From c55dc561c68e7fb24e4396e815a95b0ec7a24106 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 7 Dec 2020 22:38:47 +0100 Subject: Update doc with grammatical gender and long title --- ishtar_common/models.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'ishtar_common/models.py') 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,11 +1638,30 @@ 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") @@ -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) -- cgit v1.2.3