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,6 +32,9 @@ class CampaignAdmin(TranslationAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "organization":
if request.user.is_superuser:
kwargs["queryset"] = Organization.objects.all()
else:
query = {'id__in': [x.id
for x in request.user.organizations.all()]}
kwargs["queryset"] = Organization.objects.filter(**query)
......
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