-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODIFIED] added video count, course section obj on video
- Loading branch information
1 parent
52e9f28
commit a76225f
Showing
25 changed files
with
97 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from rest_framework import serializers | ||
|
||
from objects.serializers.video import VideoSerializer | ||
from userauth.models import UserProfile | ||
from objects.models import Section | ||
from userauth.serializers import UserProfileSerializers | ||
from userauth.constants import getAdminUser | ||
|
||
class SectionSerializer(serializers.ModelSerializer): | ||
videos = VideoSerializer(many=True, read_only=True, allow_null=True) | ||
created_by_profile = serializers.SerializerMethodField('handle_admin', read_only=True) | ||
|
||
def handle_admin(self, obj): | ||
user = UserProfile.objects.filter(user=obj.created_by) | ||
if user.count() == 1: | ||
return UserProfileSerializers(user[0]).data | ||
return getAdminUser(obj.created_by.id) | ||
|
||
class Meta: | ||
model = Section | ||
fields = '__all__' | ||
|
||
def create(self, validated_data): | ||
return Section.objects.create(**validated_data) |
Oops, something went wrong.