def form_valid(self, form): self.object = form.save() HistoricoTicket.objects.create_historico( ticket=self.object, conteudo="%s repassou o ticket para %s." % (unicode(self.request.user), unicode(self.object.analista)) ) return JsonResponse({})
def post(self, request, *args, **kwargs): user = request.user.pk self.object = self.model.objects.filter(funcionario=user, ticket=kwargs.get('ticket'), data_termino__isnull=True)[0] self.object, history = self.model.objects.pause(self.object) return JsonResponse({'historico': history.render()})
def form_valid(self, form): self.object = self.get_object() self.object.situacao = 3 self.object.save() user_tempo_ticket = self.request.user.tempoticket_set.filter(data_termino__isnull=True) if user_tempo_ticket.exists(): user_tempo_ticket = user_tempo_ticket.get() TempoTicket.objects.pause(user_tempo_ticket) HistoricoTicket.objects.create_historico( criado_por=self.request.user, ticket=self.object, conteudo=form.cleaned_data.get("historico"), tipo=2 ) HistoricoTicket.objects.create_historico( ticket=self.object, conteudo=u"Ticket liberado pelo usuário %s." % unicode(self.request.user) ) self.messages.success(self.get_message("success")) return JsonResponse({ "redirect_to": self.get_success_url() })
def form_valid(self, form): if self.request.user.cargo == 1: form.instance.analista = self.request.user self.object = form.save() self.messages.success(self.get_message('success')) return JsonResponse({'redirect_to': self.get_success_url()})
def form_valid(self, form): ticket = Ticket.objects.get(pk=self.kwargs.get('ticket')) self.object = self.model.objects.create_historico( ticket=ticket, conteudo=form.cleaned_data.get('conteudo'), criado_por=self.request.user, tipo=2 ) return JsonResponse({'historico': self.object.render()})
def form_valid(self, form): self.object = form.save() history = HistoricoTicket.objects.create_historico( ticket=self.object, conteudo="%s alterou o tipo do ticket para %s." % (unicode(self.request.user), self.object.get_tipo_display()) ) return JsonResponse({ 'tipo': self.object.tipo, 'tipo_display': self.object.get_tipo_display(), 'historico': history.render() })
def post(self, request, *args, **kwargs): ticket = Ticket.objects.get(pk=kwargs.get('ticket')) user = request.user if ticket.tempoticket_set.filter(funcionario=user.pk, data_termino__isnull=True).exists(): raise PermissionDenied() user_tempo_ticket = user.tempoticket_set.filter(data_termino__isnull=True) if user_tempo_ticket.exists(): user_tempo_ticket = user_tempo_ticket.get() TempoTicket.objects.pause(user_tempo_ticket) self.object, history = self.model.objects.start(ticket, user) return JsonResponse({'historico': history.render()})
def form_valid(self, form): self.object = form.save() user_tempo_ticket = self.request.user.tempoticket_set.filter(data_termino__isnull=True) if user_tempo_ticket.exists(): user_tempo_ticket = user_tempo_ticket.get() TempoTicket.objects.pause(user_tempo_ticket) HistoricoTicket.objects.create_historico( ticket=self.object, conteudo="%s repassou o ticket para %s." % (unicode(self.request.user), unicode(self.object.desenvolvedor)) ) self.messages.success(self.get_message("success")) return JsonResponse({'redirect_to': self.get_success_url()})
def post(self, request, *args, **kwargs): ''' Metodo que retorna uma lista de clientes :param request: :param args: :param kwargs: :return: JsonResponse ''' queryset = self.get_queryset() return JsonResponse([{ "label": cliente.nome_fantasia, "value": cliente.nome_fantasia, "id": cliente.id, "products": [{"id": produto.id, "label": unicode(produto)} for produto in cliente.produtos.all()] } for cliente in queryset])
def form_valid(self, form): self.object = form.save(commit=False) self.object.data_fechamento = timezone.now() self.object.situacao = 2 self.object.save() user_tempo_ticket = self.request.user.tempoticket_set.filter(data_termino__isnull=True) if user_tempo_ticket.exists(): user_tempo_ticket = user_tempo_ticket.get() TempoTicket.objects.pause(user_tempo_ticket) HistoricoTicket.objects.create_historico( ticket=self.object, conteudo=u"Ticket encerrado pelo usuário %s." % unicode(self.request.user) ) return JsonResponse({ "redirect_to": self.get_success_url() })
def form_invalid(self, form): error = form.errors['desenvolvedor'][0] return JsonResponse(error, status=400)