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 %}
|
<tr class="buttons">
|
||||||
{% if form.instance.adding %}
|
<td colspan="2">
|
||||||
<tr>
|
{% block buttons %}
|
||||||
<td colspan="2">
|
|
||||||
<label for="addmore">{% translate "Add another" %}</label>
|
|
||||||
<input type="checkbox" name="addmore" id="addmore" checked />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr class="buttons">
|
|
||||||
<td colspan="2">
|
|
||||||
{% 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" %}" />
|
||||||
</td>
|
{% endblock %}
|
||||||
</tr>
|
</td>
|
||||||
{% endblock %}
|
</tr>
|
||||||
</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">
|
<input hidden value="{{ next }}" name="next" />
|
||||||
<td colspan="2">
|
<input type="reset" />
|
||||||
<input hidden value="{{ next }}" name="next" />
|
<input type="submit" value="{% translate "Log in" %}" />
|
||||||
<input type="reset" />
|
|
||||||
<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">
|
<input type="reset" />
|
||||||
<td colspan="2">
|
<input type="submit" value="{% translate "Search" %}" />
|
||||||
<input type="reset" />
|
|
||||||
<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