Coverage for sample_project/models.py: 88%
40 statements
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +0000
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +0000
1from django.db import models
3from apis_core.apis_entities.abc import E21_Person, E53_Place, E74_Group
4from apis_core.apis_entities.models import AbstractEntity
5from apis_core.generic.abc import GenericModel
6from apis_core.history.models import VersionMixin
7from apis_core.relations.models import Relation
10class Profession(GenericModel, models.Model):
11 name = models.CharField(blank=True, default="", max_length=1024)
13 def __str__(self):
14 return self.name
17class Person(VersionMixin, E21_Person, AbstractEntity):
18 profession = models.ManyToManyField(Profession, blank=True)
21class Place(VersionMixin, E53_Place, AbstractEntity):
22 pass
25class Group(VersionMixin, E74_Group, AbstractEntity):
26 pass
29class IsCousinOf(Relation):
30 subj_model = Person
31 obj_model = Person
33 @classmethod
34 def reverse_name(self) -> str:
35 return "is cousin of"
38class IsPartOf(Relation):
39 subj_model = Person
40 obj_model = Group
42 @classmethod
43 def reverse_name(self) -> str:
44 return "consists of"
47class IsSiblingOf(Relation):
48 subj_model = Person
49 obj_model = Person
51 @classmethod
52 def reverse_name(self) -> str:
53 return "is sibling of"
56class LivesIn(Relation):
57 subj_model = Person
58 obj_model = Place
60 @classmethod
61 def reverse_name(self) -> str:
62 return "has inhabitant"