Skip to content

Commit

Permalink
Change meta classes
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Jul 10, 2024
1 parent 9f55c76 commit def8ff7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
16 changes: 12 additions & 4 deletions api/models/agreement_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
Created on 08/07/2024 at 10:48:44(+01:00).
"""

from django.db import models
import typing as t

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

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta # pragma: no cover
else:
TypedModelMeta = object



class AgreementSignature(models.Model):
Expand All @@ -15,10 +23,10 @@ class AgreementSignature(models.Model):
agreement_id = models.CharField(max_length=40)
signed_at = models.DateTimeField()

class Meta:
class Meta(TypedModelMeta):
unique_together = ["contributor", "agreement_id"]
verbose_name = "agreement_signature"
verbose_name_plural = "agreement_signatures"
verbose_name = _("agreement_signature")
verbose_name_plural = _("agreement_signatures")

def __str__(self):
cont = f"Contributor {self.contributor} signed"
Expand Down
14 changes: 11 additions & 3 deletions api/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
Created on 05/07/2024 at 16:18:48(+01:00).
"""

import typing as t

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

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta # pragma: no cover
else:
TypedModelMeta = object


class Contributor(models.Model):
Expand All @@ -16,9 +24,9 @@ class Contributor(models.Model):
html_url = models.TextField()
avatar_url = models.TextField()

class Meta:
verbose_name = "contributor"
verbose_name_plural = "contributors"
class Meta(TypedModelMeta):
verbose_name = _("contributor")
verbose_name_plural = _("contributors")

def __str__(self):
return self.name
2 changes: 1 addition & 1 deletion api/models/fruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.utils.translation import gettext_lazy as _

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta
from django_stubs_ext.db.models import TypedModelMeta # pragma: no cover
else:
TypedModelMeta = object

Expand Down
16 changes: 12 additions & 4 deletions api/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
Created on 05/07/2024 at 16:39:14(+01:00).
"""

from django.db import models
import typing as t

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

if t.TYPE_CHECKING:
from django_stubs_ext.db.models import TypedModelMeta # pragma: no cover
else:
TypedModelMeta = object



class Repository(models.Model):
Expand All @@ -17,10 +25,10 @@ class Repository(models.Model):
name = models.TextField(choices=NAME_CHOICES)
points = models.IntegerField(default=0)

class Meta:
class Meta(TypedModelMeta):
unique_together = ["contributor", "name"]
verbose_name = "repository"
verbose_name_plural = "repositories"
verbose_name = _("repository")
verbose_name_plural = _("repositories")

def __str__(self):
return self.name

0 comments on commit def8ff7

Please sign in to comment.