Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
3c6f1493
Commit
3c6f1493
authored
Jan 02, 2021
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing the modifications of saving student video with proper serilization validation.
parent
903fb6f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
3 deletions
+51
-3
FirstApp/api.py
FirstApp/api.py
+7
-3
FirstApp/logic/head_gaze_estimation.py
FirstApp/logic/head_gaze_estimation.py
+1
-0
FirstApp/serializers.py
FirstApp/serializers.py
+43
-0
No files found.
FirstApp/api.py
View file @
3c6f1493
...
...
@@ -165,13 +165,17 @@ class LectureVideoViewSet(APIView):
#
# }, status=status.HTTP_201_CREATED)
# serializer = LectureVideoSerializer(data=request.data, many=True)
serializer
=
LectureVideoSerializer
(
data
=
request
.
data
)
serializer
.
create
(
validated_data
=
request
.
data
)
# serializer.create(validated_data=request.data)
if
serializer
.
is_valid
(
raise_exception
=
ValueError
):
print
(
'valid'
)
serializer
.
create
(
validated_data
=
request
.
data
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
# if serializer.is_valid(raise_exception=ValueError):
# serializer.create(validated_data=request.data)
# return Response(serializer.error_messages,
# status=status.HTTP_400_BAD_REQUEST)
...
...
FirstApp/logic/head_gaze_estimation.py
View file @
3c6f1493
...
...
@@ -1007,6 +1007,7 @@ def get_gaze_correlations(individual_lec_gaze, lec_recorded_activity_data):
# this variable will be used to store the correlations
correlations
=
[]
# limit = 10
limit
=
len
(
individual_lec_gaze
)
...
...
FirstApp/serializers.py
View file @
3c6f1493
...
...
@@ -194,6 +194,47 @@ class LectureVideoSerializer(serializers.ModelSerializer):
model
=
LectureVideo
fields
=
'__all__'
# this method will validate the input data
def
to_internal_value
(
self
,
data
):
lecturer
=
None
subject
=
None
lecturer_data
=
data
.
get
(
'lecturer'
)
subject_data
=
data
.
get
(
'subject'
)
# serialize the lecturer data
lecturer
=
Lecturer
.
objects
.
filter
(
id
=
lecturer_data
)
subject
=
Subject
.
objects
.
filter
(
id
=
subject_data
)
lecturer_ser_data
=
LecturerSerializer
(
lecturer
,
many
=
True
)
.
data
[
0
]
subject_ser_data
=
SubjectSerializer
(
subject
,
many
=
True
)
.
data
[
0
]
# retrieve the last lecture video details
last_lec_video
=
LectureVideo
.
objects
.
order_by
(
'lecture_video_id'
)
.
last
()
# create the next lecture video id
new_lecture_video_id
=
ig
.
generate_new_id
(
last_lec_video
.
lecture_video_id
)
# if both subject and lecturer details are available
if
len
(
lecturer
)
==
1
&
len
(
subject
)
==
1
:
str_video_length
=
data
.
get
(
'video_length'
)
video_length_parts
=
str_video_length
.
split
(
':'
)
video_length
=
datetime
.
timedelta
(
minutes
=
int
(
video_length_parts
[
0
]),
seconds
=
int
(
video_length_parts
[
1
]),
milliseconds
=
int
(
video_length_parts
[
2
]))
# this data will be passed as validated data
validated_data
=
{
'lecture_video_id'
:
new_lecture_video_id
,
'lecturer'
:
lecturer_ser_data
,
'subject'
:
subject_ser_data
,
'date'
:
data
.
get
(
'date'
),
'video_name'
:
data
.
get
(
'video_name'
),
'video_length'
:
video_length
}
return
super
(
LectureVideoSerializer
,
self
)
.
to_internal_value
(
validated_data
)
# this method will override the 'create' method
...
...
@@ -202,6 +243,8 @@ class LectureVideoSerializer(serializers.ModelSerializer):
lecturer
=
None
subject
=
None
lecturer_data
=
validated_data
.
pop
(
'lecturer'
)
subject_data
=
validated_data
.
pop
(
'subject'
)
...
...
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