Split SubscriptionForm into SubscriptionNewUserForm and SubscriptionExistingUserForm

This commit is contained in:
imperosol
2024-11-19 00:41:49 +01:00
parent 75406f7b58
commit d2d639e5f6
14 changed files with 280 additions and 187 deletions

View File

@@ -0,0 +1,10 @@
<form
hx-post="{{ post_url }}"
hx-target="this"
hx-disabled-elt="find input[type='submit']"
hx-swap="outerHTML"
>
{% csrf_token %}
{{ form.as_p() }}
<input type="submit" value="{% trans %}Save{% endtrans %}">
</form>

View File

@@ -0,0 +1,27 @@
<div class="alert alert-green">
<div class="alert-main">
<h3 class="alert-title">
{% trans user=subscription.member %}Subscription created for {{ user }}{% endtrans %}
</h3>
<p>
{% trans trimmed user=subscription.member.get_short_name(), type=subscription.subscription_type, end=subscription.subscription_end %}
{{ user }} received its new {{ type }} subscription.
It will be active until {{ end }} included.
{% endtrans %}
</p>
</div>
<div class="alert-aside">
<a class="btn btn-blue" href="{{ subscription.member.get_absolute_url() }}">
{% trans %}Go to user profile{% endtrans %}
</a>
<a class="btn btn-grey" href="{{ url("subscription:subscription") }}">
{# We don't know if this fragment is displayed after creating a subscription
for a previously existing user or for a newly created one.
Thus, we don't know which form should be used to create another subscription
in this place.
Therefore, we reload the entire page. It just works. #}
{% trans %}Create another subscription{% endtrans %}
</a>
</div>
</div>