|
1 | 1 | from typing import Literal |
2 | 2 |
|
3 | | -from drf_spectacular.utils import OpenApiExample, extend_schema_field, extend_schema_serializer, inline_serializer |
| 3 | +from drf_spectacular.utils import extend_schema_field, inline_serializer |
4 | 4 | from rest_framework import serializers |
5 | 5 |
|
6 | 6 | from apps.homework.api.serializers import HomeworkStatsSerializer, QuestionSerializer |
7 | 7 | from apps.homework.models import Question |
8 | | -from apps.lms.models import Call, Course, Lesson, Module |
| 8 | +from apps.lms.models import Call, Lesson |
9 | 9 | from apps.notion.models import Material as NotionMaterial |
10 | | -from core.serializers import MarkdownField |
11 | 10 |
|
12 | 11 |
|
13 | 12 | class NotionMaterialSerializer(serializers.ModelSerializer): |
@@ -109,75 +108,3 @@ def get_homework(self, lesson: Lesson) -> dict | None: |
109 | 108 | question = Question.objects.for_user(user).get(pk=lesson.question_id) # extra N+1 query to annotate the question with statistics |
110 | 109 |
|
111 | 110 | return HomeworkStatsSerializer(question, context=self.context).data |
112 | | - |
113 | | - |
114 | | -@extend_schema_serializer( |
115 | | - examples=[ |
116 | | - OpenApiExample( |
117 | | - name="Markdown in descrpition", |
118 | | - value={ |
119 | | - "id": 100500, |
120 | | - "name": "Первая неделя", |
121 | | - "start_date": "2023-12-01 15:30:00+03:00", |
122 | | - "description": "Cамая важная неделя", |
123 | | - "text": "<p><strong>Первая</strong> неделя — <em>самая важная неделя</em></p>", |
124 | | - }, |
125 | | - ), |
126 | | - ] |
127 | | -) |
128 | | -class ModuleSerializer(serializers.ModelSerializer): |
129 | | - text = MarkdownField() |
130 | | - |
131 | | - class Meta: |
132 | | - model = Module |
133 | | - fields = [ |
134 | | - "id", |
135 | | - "name", |
136 | | - "start_date", |
137 | | - "description", |
138 | | - "text", |
139 | | - ] |
140 | | - |
141 | | - |
142 | | -class LMSCourseSerializer(serializers.ModelSerializer): |
143 | | - homework_check_recommendations = MarkdownField() |
144 | | - |
145 | | - class Meta: |
146 | | - model = Course |
147 | | - fields = [ |
148 | | - "id", |
149 | | - "slug", |
150 | | - "name", |
151 | | - "cover", |
152 | | - "chat", |
153 | | - "calendar_ios", |
154 | | - "calendar_google", |
155 | | - "homework_check_recommendations", |
156 | | - ] |
157 | | - |
158 | | - |
159 | | -class BreadcrumbsSerializer(serializers.ModelSerializer): |
160 | | - module = ModuleSerializer() |
161 | | - course = LMSCourseSerializer(source="module.course") |
162 | | - lesson = serializers.SerializerMethodField() |
163 | | - |
164 | | - class Meta: |
165 | | - model = Lesson |
166 | | - fields = [ |
167 | | - "module", |
168 | | - "course", |
169 | | - "lesson", |
170 | | - ] |
171 | | - |
172 | | - @extend_schema_field( |
173 | | - field=inline_serializer( |
174 | | - name="LessonPlainSerializer", |
175 | | - fields={ |
176 | | - "id": serializers.IntegerField(), |
177 | | - }, |
178 | | - ) |
179 | | - ) |
180 | | - def get_lesson(self, lesson: Lesson) -> dict: |
181 | | - return { |
182 | | - "id": lesson.id, |
183 | | - } |
0 commit comments