Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
campaign
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
13441dbf
Commit
13441dbf
authored
Sep 14, 2017
by
okhin
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing the formfield function in case of superuser.
parent
c3984fb3
Pipeline
#1239
passed with stage
in 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
picampaign/campaign/admin.py
picampaign/campaign/admin.py
+6
-3
No files found.
picampaign/campaign/admin.py
View file @
13441dbf
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
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