diff options
Diffstat (limited to 'ishtar_common/models.py')
-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) |