Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
9131a90c
Verified
Commit
9131a90c
authored
4 years ago
by
Tom Teichler
Browse files
Options
Downloads
Patches
Plain Diff
Add permissions for create users and persons
parent
576df4c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!265
Resolve "Create / delete person and group"
Pipeline
#2697
passed
4 years ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/rules.py
+12
-0
12 additions, 0 deletions
aleksis/core/rules.py
aleksis/core/views.py
+8
-2
8 additions, 2 deletions
aleksis/core/views.py
with
20 additions
and
2 deletions
aleksis/core/rules.py
+
12
−
0
View file @
9131a90c
...
...
@@ -258,3 +258,15 @@ view_group_type_predicate = has_person & (
has_global_perm
(
"
core.view_grouptype
"
)
|
has_any_object
(
"
core.view_grouptype
"
,
GroupType
)
)
add_perm
(
"
core.view_grouptype
"
,
view_group_type_predicate
)
# Create person
create_person_predicate
=
has_person
&
(
has_global_perm
(
"
core.create_person
"
)
|
has_object_perm
(
"
core.create_person
"
)
)
add_perm
(
"
core.create_person
"
,
create_person_predicate
)
# Create group
create_group_predicate
=
has_group
&
(
has_global_perm
(
"
core.create_group
"
)
|
has_object_perm
(
"
core.create_group
"
)
)
add_perm
(
"
core.create_group
"
,
create_group_predicate
)
This diff is collapsed.
Click to expand it.
aleksis/core/views.py
+
8
−
2
View file @
9131a90c
...
...
@@ -247,7 +247,10 @@ def edit_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResponse
edit_person_form
=
EditGroupForm
(
request
.
POST
or
None
,
instance
=
person
)
else
:
# Empty form to create a new group
edit_person_form
=
EditPersonForm
(
request
.
POST
or
None
)
if
request
.
user
.
has_perm
(
"
core.create_person
"
):
edit_person_form
=
EditPersonForm
(
request
.
POST
or
None
)
else
:
raise
PermissionDenied
()
if
request
.
method
==
"
POST
"
:
if
edit_person_form
.
is_valid
():
...
...
@@ -283,7 +286,10 @@ def edit_group(request: HttpRequest, id_: Optional[int] = None) -> HttpResponse:
edit_group_form
=
EditGroupForm
(
request
.
POST
or
None
,
instance
=
group
)
else
:
# Empty form to create a new group
edit_group_form
=
EditGroupForm
(
request
.
POST
or
None
)
if
request
.
user
.
has_perm
(
"
core.create_group
"
):
edit_group_form
=
EditGroupForm
(
request
.
POST
or
None
)
else
:
raise
PermissionDenied
()
if
request
.
method
==
"
POST
"
:
if
edit_group_form
.
is_valid
():
...
...
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