Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Jan Maximilian Michal
grady
Commits
b7a129c8
Commit
b7a129c8
authored
6 years ago
by
robinwilliam.hundt
Browse files
Options
Downloads
Patches
Plain Diff
Added user_pk to StudentInfoSerializer / new /user/<pk>/change_active/ route
parent
75a9f1bb
No related branches found
No related tags found
1 merge request
!108
Student and user deactivate
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/serializers/student.py
+2
-0
2 additions, 0 deletions
core/serializers/student.py
core/views/common_views.py
+15
-0
15 additions, 0 deletions
core/views/common_views.py
with
17 additions
and
0 deletions
core/serializers/student.py
+
2
−
0
View file @
b7a129c8
...
@@ -26,6 +26,7 @@ class StudentInfoSerializer(DynamicFieldsModelSerializer):
...
@@ -26,6 +26,7 @@ class StudentInfoSerializer(DynamicFieldsModelSerializer):
class
StudentInfoSerializerForListView
(
DynamicFieldsModelSerializer
):
class
StudentInfoSerializerForListView
(
DynamicFieldsModelSerializer
):
name
=
serializers
.
ReadOnlyField
(
source
=
'
user.fullname
'
)
name
=
serializers
.
ReadOnlyField
(
source
=
'
user.fullname
'
)
user
=
serializers
.
ReadOnlyField
(
source
=
'
user.username
'
)
user
=
serializers
.
ReadOnlyField
(
source
=
'
user.username
'
)
user_pk
=
serializers
.
ReadOnlyField
(
source
=
'
user.pk
'
)
exam
=
serializers
.
ReadOnlyField
(
source
=
'
exam.module_reference
'
)
exam
=
serializers
.
ReadOnlyField
(
source
=
'
exam.module_reference
'
)
submissions
=
SubmissionNoTextFieldsSerializer
(
many
=
True
)
submissions
=
SubmissionNoTextFieldsSerializer
(
many
=
True
)
is_active
=
serializers
.
BooleanField
(
source
=
'
user.is_active
'
)
is_active
=
serializers
.
BooleanField
(
source
=
'
user.is_active
'
)
...
@@ -35,6 +36,7 @@ class StudentInfoSerializerForListView(DynamicFieldsModelSerializer):
...
@@ -35,6 +36,7 @@ class StudentInfoSerializerForListView(DynamicFieldsModelSerializer):
fields
=
(
'
pk
'
,
fields
=
(
'
pk
'
,
'
name
'
,
'
name
'
,
'
user
'
,
'
user
'
,
'
user_pk
'
,
'
exam
'
,
'
exam
'
,
'
submissions
'
,
'
submissions
'
,
'
matrikel_no
'
,
'
matrikel_no
'
,
...
...
This diff is collapsed.
Click to expand it.
core/views/common_views.py
+
15
−
0
View file @
b7a129c8
...
@@ -211,3 +211,18 @@ class UserAccountViewSet(viewsets.ReadOnlyModelViewSet):
...
@@ -211,3 +211,18 @@ class UserAccountViewSet(viewsets.ReadOnlyModelViewSet):
def
me
(
self
,
request
):
def
me
(
self
,
request
):
serializer
=
self
.
get_serializer
(
request
.
user
)
serializer
=
self
.
get_serializer
(
request
.
user
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_200_OK
)
@detail_route
(
methods
=
[
'
patch
'
])
def
change_active
(
self
,
request
,
*
args
,
**
kwargs
):
active
=
request
.
data
.
get
(
'
is_active
'
)
req_user
=
request
.
user
user
=
self
.
get_object
()
if
active
is
None
:
error_msg
=
"
You need to provide an
'
active
'
field
"
return
Response
({
'
Error
'
:
error_msg
},
status
.
HTTP_400_BAD_REQUEST
)
if
(
req_user
.
is_student
()
or
req_user
.
is_tutor
())
and
req_user
!=
user
:
return
Response
(
status
.
HTTP_403_FORBIDDEN
)
user
.
is_active
=
active
user
.
save
()
return
Response
(
status
.
HTTP_200_OK
)
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