Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string methods #37

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class Meta:
abstract = True


class NameMixin(models.Model):
class GenericNameMixin(models.Model):
"""
Mixin for "name" field shared between entities.
Mixin for generic "name" field used by entities.
"""

name = models.CharField(
Expand Down Expand Up @@ -120,6 +120,9 @@ class PersonNameMixin(AlternativeNameMixin, models.Model):
class Meta:
abstract = True

def __str__(self):
return self.full_name()

def full_name(self):
full_name = ""
surname = self.surname
Expand Down Expand Up @@ -164,6 +167,9 @@ class TitlesMixin(models.Model):
class Meta:
abstract = True

def __str__(self):
return self.title

def full_title(self):
full_title = self.title
subtitle = self.subtitle
Expand Down Expand Up @@ -455,7 +461,11 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class WorkType(
NameMixin, AlternativeNameMixin, DescriptionMixin, StatusMixin, AbstractEntity
GenericNameMixin,
AlternativeNameMixin,
DescriptionMixin,
StatusMixin,
AbstractEntity,
):
name_plural = models.CharField(
max_length=255,
Expand Down Expand Up @@ -588,7 +598,7 @@ def save(self, *args, **kwargs):


@reversion.register(follow=["rootobject_ptr"])
class Archive(NameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
class Archive(GenericNameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
"""
An institution or organisation where physical objects are
stored and cared for.
Expand Down Expand Up @@ -624,7 +634,7 @@ class Meta:


@reversion.register(follow=["rootobject_ptr"])
class PhysicalObject(NameMixin, DescriptionMixin, AbstractEntity):
class PhysicalObject(GenericNameMixin, DescriptionMixin, AbstractEntity):
"""
A physical object pertaining to a Work.

Expand Down Expand Up @@ -680,7 +690,11 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class Organisation(
NameMixin, AlternativeNameMixin, DescriptionMixin, StatusMixin, AbstractEntity
GenericNameMixin,
AlternativeNameMixin,
DescriptionMixin,
StatusMixin,
AbstractEntity,
):
"""
Any legal entity, or subunit of a legal entity.
Expand Down Expand Up @@ -763,7 +777,7 @@ class Meta:


@reversion.register(follow=["rootobject_ptr"])
class MetaCharacter(NameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
class MetaCharacter(GenericNameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
"""
A composite entity to refer to related characters across works.

Expand All @@ -789,7 +803,11 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class Place(
NameMixin, AlternativeNameMixin, DescriptionMixin, StatusMixin, AbstractEntity
GenericNameMixin,
AlternativeNameMixin,
DescriptionMixin,
StatusMixin,
AbstractEntity,
):
"""
A real place in our world, either in the past or present.
Expand Down Expand Up @@ -825,7 +843,11 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class ResearchPerspective(
NameMixin, AlternativeNameMixin, DescriptionMixin, StatusMixin, AbstractEntity
GenericNameMixin,
AlternativeNameMixin,
DescriptionMixin,
StatusMixin,
AbstractEntity,
):
"""
Lens through which works are investigated.
Expand All @@ -848,7 +870,11 @@ class Meta:

@reversion.register(follow=["rootobject_ptr"])
class Topic(
NameMixin, AlternativeNameMixin, DescriptionMixin, StatusMixin, AbstractEntity
GenericNameMixin,
AlternativeNameMixin,
DescriptionMixin,
StatusMixin,
AbstractEntity,
):
"""
Topic with regard to content, theme.
Expand All @@ -870,7 +896,7 @@ class Meta:


@reversion.register(follow=["rootobject_ptr"])
class Interpretatem(NameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
class Interpretatem(GenericNameMixin, DescriptionMixin, StatusMixin, AbstractEntity):
"""
A conceptual object representing a specific (interpretative/scholarly)
view on one or more Works.
Expand Down
Loading