Skip to content

Commit

Permalink
fix direction of related judgments in admin view
Browse files Browse the repository at this point in the history
subject/object should be reversed

also makes work autocomplete a bit broader
  • Loading branch information
longhotsummer committed Jun 1, 2024
1 parent 28bf8f5 commit 5051843
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,13 @@ class LowerBenchInline(admin.TabularInline):

class JudgmentRelationshipStackedInline(NonrelatedTabularInline):
model = Relationship
fields = ["predicate", "subject_work"]
fields = ["predicate", "object_work"]
verbose_name = "Related judgment"
verbose_name_plural = "Related judgments"
extra = 2

def get_form_queryset(self, obj):
return Relationship.objects.filter(object_work=obj.work)
return Relationship.objects.filter(subject_work=obj.work)

def save_new_instance(self, parent, instance):
instance.object_work = parent.work
Expand All @@ -744,7 +744,7 @@ def get_formset(self, request, obj=None, **kwargs):
request,
obj,
widgets={
"subject_work": autocomplete.ModelSelect2(url="autocomplete-works")
"object_work": autocomplete.ModelSelect2(url="autocomplete-works")
},
**kwargs,
)
Expand Down
3 changes: 2 additions & 1 deletion peachjam/views/autocomplete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dal import autocomplete
from django.db.models import Q

from peachjam.models import Work

Expand All @@ -11,6 +12,6 @@ def get_queryset(self):

qs = Work.objects.all()
if self.q:
qs = qs.filter(title__istartswith=self.q)
qs = qs.filter(Q(title__icontains=self.q) | Q(frbr_uri__icontains=self.q))

return qs

0 comments on commit 5051843

Please sign in to comment.