diff options
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 |
commit | c55dc561c68e7fb24e4396e815a95b0ec7a24106 (patch) | |
tree | 56200214cef47ad38209d35f4608b957c3b83a70 /ishtar_common | |
parent | ee0179cbbe14e400aff6b0e9c865ce6e36152ea4 (diff) | |
download | Ishtar-c55dc561c68e7fb24e4396e815a95b0ec7a24106.tar.bz2 Ishtar-c55dc561c68e7fb24e4396e815a95b0ec7a24106.zip |
Update doc with grammatical gender and long title
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 36 |
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) |