Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
9aa06bbc
Commit
9aa06bbc
authored
Nov 22, 2014
by
Aymeric Barantal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transform Group.type into a GroupType model and make it organization admin view aware
parent
72af5396
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
picampaign/organization/admin.py
picampaign/organization/admin.py
+12
-1
picampaign/organization/models.py
picampaign/organization/models.py
+10
-1
No files found.
picampaign/organization/admin.py
View file @
9aa06bbc
from
django.contrib
import
admin
from
picampaign.organization.models
import
(
Organization
,
Group
,
from
picampaign.organization.models
import
(
Organization
,
Group
,
GroupType
,
FeedbackCategory
)
...
...
@@ -12,6 +12,16 @@ class OrganizationAdmin(admin.ModelAdmin):
return
qs
.
filter
(
id__in
=
user_orgs
)
class
GroupTypeAdmin
(
admin
.
ModelAdmin
):
def
get_queryset
(
self
,
request
):
qs
=
super
(
GroupTypeAdmin
,
self
).
get_queryset
(
request
)
if
request
.
user
.
is_superuser
:
return
qs
user_orgs
=
[
x
.
id
for
x
in
request
.
user
.
organizations
.
all
()]
return
qs
.
filter
(
organization__in
=
user_orgs
)
class
GroupAdmin
(
admin
.
ModelAdmin
):
def
get_queryset
(
self
,
request
):
qs
=
super
(
GroupAdmin
,
self
).
get_queryset
(
request
)
...
...
@@ -31,5 +41,6 @@ class CategoryAdmin(admin.ModelAdmin):
admin
.
site
.
register
(
Organization
,
OrganizationAdmin
)
admin
.
site
.
register
(
GroupType
,
GroupTypeAdmin
)
admin
.
site
.
register
(
Group
,
GroupAdmin
)
admin
.
site
.
register
(
FeedbackCategory
,
CategoryAdmin
)
picampaign/organization/models.py
View file @
9aa06bbc
...
...
@@ -14,12 +14,21 @@ class Organization(models.Model):
return
self
.
name
class
GroupType
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
)
organization
=
models
.
ForeignKey
(
Organization
)
name
=
models
.
CharField
(
max_length
=
64
)
def
__unicode__
(
self
):
return
self
.
name
class
Group
(
models
.
Model
):
"""Group model to qualify contacts"""
id
=
models
.
AutoField
(
primary_key
=
True
)
organization
=
models
.
ForeignKey
(
Organization
)
name
=
models
.
CharField
(
max_length
=
64
)
type
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
type
=
models
.
ForeignKey
(
GroupType
,
blank
=
True
,
null
=
True
)
media
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
contacts
=
models
.
ManyToManyField
(
Contact
,
null
=
True
,
blank
=
True
,
related_name
=
'groups'
)
...
...
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