mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-14 04:58:06 +00:00
refactor: use FragmentMixin for subscription fragments
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
<div x-data="existing_user_subscription_form" class="form-content existing-user">
|
||||
<fieldset>
|
||||
{{ errors }}
|
||||
{% for field, errors in fields %}
|
||||
<p{% with classes=field.css_classes %}{% if classes %} class="{{ classes }}"{% endif %}{% endwith %}>
|
||||
{{ field.label_tag }}
|
||||
{{ field }}
|
||||
{% if field.help_text %}
|
||||
<span class="helptext">{{ field.help_text }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if field.name == "payment_method" %}
|
||||
<i>
|
||||
{% blocktranslate %}If the subscription is done using the AE account, you must also click it on the AE counter.{% endblocktranslate %}
|
||||
</i>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<div
|
||||
id="subscription-form-user-mini-profile"
|
||||
x-html="profileFragment"
|
||||
:aria-busy="loading"
|
||||
></div>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
{{ form.as_p }}
|
||||
@@ -0,0 +1,38 @@
|
||||
<form
|
||||
hx-post="{{ url("subscription:fragment-existing-user") }}"
|
||||
hx-target="this"
|
||||
hx-disabled-elt="find input[type='submit']"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
{% csrf_token %}
|
||||
|
||||
<div x-data="existing_user_subscription_form" class="form-content existing-user">
|
||||
<fieldset>
|
||||
{{ form.errors }}
|
||||
{% for field in form %}
|
||||
<div class="form-group">
|
||||
{{ field.label_tag() }}
|
||||
{{ field }}
|
||||
{% if field.help_text %}
|
||||
<span class="helptext">{{ field.help_text }}</span>
|
||||
{% endif %}
|
||||
{% if field.name == "payment_method" %}
|
||||
<i>
|
||||
{% trans trimmed %}
|
||||
If the subscription is done using the AE account,
|
||||
you must also click it on the AE counter.
|
||||
{% endtrans %}
|
||||
</i>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<div
|
||||
id="subscription-form-user-mini-profile"
|
||||
x-html="profileFragment"
|
||||
:aria-busy="loading"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="{% trans %}Save{% endtrans %}">
|
||||
</form>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<form
|
||||
hx-post="{{ post_url }}"
|
||||
hx-post="{{ url("subscription:fragment-existing-user") }}"
|
||||
hx-target="this"
|
||||
hx-disabled-elt="find input[type='submit']"
|
||||
hx-swap="outerHTML"
|
||||
@@ -18,22 +18,14 @@
|
||||
<link rel="stylesheet" href="{{ static("subscription/css/subscription.scss") }}">
|
||||
{% endblock %}
|
||||
|
||||
{% macro form_fragment(form_object, post_url) %}
|
||||
{# Include the form fragment inside a with block,
|
||||
in order to inject the right form in the right place #}
|
||||
{% with form=form_object, post_url=post_url %}
|
||||
{% include "subscription/fragments/creation_form.jinja" %}
|
||||
{% endwith %}
|
||||
{% endmacro %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{% trans %}New subscription{% endtrans %}</h3>
|
||||
<ui-tab-group id="subscription-form">
|
||||
<ui-tab title="{% trans %}Existing member{% endtrans %}" active>
|
||||
{{ form_fragment(existing_user_form, existing_user_post_url) }}
|
||||
{{ existing_user_fragment }}
|
||||
</ui-tab>
|
||||
<ui-tab title="{% trans %}New member{% endtrans %}">
|
||||
{{ form_fragment(new_user_form, new_user_post_url) }}
|
||||
{{ new_user_fragment }}
|
||||
</ui-tab>
|
||||
</ui-tab-group>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user