summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-12-07 22:38:47 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:22 +0100
commitc56a6656b21a665e0fccad074d938c945f97f948 (patch)
tree56200214cef47ad38209d35f4608b957c3b83a70 /ishtar_common
parent0959e0414816adbfcb3f20e7a85b0cd972236777 (diff)
downloadIshtar-c56a6656b21a665e0fccad074d938c945f97f948.tar.bz2
Ishtar-c56a6656b21a665e0fccad074d938c945f97f948.zip
Update doc with grammatical gender and long title
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index cf0a41c54..55d9ed164 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1638,12 +1638,31 @@ GENDER = (
)
-class OrganizationType(GeneralType):
+class GenderedType(GeneralType):
grammatical_gender = models.CharField(
_("Grammatical gender"), max_length=1, choices=GENDER,
blank=True, default="")
class Meta:
+ abstract = True
+
+ @classmethod
+ def get_documentation_string(cls):
+ """
+ Used for automatic documentation generation
+ """
+ doc = super(GenderedType, cls).get_documentation_string()
+ doc += ", **grammatical_gender** {} -".format(_("Grammatical gender"))
+ for idx, gender in enumerate(GENDER):
+ key, label = gender
+ if idx:
+ doc += " ;"
+ doc += ' "{}": {}'.format(key, label)
+ return doc
+
+
+class OrganizationType(GenderedType):
+ class Meta:
verbose_name = _("Organization type")
verbose_name_plural = _("Organization types")
ordering = ('label',)
@@ -1780,11 +1799,7 @@ class Organization(Address, Merge, OwnPerms, ValueGetter, MainItem):
post_save.connect(cached_label_changed, sender=Organization)
-class PersonType(GeneralType):
- grammatical_gender = models.CharField(
- _("Grammatical gender"), max_length=1, choices=GENDER,
- blank=True, default="")
-
+class PersonType(GenderedType):
class Meta:
verbose_name = _("Person type")
verbose_name_plural = _("Person types")
@@ -1855,6 +1870,15 @@ class TitleType(GeneralType):
verbose_name_plural = _("Title types")
ordering = ('label',)
+ @classmethod
+ def get_documentation_string(cls):
+ """
+ Used for automatic documentation generation
+ """
+ doc = super(TitleType, cls).get_documentation_string()
+ doc += ", **long_title** {}".format(_("Long title"))
+ return doc
+
post_save.connect(post_save_cache, sender=TitleType)
post_delete.connect(post_save_cache, sender=TitleType)