Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kontr 2.0
Portal API Backend
Commits
7b189187
Verified
Commit
7b189187
authored
Feb 10, 2019
by
Peter Stanko
Browse files
Partials - permissions should be partials
parent
5e2f142d
Pipeline
#28723
passed with stage
in 3 minutes and 14 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
portal/database/models.py
View file @
7b189187
...
...
@@ -740,8 +740,9 @@ class Role(db.Model, EntityBase, NamedMixin):
Args:
**kwargs: Permissions
"""
IGNORED_PARAMS
=
(
'id'
,
'course_id'
,
'course'
,
'created_at'
,
'updated_at'
)
for
k
,
w
in
kwargs
.
items
():
if
hasattr
(
self
,
k
)
and
k
not
in
(
'id'
,
'course_id'
,
'course'
)
:
if
hasattr
(
self
,
k
)
and
k
not
in
IGNORED_PARAMS
:
setattr
(
self
,
k
,
w
)
__table_args__
=
(
...
...
portal/rest/roles.py
View file @
7b189187
...
...
@@ -110,7 +110,8 @@ class RolePermissions(CustomResource):
# authorization
self
.
permissions
(
course
=
course
).
require
.
write_roles
()
data
=
rest_helpers
.
parse_request_data
(
action
=
'update'
,
resource
=
'permissions'
)
data
=
rest_helpers
.
parse_request_data
(
action
=
'update'
,
resource
=
'permissions'
,
partial
=
True
)
role
=
self
.
find
.
role
(
course
,
rid
)
log
.
info
(
f
"[REST] Update role permissions for"
f
"
{
role
.
log_name
}
by
{
self
.
client
.
log_name
}
:
{
data
}
"
)
...
...
portal/rest/schemas.py
View file @
7b189187
...
...
@@ -202,9 +202,33 @@ class RoleSchema(BaseSchema, NamedSchema, Schema):
"""
clients
=
NESTED
[
'clients'
]
course
=
NESTED
[
'course'
]
# this could be done prettier (e.g. flattening the structure, showing only
# set fields)
permissions
=
NESTED
(
"RolePermissions"
)
view_course_limited
=
fields
.
Bool
()
view_course_full
=
fields
.
Bool
()
update_course
=
fields
.
Bool
()
handle_notes_access_token
=
fields
.
Bool
()
write_roles
=
fields
.
Bool
()
write_groups
=
fields
.
Bool
()
write_projects
=
fields
.
Bool
()
archive_projects
=
fields
.
Bool
()
create_submissions
=
fields
.
Bool
()
create_submissions_other
=
fields
.
Bool
()
resubmit_submissions
=
fields
.
Bool
()
evaluate_submissions
=
fields
.
Bool
()
read_submissions_all
=
fields
.
Bool
()
read_submissions_groups
=
fields
.
Bool
()
read_submissions_own
=
fields
.
Bool
()
read_all_submission_files
=
fields
.
Bool
()
read_reviews_all
=
fields
.
Bool
()
read_reviews_groups
=
fields
.
Bool
()
read_reviews_own
=
fields
.
Bool
()
write_reviews_all
=
fields
.
Bool
()
write_reviews_group
=
fields
.
Bool
()
write_reviews_own
=
fields
.
Bool
()
class
ClientSchema
(
BaseSchema
,
Schema
):
...
...
@@ -214,7 +238,6 @@ class ClientSchema(BaseSchema, Schema):
class
RolePermissionsSchema
(
BaseSchema
,
Schema
):
"""Role Permissions Schema
"""
role
=
NESTED
[
'role'
]
view_course_limited
=
fields
.
Bool
()
view_course_full
=
fields
.
Bool
()
update_course
=
fields
.
Bool
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment