P-42 Не забыть исправить проверку валидации
This commit is contained in:
1 parent
8d8ad9390e
commit
90994e83de
12 files changed
+231
-321
No files matched your search
@@ -39,30 +39,34 @@ class MyCalendars(APIView):
|
||||
|
||||
|
||||
'''
|
||||
print(request.data, '---------------')
|
||||
|
||||
try:
|
||||
|
||||
ob=MyCalendarPostParameters(data=request.data)
|
||||
ob=MyCalendarPostParameters(data=request.data)
|
||||
|
||||
if ob.is_valid():
|
||||
ob = ob.data
|
||||
participant = ob['participant'] if 'participant' in ob else False
|
||||
|
||||
del ob['participant']
|
||||
if 'id' in ob:
|
||||
newcal,created = Calendar.objects.update_or_create(id=ob['id'],defaults=ob)
|
||||
|
||||
else:
|
||||
newcal=Calendar.objects.create(**ob, author=DictEmployee(id=request.user.user.id))
|
||||
|
||||
|
||||
if participant != False:
|
||||
ptspnt = []
|
||||
|
||||
for x in participant:
|
||||
x['participant_calendar']=DictEmployee(id=x['participant_calendar'])
|
||||
print(x['participant_calendar'])
|
||||
CalendarParticipants.objects.update_or_create(calendar=newcal, participant_calendar=x['participant_calendar'],
|
||||
|
||||
newpart, created = CalendarParticipants.objects.update_or_create(calendar=newcal, participant_calendar=x['participant_calendar'],
|
||||
defaults=x)
|
||||
|
||||
ptspnt.append(x['participant_calendar'])
|
||||
print(ptspnt)
|
||||
CalendarParticipants.objects.exclude(calendar=newcal,participant_calendar__in=ptspnt).delete()
|
||||
CalendarParticipants.objects.exclude(participant_calendar__in=ptspnt).filter(calendar=newcal).delete()
|
||||
else:
|
||||
return Response({"mess":"Ошибка валидации полей"})
|
||||
except Exception as e:
|
||||
|
||||
@@ -138,7 +138,7 @@ class DailyloadAPIView(APIView):
|
||||
}]
|
||||
|
||||
daily = result
|
||||
print(daily,'dailydaily')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user