Exemplo n.º 1
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['authorization_form'] = \
            forms.ServiceWorkOrderAuthorizationForm(initial={
                'order': self.object.pk
            })

        return context
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['budget'] = False
        if self.object.expected_duration:
            context['budget'] = plot_time_budget(self.object)
        context['authorization_form'] = \
            forms.ServiceWorkOrderAuthorizationForm(initial={
                'order': self.object.pk
            })

        return context
Exemplo n.º 3
0
def work_order_authorize(request, pk=None):
    worder = get_object_or_404(models.ServiceWorkOrder, pk=pk)
    form = forms.ServiceWorkOrderAuthorizationForm(request.POST)
    if form.is_valid():
        worder.status = form.cleaned_data['status']
        worder.authorized_by = form.cleaned_data['authorized_by']
        worder.save()
    else: 
        pk = request.path.split("/")[-1]
        messages.info(request, "The authorization password is incorrect")
        return HttpResponseRedirect("/services/work-order-detail/{}".format(pk))
    return HttpResponseRedirect(reverse_lazy('services:work-order-list'))