#158: Added success notification for ItemCreate/ItemUpdate View.
This commit is contained in:
parent
710882c28a
commit
822264ef7b
@ -5,7 +5,11 @@
|
|||||||
{% block title %}{{ block.super }} - {%trans "Item" %}{% endblock %}
|
{% block title %}{{ block.super }} - {%trans "Item" %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if item %}
|
||||||
<h1>{%trans "Edit item" %}</h1>
|
<h1>{%trans "Edit item" %}</h1>
|
||||||
|
{% else %}
|
||||||
|
<h1>{%trans "New item" %}</h1>
|
||||||
|
{% endif %}
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<p>
|
<p>
|
||||||
|
@ -105,6 +105,13 @@ class ItemUpdate(UpdateView):
|
|||||||
context_object_name = 'item'
|
context_object_name = 'item'
|
||||||
form_class = ItemForm
|
form_class = ItemForm
|
||||||
success_url = 'item_overview'
|
success_url = 'item_overview'
|
||||||
|
apply_url = 'item_edit'
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
messages.success(self.request, _("Item <b>%s</b> was successfully modified.") % self.request.POST['title'])
|
||||||
|
if 'apply' in self.request.POST:
|
||||||
|
return ''
|
||||||
|
return reverse(super(UpdateView, self).get_success_url())
|
||||||
|
|
||||||
|
|
||||||
class ItemCreate(CreateView):
|
class ItemCreate(CreateView):
|
||||||
@ -114,6 +121,13 @@ class ItemCreate(CreateView):
|
|||||||
context_object_name = 'item'
|
context_object_name = 'item'
|
||||||
form_class = ItemForm
|
form_class = ItemForm
|
||||||
success_url = 'item_overview'
|
success_url = 'item_overview'
|
||||||
|
apply_url = 'item_edit'
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
messages.success(self.request, _("Item <b>%s</b> was successfully created.") % self.request.POST['title'])
|
||||||
|
if 'apply' in self.request.POST:
|
||||||
|
return reverse(self.get_apply_url(), args=[self.object.id])
|
||||||
|
return reverse(super(CreateView, self).get_success_url())
|
||||||
|
|
||||||
|
|
||||||
class ItemDelete(DeleteView):
|
class ItemDelete(DeleteView):
|
||||||
|
Loading…
Reference in New Issue
Block a user