feat: use GET params for create
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
{% block toolbar_right %}
|
{% block toolbar_right %}
|
||||||
{% if views.create %}
|
{% if views.create %}
|
||||||
<a class="btn btn-primary" href="{% url views.create %}">
|
<a class="btn btn-primary" href="{% url views.create %}{% query_url %}">
|
||||||
<i class="fas fa-plus"></i> {{ model_verbose_name }} hinzufügen</a>
|
<i class="fas fa-plus"></i> {{ model_verbose_name }} hinzufügen</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<input name="amount" class="form-control text-end" type="number" min="0" step="0.5" value="{{ object.account.balance|invert|min:object.account.balance|default:10|floatformat:'2u' }}">
|
<input name="amount" class="form-control text-end" type="number" min="0" step="0.5" value="{{ object.account.balance|invert|min:object.account.balance|default:10|floatformat:'2u' }}">
|
||||||
<span class="input-group-text">€</span>
|
<span class="input-group-text">€</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="account" value="{{ object.account.pk }}">
|
<input type="hidden" name="user" value="{{ object.account.pk }}">
|
||||||
<div class="btn-group mt-2 w-100">
|
<div class="btn-group mt-2 w-100">
|
||||||
<button name="_type" class="btn btn-outline-success" value="deposit-plus">Einzahlen</button>
|
<button name="_type" class="btn btn-outline-success" value="deposit-plus">Einzahlen</button>
|
||||||
<button name="_type" class="btn btn-outline-danger" value="deposit-minus">Auszahlen</button>
|
<button name="_type" class="btn btn-outline-danger" value="deposit-minus">Auszahlen</button>
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ def query_url(context: dict, **kwargs: dict) -> str:
|
|||||||
del query[k]
|
del query[k]
|
||||||
else:
|
else:
|
||||||
query[k] = v
|
query[k] = v
|
||||||
return '?' + query.urlencode() # type: ignore
|
query_str = query.urlencode() # type: ignore
|
||||||
|
return ('?' + query_str) if query_str else ''
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class TransactionCreateView(TransactionOptions, ModelCreateView):
|
|||||||
else:
|
else:
|
||||||
desc = self.request.GET.get('description')
|
desc = self.request.GET.get('description')
|
||||||
|
|
||||||
initial['account'] = self.request.GET.get('account') or None
|
initial['account'] = self.request.GET.get('user') or None
|
||||||
initial['amount'] = amount
|
initial['amount'] = amount
|
||||||
initial['description'] = desc or None
|
initial['description'] = desc or None
|
||||||
return initial
|
return initial
|
||||||
|
|||||||
Reference in New Issue
Block a user