Skip to content

Commit

Permalink
change model fields
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Jul 9, 2024
1 parent b70bda6 commit bdb7581
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions api/models/agreement_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
Created on 08/07/2024 at 10:48:44(+01:00).
"""

import typing as t

from django.db import models
from django.utils.translation import gettext_lazy as _
from .contributor import Contributor

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta

from .contributor import Contributor
else:
TypedModelMeta = object



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')
]
unique_together = ["contributor", "agreement_id"]

def __str__(self):
return f"Contributor {self.contributor} signed
{self.agreement_id[:7]} at {self.signed_at}"
Empty file.
Empty file added api/models/contributor_test.py
Empty file.
17 changes: 8 additions & 9 deletions api/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@

from django.db import models
from django.utils.translation import gettext_lazy as _
from .contributor import Contributor

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta

from .contributor import Contributor
else:
TypedModelMeta = object

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 = [
NAME_CHOICES = [
("portal", "portal"),
("rr", "rr")
]
name = models.TextField(choices=name_choices)
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')
]
unique_together = ["contributor", "name"]

def __str__(self):
return self.name
Empty file added api/models/repository_test.py
Empty file.

0 comments on commit bdb7581

Please sign in to comment.