Skip to content

Commit

Permalink
refactor: rename LegacyStuffMixin to SicprodMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 17, 2024
1 parent de9fa75 commit 3ff8942
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
16 changes: 8 additions & 8 deletions apis_ontology/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, *args, **kwargs):
self.fields.move_to_end("columns", False)


class LegacyStuffMixinFilterSet(AbstractEntityFilterSet):
class SicprodMixinFilterSet(AbstractEntityFilterSet):
collection = django_filters.ModelMultipleChoiceFilter(
queryset=SkosCollection.objects.filter(parent__name="sicprod").order_by("name"),
label="Collections",
Expand All @@ -81,22 +81,22 @@ class Meta(AbstractEntityFilterSet.Meta):
form = SicprodLegacyStuffFilterSetForm


class SalaryFilterSet(LegacyStuffMixinFilterSet):
class SalaryFilterSet(SicprodMixinFilterSet):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filters["typ"].method = filter_empty_string
self.filters["typ"].extra["choices"] = (*self.filters["typ"].extra["choices"], ("empty", "Nicht gesetzt"))
self.filters["typ"].extra["required"] = False


class FunctionFilterSet(LegacyStuffMixinFilterSet):
class FunctionFilterSet(SicprodMixinFilterSet):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filters["name"].method = name_alternative_name_filter
self.filters["name"].label = "Name or alternative name"


class PlaceFilterSet(LegacyStuffMixinFilterSet):
class PlaceFilterSet(SicprodMixinFilterSet):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filters["type"].method = filter_empty_string
Expand All @@ -108,8 +108,8 @@ def __init__(self, *args, **kwargs):
PERSON_FILTERS_EXCLUDE.remove("status")


class PersonFilterSet(LegacyStuffMixinFilterSet):
class Meta(LegacyStuffMixinFilterSet.Meta):
class PersonFilterSet(SicprodMixinFilterSet):
class Meta(SicprodMixinFilterSet.Meta):
exclude = PERSON_FILTERS_EXCLUDE

def __init__(self, *args, **kwargs):
Expand All @@ -121,7 +121,7 @@ def __init__(self, *args, **kwargs):
self.filters["gender"].extra["required"] = False


class InstitutionFilterSet(LegacyStuffMixinFilterSet):
class InstitutionFilterSet(SicprodMixinFilterSet):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.filters["name"].method = name_alternative_name_filter
Expand Down Expand Up @@ -213,7 +213,7 @@ class InstitutionApiFilterSet(FacetFilterSetMixin, InstitutionFilterSet):
pass


class EventApiFilterSet(FacetFilterSetMixin, LegacyStuffMixinFilterSet):
class EventApiFilterSet(FacetFilterSetMixin, SicprodMixinFilterSet):
pass


Expand Down
16 changes: 8 additions & 8 deletions apis_ontology/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MyModelMultipleChoiceField(forms.ModelMultipleChoiceField):
from apis_core.generic.forms.widgets import NewlineSeparatedListWidget


class LegacyStuffMixinForm(GenericModelForm):
class SicprodMixinForm(GenericModelForm):
collections = MyModelMultipleChoiceField(queryset=SkosCollection.objects.filter(parent=SkosCollection.objects.get(name="sicprod")), required=False)

class Meta(GenericModelForm.Meta):
Expand Down Expand Up @@ -41,29 +41,29 @@ def save(self, *args, **kwargs):
return obj


class PersonForm(LegacyStuffMixinForm):
class PersonForm(SicprodMixinForm):
field_order = ["first_name", "name", "start_date_written", "end_date_written", "status", "collection", "gender", "alternative_label"]

class Meta(LegacyStuffMixinForm.Meta):
class Meta(SicprodMixinForm.Meta):
model = Person
exclude = ["published", "deprecated_name"]


class PlaceForm(LegacyStuffMixinForm):
class PlaceForm(SicprodMixinForm):
field_order = ["label", "type", "latitude", "longitude", "status", "collection"]


class InstitutionForm(LegacyStuffMixinForm):
class InstitutionForm(SicprodMixinForm):
field_order = ["name", "start_date_written", "end_date_written", "kind", "status", "collection"]


class EventForm(LegacyStuffMixinForm):
class EventForm(SicprodMixinForm):
field_order = ["name", "start_date_written", "end_date_written", "kind", "status", "collection"]


class FunctionForm(LegacyStuffMixinForm):
class FunctionForm(SicprodMixinForm):
field_order = ["name", "start_date_written", "end_date_written", "kind", "status", "collection"]


class SalaryForm(LegacyStuffMixinForm):
class SalaryForm(SicprodMixinForm):
field_order = ["name", "start_date_written", "end_date_written", "kind", "status", "collection"]
15 changes: 8 additions & 7 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from auditlog.registry import auditlog


class LegacyStuffMixin(models.Model):
class SicprodMixin(models.Model):
""" A mixin providing generic fields and functionality for all Sicprod Models """
review = review = models.BooleanField(default=False, help_text="Should be set to True, if the data record holds up quality standards.")
status = models.CharField(max_length=100, blank=True)
references = models.TextField(blank=True, null=True)
Expand All @@ -32,7 +33,7 @@ def sicprod_collections(self):
return SkosCollection.objects.filter(id__in=sccos)


class Person(VersionMixin, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
class Person(VersionMixin, SicprodMixin, LegacyDateMixin, AbstractEntity):
"""
Person, eine Subklasse von crm:E21_Person.
"""
Expand All @@ -50,7 +51,7 @@ def __str__(self):
return "{}, {} (ID: {})".format(self.name, self.first_name, self.id)


class Function(VersionMixin, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
class Function(VersionMixin, SicprodMixin, LegacyDateMixin, AbstractEntity):
"""
Eine Funktion kann von einer Person an einer Institution oder einem Hof ausgeübt werden kann.
"""
Expand All @@ -62,7 +63,7 @@ class Meta:
ordering = ["name"]


class Place(VersionMixin, LegacyStuffMixin, LegacyDateMixin, E53_Place, AbstractEntity):
class Place(VersionMixin, SicprodMixin, LegacyDateMixin, E53_Place, AbstractEntity):
"""
Orte in SiCProD, Subklasse von crm:E53_Place.
"""
Expand All @@ -79,7 +80,7 @@ def __str__(self):
return self.label


class Institution(VersionMixin, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
class Institution(VersionMixin, SicprodMixin, LegacyDateMixin, AbstractEntity):
"""
SiCProD Institution, Subklasse von crm:E74_Group. Wird für alle Institutionen benutzt die kein Hof sind
"""
Expand All @@ -93,7 +94,7 @@ class Meta:
ordering = ["name"]


class Event(VersionMixin, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
class Event(VersionMixin, SicprodMixin, LegacyDateMixin, AbstractEntity):
"""
SiCProD Ereignis, Subklasse von crm:E5_Event.
"""
Expand All @@ -107,7 +108,7 @@ class Meta:
ordering = ["name"]


class Salary(VersionMixin, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
class Salary(VersionMixin, SicprodMixin, LegacyDateMixin, AbstractEntity):
"""
Ein Gehalt ist die Menge an Geld die eine Person als Gegenleistung erhalten hat. Das Gehalt muss keine wiederkehrende Zahlung sein.
"""
Expand Down
2 changes: 1 addition & 1 deletion apis_ontology/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_references(self, obj):
return SimplifiedReferenceSerializer(references, many=True).data


class LegacyStuffMixinSerializer(GenericHyperlinkedModelSerializer):
class SicprodMixinSerializer(GenericHyperlinkedModelSerializer):
class Meta:
fields = ["name"]

Expand Down

0 comments on commit 3ff8942

Please sign in to comment.