From 768881356ebe8ec01a6c087a7c1298d18aaafb26 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Mon, 29 Jan 2024 15:58:28 +0100 Subject: [PATCH] feat(apis_entities): implement default abstract entity classes Closes: #403 --- apis_core/apis_entities/abc.py | 35 ++++++++++++++++++++++++++++++++++ apis_core/core/abc.py | 8 ++++++++ 2 files changed, 43 insertions(+) create mode 100644 apis_core/apis_entities/abc.py create mode 100644 apis_core/core/abc.py diff --git a/apis_core/apis_entities/abc.py b/apis_core/apis_entities/abc.py new file mode 100644 index 000000000..aa2dd33b7 --- /dev/null +++ b/apis_core/apis_entities/abc.py @@ -0,0 +1,35 @@ +from django.db import models +from apis_core.core.abc import LabelBaseModel + +######################### +# Abstract base classes # +######################### + + +# These abstract base classes are named after +# CIDOC CRM entities, but we are *NOT*(!) +# trying to implement CIDOC CRM in Django. + + +class E21_Person(LabelBaseModel, models.Model): + forename = models.CharField(blank=True, default="") + surname = models.CharField(blank=True, default="") + gender = models.CharField(blank=True, default="") + date_of_birth = models.DateField(blank=True, null=True) + date_of_death = models.DateField(blank=True, null=True) + + class Meta: + abstract = True + + +class E53_Place(LabelBaseModel, models.Model): + longitude = models.FloatField(blank=True, null=True) + latitude = models.FloatField(blank=True, null=True) + + class Meta: + abstract = True + + +class E74_Group(LabelBaseModel, models.Model): + class Meta: + abstract = True diff --git a/apis_core/core/abc.py b/apis_core/core/abc.py new file mode 100644 index 000000000..abc03683c --- /dev/null +++ b/apis_core/core/abc.py @@ -0,0 +1,8 @@ +from django.db import models + + +class LabelBaseModel(models.Model): + label = models.CharField(blank=True, default="") + + class Meta: + abstract = True