Skip to content

Commit

Permalink
Merge pull request #231 from acdh-oeaw/plural-verbose-names
Browse files Browse the repository at this point in the history
Enforce singular form of verbose name to plural for relations
  • Loading branch information
gythaogg authored Dec 11, 2024
2 parents 90ceeb5 + 4eb11e3 commit 9810d24
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import OuterRef, QuerySet, Subquery
from django.db.models.signals import class_prepared
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from crum import get_current_user
Expand Down Expand Up @@ -389,6 +390,16 @@ class Meta:
abstract = True


def enforce_plural_name(sender, **kwargs):
if issubclass(sender, TibScholRelationMixin):
meta = sender._meta
# set verbose_name_plural to verbose_name
meta.verbose_name_plural = meta.verbose_name or sender.__name__.lower()


class_prepared.connect(enforce_plural_name)


class PersonActiveAtPlace(TibScholRelationMixin):
subj_model = Person
obj_model = Place
Expand Down

0 comments on commit 9810d24

Please sign in to comment.