Coverage for sample_project/models.py: 88%

40 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-16 07:42 +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.generic.abc import GenericModel 

6from apis_core.history.models import VersionMixin 

7from apis_core.relations.models import Relation 

8 

9 

10class Profession(GenericModel, models.Model): 

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

12 

13 def __str__(self): 

14 return self.name 

15 

16 

17class Person(VersionMixin, E21_Person, AbstractEntity): 

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

19 

20 

21class Place(VersionMixin, E53_Place, AbstractEntity): 

22 pass 

23 

24 

25class Group(VersionMixin, E74_Group, AbstractEntity): 

26 pass 

27 

28 

29class IsCousinOf(Relation): 

30 subj_model = Person 

31 obj_model = Person 

32 

33 @classmethod 

34 def reverse_name(self) -> str: 

35 return "is cousin of" 

36 

37 

38class IsPartOf(Relation): 

39 subj_model = Person 

40 obj_model = Group 

41 

42 @classmethod 

43 def reverse_name(self) -> str: 

44 return "consists of" 

45 

46 

47class IsSiblingOf(Relation): 

48 subj_model = Person 

49 obj_model = Person 

50 

51 @classmethod 

52 def reverse_name(self) -> str: 

53 return "is sibling of" 

54 

55 

56class LivesIn(Relation): 

57 subj_model = Person 

58 obj_model = Place 

59 

60 @classmethod 

61 def reverse_name(self) -> str: 

62 return "has inhabitant"