Skip to content

Commit

Permalink
sort by -ID
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Nov 9, 2024
1 parent 8198c6c commit c1a0c71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = D203 W504
ignore = D203 W504 W503
max-line-length = 120
exclude =
*/migrations,
Expand Down
24 changes: 14 additions & 10 deletions apis_core/apis_entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,16 @@ def create_relation_methods_from_manytomany_fields(cls):
or
person.get_related_person_instances()
Note that with these methods it is not necessary to differentiate between A and B entities when self-relations exist.
Note that with these methods it is not necessary to differentiate between
A and B entities when self-relations exist.
The result of any such method call is the queryset of the related entities.
(And not a ManyToManyManager as is the case when calling <entity>.<entity>_set where in the case of self-relation
(And not a ManyToManyManager as is the case when calling <entity>.<entity>_set where
in the case of self-relation
it must be differentiated between A and B entities, e.g. person.personA_set )
It was not possible to my understanding to change managers in such a way that two (the A and the B) could be combined
It was not possible to my understanding to change managers in such a way that two
(the A and the B) could be combined
into one manager. Hence these additional shortcut methods.
:return: None
Expand All @@ -121,7 +124,8 @@ def create_function_from_manytomany_field_to_other_entity(
"""
creates the individual method from a ManyToMany field by calling the manager's objects.all()
This method creation has to be done here in a separate method, so that it can be called once before assignment
This method creation has to be done here in a separate method, so that it can be called once
before assignment
as otherwise the variable 'entity_name' in the loop below changes with each iteration and with that also the
method references (due to python's "late binding").
A method call in between thus forces the content of 'entity_name' to be assigned for good to the
Expand Down Expand Up @@ -220,7 +224,7 @@ def get_all_entity_classes(cls):
:return: list of all python classes of the entities defined within this models' module
"""

if cls._all_entity_classes == None:
if cls._all_entity_classes is None:
entity_classes = []
entity_names = []

Expand Down Expand Up @@ -515,7 +519,7 @@ class Meta:
verbose_name = "Person"
verbose_name_plural = "Personen"
ordering = [
"id",
"-id",
]

def get_tei_url(self):
Expand Down Expand Up @@ -550,7 +554,7 @@ class Meta:
verbose_name = "Ort"
verbose_name_plural = "Orte"
ordering = [
"id",
"-id",
]

def get_tei_url(self):
Expand All @@ -577,7 +581,7 @@ class Meta:
verbose_name = "Institution"
verbose_name_plural = "Institutionen"
ordering = [
"id",
"-id",
]

def get_tei_url(self):
Expand All @@ -604,7 +608,7 @@ class Meta:
verbose_name = "Ereignis"
verbose_name_plural = "Ereignisse"
ordering = [
"id",
"-id",
]

def get_tei_url(self):
Expand All @@ -629,7 +633,7 @@ class Meta:
verbose_name = "Werk"
verbose_name_plural = "Werke"
ordering = [
"id",
"-id",
]

def get_tei_url(self):
Expand Down

0 comments on commit c1a0c71

Please sign in to comment.