示例#1
0
 def create(self, request, *args, **kwargs):
     printer_id=request.data.get('printer')
     act=ActPrinter(status=1)
     unit = get_object_or_404(WorkUnit,id=printer_id)
     act.comment="Возвращение принтера после ремонта в "+unit.cabinet.city.name+". "+request.data.get('comment')
     serializer=ActPrinterSerializer(act,data={"printer":printer_id})
     printer_serializer=WorkUnitSerializer(unit,data={"status":1,"status_note":"В работе"},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#2
0
 def create(self, request, *args, **kwargs):
     printer_id=request.data.get('printer')
     unit = get_object_or_404(WorkUnit,id=printer_id)
     comment=request.data.get('comment',unit.status_note)
     act=ActPrinter(status=7)
     act.comment=comment
     serializer=ActPrinterSerializer(act,data=request.data)
     printer_serializer=WorkUnitSerializer(unit,data={"status":6,"comment":comment},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#3
0
 def create(self, request, *args, **kwargs):
     printer_id=request.data.get('printer')
     act=ActPrinter(status=6)
     unit = get_object_or_404(WorkUnit,id=printer_id)
     act.comment="Устранено своими силами - "+request.data.get('comment',unit.status_note)
     serializer=ActPrinterSerializer(act,data=request.data)
     printer_serializer=WorkUnitSerializer(unit,data={"status":5,"status_note":"Принтер починен и ожидает в ИТ-отделе."},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         sender=email_sender()
         sender.send_mail_on_adress('Изменение статуса принтера','Принтер ' + unit.printer.name + 'id:' + str(unit.id) + 'готов и ожидает в ОГУПе' ,unit.cabinet.city.email_city)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#4
0
 def create(self, request, *args, **kwargs):
     printer_id=request.data.get('printer')
     unit = get_object_or_404(WorkUnit,id=printer_id)
     comment=request.data.get('comment',unit.status_note)
     act=ActPrinter(status=3)
     act.comment=comment
     serializer=ActPrinterSerializer(act,data=request.data)
     printer_serializer=WorkUnitSerializer(unit,data={"status":3,"status_note":comment},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         sender=email_sender()
         sender.send_mail_on_adress('Изменение статуса принтера','Принтер ' + unit.printer.name + 'id:' + str(unit.id) + 'принят в диагностику' ,unit.cabinet.city.email_city)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#5
0
 def create(self, request, *args, **kwargs):
     printer_id=request.data.get('printer')
     comment=request.data.get('comment',"В работе")
     cabinet_id=request.data.get('cabinet')
     act=ActPrinter(status=1)
     unit = get_object_or_404(WorkUnit,id=printer_id)
     cabinet=get_object_or_404(Cabinet,id=cabinet_id)
     prevcab=unit.cabinet.city.name+" - "+unit.cabinet.name+" "
     unit.cabinet=cabinet
     act.comment="Перемещение принтера из "+ prevcab +"в - "+unit.cabinet.city.name+" - "+unit.cabinet.name+". "+comment
     serializer=ActPrinterSerializer(act,data={"printer":printer_id})
     printer_serializer=WorkUnitSerializer(unit,data={"status":1,"status_note":comment},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#6
0
 def create(self, request, *args, **kwargs):
     comment=request.data.get('comment')
     printer_id=request.data.get('printer')
     act=ActPrinter(status=4)
     act.comment=comment
     serializer=ActPrinterSerializer(act,data=request.data)
     unit = get_object_or_404(WorkUnit,id=printer_id)
     printer_serializer=WorkUnitSerializer(unit,data={"status":4,"status_note":comment},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         text='Добрый день!\n\nВышел из строя принтер '+unit.printer.name+'.\n\nПричина: '+comment
         sender=email_sender()
         sender.send_email(text)
         sender.send_mail_on_adress('Изменение статуса принтера','Принтер ' + unit.printer.name + 'id:' + str(unit.id) + 'отправлен в ремонт' ,unit.cabinet.city.email_city)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#7
0
 def create(self, request, *args, **kwargs):
     city=request.user.city.name
     comment=request.data.get('comment')
     printer_id=request.data.get('printer')
     act=ActPrinter(status=2)
     serializer=ActPrinterSerializer(act,data=request.data)
     unit = get_object_or_404(WorkUnit,id=printer_id)
     printer_serializer=WorkUnitSerializer(unit,data={"status":2,"status_note":comment},partial=True)
     if serializer.is_valid() and printer_serializer.is_valid():
         serializer.save()
         printer_serializer.save()
         text='*Поломка принтера* id:'+request.data['printer']+'\n\n'+unit.printer.name+'\n\n_Причина_: '+comment+ '\n\n_Район:_ '+city
         telegram.send(text)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)