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
7d4d6446
Commit
7d4d6446
authored
Jan 28, 2021
by
Matheus Miranda
Browse files
Merge branch 'issue_77_allow_groups_editing' into 'develop'
New endpoint to list groups See merge request
!31
parents
f541597a
7fad3a23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
courses/views.py
courses/views.py
+17
-0
courses/workspaces/serializers.py
courses/workspaces/serializers.py
+11
-0
No files found.
courses/views.py
View file @
7d4d6446
...
...
@@ -12,12 +12,29 @@ from .serializers import (CourseSerializer, BasicCourseProfessorSerializer,
ProfessorMessageSerializer
,
ProfessorMessageReadSerializer
,
)
from
courses.workspaces.serializers
import
CourseGroupSerializer
from
.permissions
import
(
IsProfessorCoordinatorOrAdminPermissionOrReadOnly
,
IsAssistantOrCoordinatorOrAdminOrRecipient
,
IsAdminOrReadOnly
,
)
class
CourseGroupViewSet
(
viewsets
.
ModelViewSet
):
model
=
Course
queryset
=
Course
.
objects
.
all
()
serializer_class
=
CourseGroupSerializer
def
get_queryset
(
self
):
queryset
=
super
(
CourseGroupViewSet
,
self
).
get_queryset
()
course
=
self
.
request
.
query_params
.
get
(
'id'
,
None
)
if
course
:
queryset
=
queryset
.
filter
(
groups__id
=
course
)
return
queryset
class
CourseViewSet
(
viewsets
.
ModelViewSet
):
...
...
courses/workspaces/serializers.py
View file @
7d4d6446
...
...
@@ -86,3 +86,14 @@ class CourseGroupSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Course
fields
=
(
'slug'
,
'name'
,
'groups'
)
def
update
(
self
,
instance
,
validated_data
):
data
=
self
.
context
.
get
(
'request'
).
data
course
=
super
().
update
(
instance
,
validated_data
)
if
'groups'
in
data
:
course
.
groups
.
clear
()
for
g
in
data
[
'groups'
]:
course
.
groups
.
add
(
g
)
return
course
\ No newline at end of file
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