Create view returns to create another ; remove checkbox
This commit is contained in:
parent
3eb40cd5ed
commit
9263af0d40
4 changed files with 15 additions and 31 deletions
|
@ -22,25 +22,17 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
{% block buttons %}
|
|
||||||
{% if form.instance.adding %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<label for="addmore">{% translate "Add another" %}</label>
|
|
||||||
<input type="checkbox" name="addmore" id="addmore" checked />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr class="buttons">
|
<tr class="buttons">
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
|
{% block buttons %}
|
||||||
{% if not form.instance.adding %}
|
{% if not form.instance.adding %}
|
||||||
<a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a>
|
<a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="reset" value="{% translate "Reset" %}" />
|
<input type="reset" value="{% translate "Reset" %}" />
|
||||||
<input type="submit" value="{% translate "Save" %}" />
|
<input type="submit" value="{% translate "Save" %}" />
|
||||||
|
{% endblock %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endblock %}
|
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
{% extends "main/form/base.html" %}
|
{% extends "main/form/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block buttons %}
|
{% block buttons %}
|
||||||
<tr class="buttons">
|
|
||||||
<td colspan="2">
|
|
||||||
<input hidden value="{{ next }}" name="next" />
|
<input hidden value="{{ next }}" name="next" />
|
||||||
<input type="reset" />
|
<input type="reset" />
|
||||||
<input type="submit" value="{% translate "Log in" %}" />
|
<input type="submit" value="{% translate "Log in" %}" />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
{% extends "main/form/base.html" %}
|
{% extends "main/form/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block buttons %}
|
{% block buttons %}
|
||||||
<tr class="buttons">
|
|
||||||
<td colspan="2">
|
|
||||||
<input type="reset" />
|
<input type="reset" />
|
||||||
<input type="submit" value="{% translate "Search" %}" />
|
<input type="submit" value="{% translate "Search" %}" />
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -71,12 +71,12 @@ class UserFormMixin:
|
||||||
|
|
||||||
|
|
||||||
class NummiCreateView(UserMixin, UserFormMixin, CreateView):
|
class NummiCreateView(UserMixin, UserFormMixin, CreateView):
|
||||||
|
def get_success_url(self):
|
||||||
|
return self.object.get_create_url()
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.instance.user = self.request.user
|
form.instance.user = self.request.user
|
||||||
_res = super().form_valid(form)
|
return super().form_valid(form)
|
||||||
if form.data["addmore"]:
|
|
||||||
return HttpResponseRedirect(self.object.get_create_url())
|
|
||||||
return _res
|
|
||||||
|
|
||||||
|
|
||||||
class NummiUpdateView(UserMixin, UserFormMixin, UpdateView):
|
class NummiUpdateView(UserMixin, UserFormMixin, UpdateView):
|
||||||
|
|
Loading…
Reference in a new issue