diff --git a/protocoloadm/urls.py b/protocoloadm/urls.py index b09890eb1..498e7d5f6 100644 --- a/protocoloadm/urls.py +++ b/protocoloadm/urls.py @@ -27,7 +27,7 @@ urlpatterns = [ # url(r'^protocoloadm/anular-protocolo/', # include(anular_protocolo_crud.urls), name='anular_protocolo'), - url(r'^protocoladm/anular-protocolo', + url(r'^protocoloadm/anular-protocolo', AnularProtocoloAdmView.as_view(), name='anular_protocolo'), ] diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 1f7f49615..0fb345a20 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -3,6 +3,7 @@ from datetime import datetime from django import forms from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse +from django.shortcuts import render from django.utils.html import strip_tags from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import TemplateView @@ -233,6 +234,8 @@ class AnularProtocoloAdmView(FormMixin, TemplateView): form = AnularProcoloAdmForm(request.POST) + template_name = reverse("anular_protocolo") + if form.is_valid(): numero = request.POST['numero_protocolo'] @@ -259,7 +262,9 @@ class AnularProtocoloAdmView(FormMixin, TemplateView): protocolo.ip_anulacao = ip_addr protocolo.save() - return self.form_valid(form) + message = "Protocolo criado com sucesso" + + return render(request, self.template_name, {'form': form, 'message': message}) except ObjectDoesNotExist: errors = form._errors.setdefault( diff --git a/templates/protocoloadm/anular_protocoloadm.html b/templates/protocoloadm/anular_protocoloadm.html index 231e2debc..499974aa7 100644 --- a/templates/protocoloadm/anular_protocoloadm.html +++ b/templates/protocoloadm/anular_protocoloadm.html @@ -1,7 +1,7 @@ {% extends "protocoloadm/protocoloadm_detail.html" %} {% load i18n %} {% block detail_content %} -
{{ view.message }}
+
{{ message }}
{% csrf_token %}