p-10 help
This commit is contained in:
1 parent
ea16cacc8a
commit
0998ec54b1
2 files changed
+47
-8
No files matched your search
@@ -69,6 +69,44 @@ class CalendarEventsNameSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Сериализаторы по заданию p-50
|
# Сериализаторы по заданию p-50
|
||||||
|
# Сериализатор подключенный к GetCalendarsAPIView
|
||||||
|
class UserCalendarsSerializer(serializers.ModelSerializer):
|
||||||
|
patricpants = serializers.SerializerMethodField('get_patricipants')
|
||||||
|
cld_events = serializers.SerializerMethodField('get_cld_events')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DictEmployee
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
# Участники календаря
|
||||||
|
def get_patricipants(self, obj):
|
||||||
|
return PatricipantsCldSerializer(obj.get_patricipants.all(), many=True).data
|
||||||
|
|
||||||
|
# События календаря
|
||||||
|
def get_cld_events(self, obj):
|
||||||
|
return CldForEventSerializer(obj.get_cld_events.all(), many=True).data
|
||||||
|
|
||||||
|
# Сериализатор для участников календаря
|
||||||
|
class PatricipantsCldSerializer(serializers.ModelSerializer):
|
||||||
|
patr_cld = serializers.SerializerMethodField('get_patr_cld')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model: CalendarPatricipants
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_patr_cld(self, obj):
|
||||||
|
return CalendarSerializer(obj.calendar).data
|
||||||
|
|
||||||
|
# Сериализатор для событий календаря
|
||||||
|
class CldForEventSerializer(serializers.ModelSerializer):
|
||||||
|
cld_events = serializers.SerializerMethodField('get_cld_event')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = TableEventParticipant
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_cld_event(self, obj):
|
||||||
|
return TableEventParticipantSerializer(obj.get_cld_event.all(), many=True).data
|
||||||
|
|
||||||
class CalendarSerializer(serializers.ModelSerializer):
|
class CalendarSerializer(serializers.ModelSerializer):
|
||||||
""" Сериализатор календаря """
|
""" Сериализатор календаря """
|
||||||
|
|||||||
@@ -70,12 +70,13 @@ class ExclusionDatesAPIView(APIView):
|
|||||||
|
|
||||||
print(formonth, 'formonthformonthformonth')
|
print(formonth, 'formonthformonthformonth')
|
||||||
|
|
||||||
return Response('ru')
|
|
||||||
|
|
||||||
|
|
||||||
class GetCalendars(ListAPIView):
|
|
||||||
def get(self, request):
|
|
||||||
queryset = Calendar.objects.filter(user=request.user)
|
|
||||||
return Response(CalendarSerializer(queryset, many=True).data)
|
|
||||||
|
|
||||||
return Response(formonth)
|
return Response(formonth)
|
||||||
|
|
||||||
|
|
||||||
|
class GetCalendars(APIView):
|
||||||
|
def get(self, request):
|
||||||
|
calendar_patricipants = CalendarPatricipants.objects.filter(patrcipant_calendar = self.request.user.id)
|
||||||
|
cld_event = TableEventParticipant.objects.filter(participant_event = self.request.user.id)
|
||||||
|
return Response(UserCalendarsSerializer(calendar_patricipants,cld_event,many=True).data)
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user