Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix direction of related judgments in admin view #1835

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading