Coverage for sample_project / models.py: 98%

47 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-05 11:37 +0000

1from django.db import models 

2 

3from apis_core.apis_entities.abc import E21_Person, E53_Place, E74_Group 

4from apis_core.apis_entities.models import AbstractEntity 

5from apis_core.entities.abc import Entity 

6from apis_core.generic.abc import GenericModel 

7from apis_core.history.models import VersionMixin 

8from apis_core.relations.models import Relation 

9 

10 

11class Profession(VersionMixin, GenericModel, models.Model): 

12 name = models.CharField(blank=True, default="", max_length=1024) 

13 

14 def __str__(self): 

15 return self.name 

16 

17 

18class Person(E21_Person, VersionMixin, AbstractEntity, Entity): 

19 profession = models.ManyToManyField(Profession, blank=True) 

20 

21 

22class Place(E53_Place, VersionMixin, AbstractEntity, Entity): 

23 pass 

24 

25 

26class Group(E74_Group, VersionMixin, AbstractEntity, Entity): 

27 pass 

28 

29 

30class IsCousinOf(Relation): 

31 subj_model = Person 

32 obj_model = Person 

33 

34 @classmethod 

35 def reverse_name(self) -> str: 

36 return "is cousin of" 

37 

38 

39class IsPartOf(Relation): 

40 subj_model = Person 

41 obj_model = Group 

42 

43 @classmethod 

44 def reverse_name(self) -> str: 

45 return "consists of" 

46 

47 

48class IsSiblingOf(Relation): 

49 subj_model = Person 

50 obj_model = Person 

51 

52 @classmethod 

53 def reverse_name(self) -> str: 

54 return "is sibling of" 

55 

56 

57class LivesIn(Relation): 

58 subj_model = Person 

59 obj_model = Place 

60 

61 @classmethod 

62 def reverse_name(self) -> str: 

63 return "has inhabitant" 

64 

65 

66class IsParentOf(Relation): 

67 subj_model = Person 

68 obj_model = Person 

69 

70 @classmethod 

71 def reverse_name(self) -> str: 

72 return "is child of"