P-72
This commit is contained in:
1 parent
2ddc208bdc
commit
037e8bfc05
3 files changed
+21
-7
No files matched your search
@@ -39,16 +39,18 @@ class MyCalendars(APIView):
|
||||
try:
|
||||
ob=MyCalendarPostParameters(data=request.data)
|
||||
if ob.is_valid():
|
||||
ob = ob.data
|
||||
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' in ob:
|
||||
if participant != False:
|
||||
ptspnt = []
|
||||
for x in ob['participant']:
|
||||
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'],
|
||||
@@ -63,7 +65,18 @@ class MyCalendars(APIView):
|
||||
return Response({"mess":"Ошибка операции"})
|
||||
|
||||
return Response({"mess": f"Календарь успешно {'обновлен' if 'id' in ob else 'создан'}"})
|
||||
|
||||
|
||||
|
||||
|
||||
@swagger_auto_schema(query_serializer=DeleteCalendarSerializer)
|
||||
def delete(self,request):
|
||||
try:
|
||||
Calendar.objects.get(id=request.query_params.get("delid")).delete()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return Response({'mess':'Удаление не удалось'})
|
||||
return Response({"mess": "Календарь удален"})
|
||||
|
||||
|
||||
class GetEmployees(APIView):
|
||||
def get(self, request):
|
||||
|
||||
Reference in new issue
Block a user