Commit 75b91752 authored by okhin's avatar okhin 🚴

Merge branch...

Merge branch '21-an-organization-does-not-appears-in-the-selectable-one-for-a-campaign' into 'master'

Resolve "An organization does not appears in the selectable one for a campaign`"

Closes #21

See merge request !10
parents c3984fb3 13441dbf
Pipeline #1241 passed with stage
in 50 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 db_field.name == "organization": if db_field.name == "organization":
query = {'id__in': [x.id 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': [x.id
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