diff --git a/api/models/agreement_signature.py b/api/models/agreement_signature.py new file mode 100644 index 0000000..0d89b6f --- /dev/null +++ b/api/models/agreement_signature.py @@ -0,0 +1,23 @@ +""" +© Ocado Group +Created on 08/07/2024 at 10:48:44(+01:00). + +""" + +from django.db import models +from .contributor import Contributor + +class AgreementSignature(models.Model): + """ Signature of a contributor signing the agreement """ + id = models.AutoField(primary_key=True) + contributor = models.ForeignKey(Contributor, on_delete=models.CASCADE) + agreement_id = models.CharField(max_length=40) + signed_at = models.DateTimeField() + + def __str__(self): + return self.id + + class Meta: + constraints = [ + models.UniqueConstraint(fields=["contributor", "agreement_id"], name='unique_contributor_agreement') + ] \ No newline at end of file diff --git a/api/models/contributor.py b/api/models/contributor.py index 3d46f57..07c5cb7 100644 --- a/api/models/contributor.py +++ b/api/models/contributor.py @@ -7,7 +7,7 @@ from django.db import models class Contributor(models.Model): - """ A contributor """ + """ A contributor that contributes to a repo""" id = models.IntegerField(primary_key=True) email = models.TextField() name = models.TextField() @@ -16,5 +16,5 @@ class Contributor(models.Model): avatar_url = models.TextField() def __str__(self): - return super().name + return self.name \ No newline at end of file diff --git a/api/models/repository.py b/api/models/repository.py index db25d00..09e4f84 100644 --- a/api/models/repository.py +++ b/api/models/repository.py @@ -4,3 +4,23 @@ """ from django.db import models +from .contributor import Contributor + +class Repository(models.Model): + """ A repository to contribute to""" + id = models.IntegerField(primary_key=True) + contributor = models.ForeignKey(Contributor, on_delete=models.CASCADE) + name_choices = [ + ("portal", "portal"), + ("rr", "rr") + ] + name = models.TextField(choices=name_choices) + points = models.IntegerField(default=0) + + def __str__(self): + return self.name + + class Meta: + constraints = [ + models.UniqueConstraint(fields=["contributor", "name"], name='unique_contributor_repo') + ] \ No newline at end of file