Skip to content

Commit

Permalink
Merge pull request #163 from nens/StevenHosper/issue157
Browse files Browse the repository at this point in the history
[GENERAL]: Add contracts
  • Loading branch information
StevenHosper authored Dec 18, 2024
2 parents 27214f2 + 2b3f1bf commit 2cf1660
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
46 changes: 46 additions & 0 deletions api/migrations/0052_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 5.0.4 on 2024-12-18 10:04

import uuid

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("api", "0051_bulkupload_sourcedocument_data_and_more"),
]

operations = [
migrations.CreateModel(
name="Contract",
fields=[
(
"uuid",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("start_date", models.DateTimeField()),
("end_date", models.DateTimeField()),
("nr_of_messages", models.BigIntegerField(default=0)),
("description", models.TextField()),
("created", models.DateTimeField(auto_now_add=True)),
("updated", models.DateTimeField(auto_now=True)),
(
"organisation",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to="api.organisation",
),
),
],
options={
"verbose_name": "Contract",
"verbose_name_plural": "Contracts",
},
),
]
20 changes: 20 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ def __str__(self) -> str:
return self.name


class Contract(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
organisation = models.OneToOneField(
Organisation, on_delete=models.CASCADE, null=False
)
start_date = models.DateTimeField(null=False, blank=False)
end_date = models.DateTimeField()
nr_of_messages = models.BigIntegerField(null=False, blank=False, default=0)
description = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)

def __str__(self) -> str:
return f"{self.organisation} ({self.start_date} - {self.end_date if self.end_date else 'onbepaald'})"

class Meta:
verbose_name = "Contract"
verbose_name_plural = "Contracts"


class UserProfile(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.OneToOneField(User, on_delete=models.CASCADE)
Expand Down

0 comments on commit 2cf1660

Please sign in to comment.