Skip to content

Commit

Permalink
Merge branch 'feature/new-concordances' of github.com:UCL/frrant into…
Browse files Browse the repository at this point in the history
… feature/new-concordances
  • Loading branch information
acholyn committed Sep 5, 2024
2 parents a083ae7 + 772c7ae commit 5dd62a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/rard/research/models/concordance.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_queryset(self):
default=Value(False),
)
)
.order_by("-is_template", "edition__name", "value")
.order_by("-is_template", "edition__name", "display_order")
)


Expand All @@ -33,7 +33,9 @@ def __str__(self):

edition = models.ForeignKey("Edition", on_delete=models.CASCADE)
value = models.CharField(max_length=250, blank=False)
display_order = models.CharField(max_length=30, blank=True)
display_order = models.CharField(
max_length=30, blank=True
) # Name for ordering purposes


class Edition(HistoryModelMixin, BaseModel):
Expand Down Expand Up @@ -107,7 +109,7 @@ def works(self):
@staticmethod
def get_ordered_queryset(queryset):
return queryset.order_by(
"identifier",
"identifier__display_order",
Case(
When(content_type="T", then=0),
When(content_type="F", then=1),
Expand Down
15 changes: 6 additions & 9 deletions src/rard/research/views/concordance.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,18 @@ def get_queryset(self, *args, **kwargs):
]
results_qs = {"frrant": results, "concordances": filtered_concordances}

elif edition_pk or identifier_pk:
elif edition_pk:
# also sort by this rather than by the frrant thing
self.sort_by_antiquarian = False
# todo:
if edition_pk:
results_qs = ConcordanceModel.get_ordered_queryset(
queryset.filter(identifier__edition=edition_pk).order_by(
"identifier__display_order"
)
queryset.filter(identifier__edition=edition_pk)
)
if identifier_pk:
if (
identifier_pk
): # Identifier should not be an option without an edition
results_qs = ConcordanceModel.get_ordered_queryset(
queryset.filter(identifier=identifier_pk).order_by(
"identifier__display_order"
)
queryset.filter(identifier=identifier_pk)
)
else:
results_qs = queryset.none()
Expand Down

0 comments on commit 5dd62a0

Please sign in to comment.