Commit 13441dbf authored by okhin's avatar okhin 🚴

Fixing the formfield function in case of superuser.

parent c3984fb3
Pipeline #1239 passed with stage
in 54 seconds
...@@ -32,9 +32,12 @@ class CampaignAdmin(TranslationAdmin): ...@@ -32,9 +32,12 @@ class CampaignAdmin(TranslationAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs): def formfield_for_foreignkey(self, db_field, request, **kwargs):
if == "organization": if == "organization":
query = {'id__in': [ if request.user.is_superuser:
for x in request.user.organizations.all()]} kwargs["queryset"] = Organization.objects.all()
kwargs["queryset"] = Organization.objects.filter(**query) else:
query = {'id__in': [
for x in request.user.organizations.all()]}
kwargs["queryset"] = Organization.objects.filter(**query)
return super(CampaignAdmin, self).formfield_for_foreignkey(db_field, return super(CampaignAdmin, self).formfield_for_foreignkey(db_field,
request, request,
**kwargs) **kwargs)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment