Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
7387b018
Commit
7387b018
authored
Sep 14, 2017
by
okhin
🚴
Browse files
Update admin.py
parent
75b91752
Pipeline
#1242
passed with stage
in 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
picampaign/campaign/admin.py
View file @
7387b018
...
...
@@ -33,11 +33,12 @@ 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
()
orgs
=
Organization
.
objects
.
all
()
else
:
query
=
{
'id__in'
:
[
x
.
id
for
x
in
request
.
user
.
organizations
.
all
()]}
kwargs
[
"queryset"
]
=
Organization
.
objects
.
filter
(
**
query
)
orgs
=
request
.
user
.
organizations
.
all
()
query
=
{
'id__in'
:
[
x
.
id
for
x
in
orgs
]}
kwargs
[
"queryset"
]
=
Organization
.
objects
.
filter
(
**
query
)
return
super
(
CampaignAdmin
,
self
).
formfield_for_foreignkey
(
db_field
,
request
,
**
kwargs
)
...
...
@@ -69,7 +70,10 @@ class ArgumentaryAdmin(TranslationAdmin):
def
formfield_for_foreignkey
(
self
,
db_field
,
request
,
**
kwargs
):
if
db_field
.
name
==
"campaign"
:
orgs
=
request
.
user
.
organizations
.
all
()
if
request
.
user
.
is_superuser
:
orgs
=
Organization
.
objects
.
all
()
else
:
orgs
=
request
.
user
.
organizations
.
all
()
query
=
{
'organization__in'
:
orgs
}
kwargs
[
"queryset"
]
=
Campaign
.
objects
.
filter
(
**
query
)
return
super
(
ArgumentaryAdmin
,
self
).
formfield_for_foreignkey
(
db_field
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment