Skip to content

Commit

Permalink
Merge pull request #1835 from laws-africa/relationships
Browse files Browse the repository at this point in the history
fix direction of related judgments in admin view
  • Loading branch information
longhotsummer authored Jun 3, 2024
2 parents 304f7c0 + 5051843 commit 46e4f2a
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 @@ -749,13 +749,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 @@ -765,7 +765,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 Judgment, Work

Expand All @@ -11,7 +12,7 @@ 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

Expand Down

0 comments on commit 46e4f2a

Please sign in to comment.