SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
d28bea6b
Commit
d28bea6b
authored
6 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Allow ContactRole update to all Contacts of an Organization
parent
8aa15c41
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
organizations/views.py
+11
-2
11 additions, 2 deletions
organizations/views.py
with
11 additions
and
2 deletions
organizations/views.py
+
11
−
2
View file @
d28bea6b
...
...
@@ -4,6 +4,7 @@ __license__ = "AGPL v3"
from
django.contrib
import
messages
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.mixins
import
UserPassesTestMixin
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse_lazy
from
django.db
import
transaction
...
...
@@ -179,15 +180,23 @@ def dashboard(request):
return
render
(
request
,
'
organizations/dashboard.html
'
,
context
)
class
ContactRoleUpdateView
(
Permissions
Mixin
,
UpdateView
):
class
ContactRoleUpdateView
(
UserPassesTest
Mixin
,
UpdateView
):
"""
Update a ContactRole.
"""
permission_required
=
'
scipost.can_manage_organizations
'
model
=
ContactRole
form_class
=
ContactRoleForm
template_name
=
'
organizations/contactrole_form.html
'
def
test_func
(
self
):
"""
Allow ContactRole update to OrgAdmins and all Contacts for this Organization.
"""
if
self
.
request
.
user
.
has_perm
(
'
scipost.can_manage_organizations
'
):
return
True
contactrole
=
get_object_or_404
(
ContactRole
,
pk
=
self
.
kwargs
.
get
(
'
pk
'
))
return
self
.
request
.
user
.
has_perm
(
'
can_view_org_contacts
'
,
contactrole
.
organization
)
def
get_success_url
(
self
):
return
reverse_lazy
(
'
organizations:organization_details
'
,
kwargs
=
{
'
pk
'
:
self
.
object
.
organization
.
id
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment