|
|
|
|
@ -24,16 +24,22 @@ User = get_user_model() |
|
|
|
|
class MaterialViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = Material.objects.all() |
|
|
|
|
serializer_class = MaterialSerializer |
|
|
|
|
search_fields = ('title', 'short_description',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LikeViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = Like.objects.select_related('user').all() |
|
|
|
|
serializer_class = LikeSerializer |
|
|
|
|
search_fields = ('user__email', 'user__firstname', 'user__lastname',) |
|
|
|
|
ordering_fields = ('created_at', 'update_at',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CategoryViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = Category.objects.all() |
|
|
|
|
serializer_class = CategorySerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CourseViewSet(ExtendedModelViewSet): |
|
|
|
|
@ -43,7 +49,9 @@ class CourseViewSet(ExtendedModelViewSet): |
|
|
|
|
'likes', 'materials' |
|
|
|
|
).all() |
|
|
|
|
serializer_class = CourseSerializer |
|
|
|
|
filter_fields = ('category',) |
|
|
|
|
filter_fields = ('category', 'status', 'is_infinite', 'is_featured',) |
|
|
|
|
search_fields = ('author__email', 'title', 'category__title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageViewSet(ExtendedModelViewSet): |
|
|
|
|
@ -51,6 +59,8 @@ class ImageViewSet(ExtendedModelViewSet): |
|
|
|
|
'course', 'lesson' |
|
|
|
|
).all() |
|
|
|
|
serializer_class = ImageSerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at', 'position',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TextViewSet(ExtendedModelViewSet): |
|
|
|
|
@ -58,6 +68,8 @@ class TextViewSet(ExtendedModelViewSet): |
|
|
|
|
'course', 'lesson' |
|
|
|
|
).all() |
|
|
|
|
serializer_class = TextSerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at', 'position',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageTextViewSet(ExtendedModelViewSet): |
|
|
|
|
@ -65,6 +77,8 @@ class ImageTextViewSet(ExtendedModelViewSet): |
|
|
|
|
'course', 'lesson' |
|
|
|
|
).all() |
|
|
|
|
serializer_class = ImageTextSerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at', 'position',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VideoViewSet(ExtendedModelViewSet): |
|
|
|
|
@ -72,18 +86,26 @@ class VideoViewSet(ExtendedModelViewSet): |
|
|
|
|
'course', 'lesson' |
|
|
|
|
).all() |
|
|
|
|
serializer_class = VideoSerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at', 'position',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GalleryViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = Gallery.objects.select_related('course').all() |
|
|
|
|
serializer_class = GallerySerializer |
|
|
|
|
search_fields = ('title',) |
|
|
|
|
ordering_fields = ('title', 'created_at', 'update_at',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GalleryImageViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = GalleryImage.objects.select_related('gallery').all() |
|
|
|
|
serializer_class = GalleryImageSerializer |
|
|
|
|
search_fields = ('gallery__title',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserViewSet(ExtendedModelViewSet): |
|
|
|
|
queryset = User.objects.all() |
|
|
|
|
serializer_class = UserSerializer |
|
|
|
|
filter_fields = ('is_staff', 'is_active', 'role', 'gender', 'is_email_proved', 'fb_id',) |
|
|
|
|
search_fields = ('email', 'first_name', 'last_name', 'country', 'city', 'fb_id',) |
|
|
|
|
ordering_fields = ('email', 'first_name', 'last_name', 'country', 'city', 'date_joined',) |