Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
7c2b69ca
Commit
7c2b69ca
authored
4 years ago
by
Bruno Martin
Browse files
Options
Download
Email Patches
Plain Diff
add field to check if current user can edit the
classroom
parent
337af319
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
courses/classroom/serializers.py
courses/classroom/serializers.py
+9
-0
No files found.
courses/classroom/serializers.py
View file @
7c2b69ca
...
...
@@ -40,6 +40,7 @@ class ClassroomSerializer(serializers.ModelSerializer):
events
=
EventSerializer
(
read_only
=
True
,
many
=
True
)
courses
=
BasicCourseSerializer
(
read_only
=
True
,
many
=
True
)
forum
=
ForumSumarySerializer
(
read_only
=
True
)
can_edit
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
Classroom
...
...
@@ -55,5 +56,13 @@ class ClassroomSerializer(serializers.ModelSerializer):
'events'
,
'chat_url'
,
'forum'
,
'can_edit'
,
)
depth
=
1
def
get_can_edit
(
self
,
obj
):
request
=
self
.
context
.
get
(
"request"
,
None
)
if
request
and
hasattr
(
request
,
"user"
):
return
request
.
user
in
obj
.
assistants
.
all
()
\
or
request
.
user
in
obj
.
coordinators
.
all
()
\
or
request
.
user
.
is_superuser
This diff is collapsed.
Click to expand it.
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