Fix CampViewMixin to deal properly with multiple camp_filters when dealing with SingleObjectMixin based CBVs
This commit is contained in:
parent
8ac973bc61
commit
b602e394fe
|
@ -24,7 +24,11 @@ class CampViewMixin(object):
|
|||
camp_filter = [camp_filter]
|
||||
|
||||
for _filter in camp_filter:
|
||||
result = queryset.filter(**{_filter: self.camp})
|
||||
filter_dict = {_filter: self.camp}
|
||||
if hasattr(self, 'pk_url_kwarg'):
|
||||
# We should also filter for the pk of the object
|
||||
filter_dict['pk'] = str(self.kwargs.get(self.pk_url_kwarg))
|
||||
result = queryset.filter(**filter_dict)
|
||||
if result.exists():
|
||||
return result
|
||||
|
||||
|
|
|
@ -146,7 +146,12 @@ class Url(CampRelatedModel):
|
|||
def camp(self):
|
||||
return self.owner.camp
|
||||
|
||||
camp_filter = 'owner__camp'
|
||||
camp_filter = [
|
||||
'speakerproposal__camp',
|
||||
'eventproposal__track__camp',
|
||||
'speaker__camp',
|
||||
'event__track__camp',
|
||||
]
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
|
Loading…
Reference in a new issue