Create view returns to create another ; remove checkbox

This commit is contained in:
Edgar P. Burkhart 2023-04-20 11:11:06 +02:00
parent 3eb40cd5ed
commit 9263af0d40
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 15 additions and 31 deletions

View file

@ -22,25 +22,17 @@
{% endfor %}
</tbody>
<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">
<td colspan="2">
{% block buttons %}
{% if not form.instance.adding %}
<a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a>
{% endif %}
<input type="reset" value="{% translate "Reset" %}" />
<input type="submit" value="{% translate "Save" %}" />
{% endblock %}
</td>
</tr>
{% endblock %}
</tfoot>
</table>
{% endblock %}

View file

@ -1,11 +1,7 @@
{% extends "main/form/base.html" %}
{% load i18n %}
{% block buttons %}
<tr class="buttons">
<td colspan="2">
<input hidden value="{{ next }}" name="next" />
<input type="reset" />
<input type="submit" value="{% translate "Log in" %}" />
</td>
</tr>
{% endblock %}

View file

@ -1,10 +1,6 @@
{% extends "main/form/base.html" %}
{% load i18n %}
{% block buttons %}
<tr class="buttons">
<td colspan="2">
<input type="reset" />
<input type="submit" value="{% translate "Search" %}" />
</td>
</tr>
{% endblock %}

View file

@ -71,12 +71,12 @@ class UserFormMixin:
class NummiCreateView(UserMixin, UserFormMixin, CreateView):
def get_success_url(self):
return self.object.get_create_url()
def form_valid(self, form):
form.instance.user = self.request.user
_res = super().form_valid(form)
if form.data["addmore"]:
return HttpResponseRedirect(self.object.get_create_url())
return _res
return super().form_valid(form)
class NummiUpdateView(UserMixin, UserFormMixin, UpdateView):