P_55 Настройки
This commit is contained in:
1 parent
133696de50
commit
ec35771276
11 files changed
+259
-184
No files matched your search
@@ -3,7 +3,12 @@ from .models import *
|
||||
from about_inspection.models import *
|
||||
from userauth.serializers import *
|
||||
|
||||
|
||||
class CalendarParticipantsSerializer(serializers.ModelSerializer):
|
||||
""" Сериализатор участников календаря """
|
||||
|
||||
class Meta:
|
||||
model = CalendarParticipants
|
||||
exclude = ['calendar']
|
||||
|
||||
class CalendarEventSerializer(serializers.ModelSerializer):
|
||||
""" Сериализатор событий календаря """
|
||||
@@ -14,23 +19,20 @@ class CalendarEventSerializer(serializers.ModelSerializer):
|
||||
|
||||
class CalendarsSerializer(serializers.ModelSerializer):
|
||||
""" Сериализатор календарей """
|
||||
editor = serializers.SerializerMethodField("is_editor")
|
||||
# editor = serializers.SerializerMethodField("is_editor")
|
||||
events = CalendarEventSerializer(source="get_calendar_event", many=True, allow_null=True)
|
||||
participant = CalendarParticipantsSerializer(source="get_participants", many= True, read_only=True)
|
||||
|
||||
def is_editor(self, obj):
|
||||
r = self.context.get("request")
|
||||
return obj.get_user.filter(patrcipant_calendar=r.user.user.id).last().editor
|
||||
|
||||
# def is_editor(self, obj):
|
||||
# r = self.context.get("request")
|
||||
# return obj.get_user.filter(participant_calendar=r.user.user.id).last().editor
|
||||
|
||||
class Meta:
|
||||
model = Calendar
|
||||
fields = '__all__'
|
||||
|
||||
class CalendarPatricipantsSerializer(serializers.ModelSerializer):
|
||||
""" Сериализатор участников календаря """
|
||||
|
||||
class Meta:
|
||||
model = CalendarPatricipants
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user