Skip to content

Commit

Permalink
api models for contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Jul 8, 2024
1 parent b267d6f commit 84fd2a1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
23 changes: 23 additions & 0 deletions api/models/agreement_signature.py
Original file line number Diff line number Diff line change
@@ -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')
]
4 changes: 2 additions & 2 deletions api/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -16,5 +16,5 @@ class Contributor(models.Model):
avatar_url = models.TextField()

def __str__(self):
return super().name
return self.name

20 changes: 20 additions & 0 deletions api/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
]

0 comments on commit 84fd2a1

Please sign in to comment.