diff --git a/accounts/templates/accounts/2fa-setup.html b/accounts/templates/accounts/2fa-setup.html index 071942fdb..a8a874ef5 100644 --- a/accounts/templates/accounts/2fa-setup.html +++ b/accounts/templates/accounts/2fa-setup.html @@ -29,7 +29,9 @@

QR Code

{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button "Test Code" button_type="submit" button_class=btn_primary_classes %} + {% form_buttons %} + {% bootstrap_button "Test Code" button_type="submit" button_class=btn_primary_classes %} + {% endform_buttons %}
diff --git a/accounts/templates/accounts/account-update.html b/accounts/templates/accounts/account-update.html index 80c0f9cb4..be554853d 100644 --- a/accounts/templates/accounts/account-update.html +++ b/accounts/templates/accounts/account-update.html @@ -1,5 +1,6 @@ {% extends "web/base.html" %} {% load django_bootstrap5 %} +{% load web_extras %} {% load i18n %} {% block title %} {% trans "Update account information" %} @@ -15,7 +16,9 @@

{% trans "Account Information" %}

{% csrf_token %} {% bootstrap_form update_account_form %} - {% bootstrap_button "Save" name="form-handle" value="update-account" %} + {% form_buttons %} + {% bootstrap_button "Save" name="form-handle" value="update-account" %} + {% endform_buttons %}
@@ -26,7 +29,9 @@

{% trans "Change Your Password" %}

{% csrf_token %} {% bootstrap_form change_password_form %} - {% bootstrap_button "Save" name="form-handle" value="change-password" %} + {% form_buttons %} + {% bootstrap_button "Save" name="form-handle" value="change-password" %} + {% endform_buttons %}
@@ -51,11 +56,13 @@

{% trans "Manage Two-Factor Authentication" %}

{% endif %} {% csrf_token %} {% bootstrap_form otp_check_form %} - {% if otp.activated %} - {% bootstrap_button "Submit" name="form-handle" value="deactivate-otp" %} - {% else %} - {% bootstrap_button "Submit" name="form-handle" value="activate-otp" %} - {% endif %} + {% form_buttons %} + {% if otp.activated %} + {% bootstrap_button "Submit" name="form-handle" value="deactivate-otp" %} + {% else %} + {% bootstrap_button "Submit" name="form-handle" value="activate-otp" %} + {% endif %} + {% endform_buttons %} {% else %} {# if we don't have OTP, link to 2FA setup directly. #} diff --git a/accounts/templates/accounts/researcher-registration.html b/accounts/templates/accounts/researcher-registration.html index a41ae9ad6..55c6e2dd8 100644 --- a/accounts/templates/accounts/researcher-registration.html +++ b/accounts/templates/accounts/researcher-registration.html @@ -1,6 +1,7 @@ {% extends "web/base.html" %} {% load django_bootstrap5 %} {% load bootstrap_icons %} +{% load web_extras %} {% block title %} Researcher Registration {% endblock title %} @@ -19,7 +20,9 @@ Privacy Statement .

- {% bootstrap_button bs_icon_plus|add:"Create Account" %} + {% form_buttons %} + {% bootstrap_button bs_icon_plus|add:"Create Account" %} + {% endform_buttons %} diff --git a/studies/templates/studies/lab_create.html b/studies/templates/studies/lab_create.html index 2b7aa34de..e0a537ba4 100644 --- a/studies/templates/studies/lab_create.html +++ b/studies/templates/studies/lab_create.html @@ -15,6 +15,8 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button "Submit" %} + {% form_buttons %} + {% bootstrap_button "Submit" %} + {% endform_buttons %}
{% endblock content %} diff --git a/studies/templates/studies/lab_member_list.html b/studies/templates/studies/lab_member_list.html index b65498ea8..628def0a5 100644 --- a/studies/templates/studies/lab_member_list.html +++ b/studies/templates/studies/lab_member_list.html @@ -77,7 +77,9 @@ Send password reset email - {% bootstrap_button "Submit" %} + {% form_buttons %} + {% bootstrap_button "Submit" %} + {% endform_buttons %} {% endif %} diff --git a/studies/templates/studies/lab_update.html b/studies/templates/studies/lab_update.html index f4520a5c6..e9f65f3a5 100644 --- a/studies/templates/studies/lab_update.html +++ b/studies/templates/studies/lab_update.html @@ -19,7 +19,9 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button "Discard Changes" href=url_lab_edit button_class=btn_secondary_classes %} - {% bootstrap_button "Save" type="submit" button_class=btn_primary_classes %} + {% form_buttons %} + {% bootstrap_button "Discard Changes" href=url_lab_edit button_class=btn_secondary_classes %} + {% bootstrap_button "Save" type="submit" button_class=btn_primary_classes %} + {% endform_buttons %}
{% endblock content %} diff --git a/studies/templates/studies/study_edit.html b/studies/templates/studies/study_edit.html index 58613eb00..4fc587dd0 100644 --- a/studies/templates/studies/study_edit.html +++ b/studies/templates/studies/study_edit.html @@ -26,6 +26,7 @@ {% url 'exp:preview-detail' uuid=study.uuid as url_preview_detail %} {% url 'exp:study-edit' pk=study.id as url_cancel %} {% button_secondary_classes as btn_secondary_classes %} + {% button_primary_classes as btn_primary_classes %}
@@ -42,7 +43,7 @@

{% csrf_token %} {% include "studies/_study_fields.html" with form=form study=study %} {% include "studies/_study_type.html" with types=types create=0 currentType=study.study_type.id %} -
+ {% form_buttons %} {% bootstrap_button "Cancel" button_class=btn_secondary_classes href=url_cancel %} -
+ {% endform_buttons %}

{% csrf_token %} {% include "studies/_study_fields.html" with form=form %} {% include "studies/_study_type.html" with types=types create=1 %} -
+ {% form_buttons %} {% bootstrap_button "Cancel" button_class=btn_secondary_classes href=url_cancel %} {% bootstrap_button bs_icon_plus|add:"Create Study" button_class=btn_primary_classes button_type="submit" id="create-study-button" %} -
+ {% endform_buttons %}
diff --git a/studies/templates/studies/study_participant_contact.html b/studies/templates/studies/study_participant_contact.html index d22dc9f49..613b48045 100644 --- a/studies/templates/studies/study_participant_contact.html +++ b/studies/templates/studies/study_participant_contact.html @@ -140,7 +140,9 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button "Submit" %} + {% form_buttons %} + {% bootstrap_button "Submit" %} + {% endform_buttons %}
diff --git a/web/templates/registration/login.html b/web/templates/registration/login.html index 0d76f3620..7050d44de 100644 --- a/web/templates/registration/login.html +++ b/web/templates/registration/login.html @@ -1,5 +1,6 @@ {% extends "web/base.html" %} {% load django_bootstrap5 %} +{% load web_extras %} {% load i18n %} {% block title %} {% trans "Login" %} @@ -12,7 +13,9 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button button_type="submit" content=login %} + {% form_buttons %} + {% bootstrap_button button_type="submit" content=login %} + {% endform_buttons %}
{# Assumes you setup the password_reset view in your URLconf #} diff --git a/web/templates/registration/password_reset_confirm.html b/web/templates/registration/password_reset_confirm.html index a11092923..c322d1d4c 100644 --- a/web/templates/registration/password_reset_confirm.html +++ b/web/templates/registration/password_reset_confirm.html @@ -12,7 +12,9 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_change_my_password %} + {% form_buttons %} + {% bootstrap_button trans_change_my_password %} + {% endform_buttons %}
{% else %}

diff --git a/web/templates/registration/password_reset_form.html b/web/templates/registration/password_reset_form.html index 8e49c1d6a..4997712ad 100644 --- a/web/templates/registration/password_reset_form.html +++ b/web/templates/registration/password_reset_form.html @@ -13,7 +13,9 @@

{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_reset_password %} + {% form_buttons %} + {% bootstrap_button trans_reset_password %} + {% endform_buttons %}
diff --git a/web/templates/web/child-add.html b/web/templates/web/child-add.html index 8731724fd..3120203df 100644 --- a/web/templates/web/child-add.html +++ b/web/templates/web/child-add.html @@ -27,8 +27,10 @@

{% trans "Add Child" %}

{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_cancel href=url_children_list button_class=btn_secondary_classes %} - {% bootstrap_button bs_icon_plus|add:trans_add_child button_class=btn_primary_classes %} + {% form_buttons %} + {% bootstrap_button trans_cancel href=url_children_list button_class=btn_secondary_classes %} + {% bootstrap_button bs_icon_plus|add:trans_add_child button_class=btn_primary_classes %} + {% endform_buttons %}
diff --git a/web/templates/web/child-update.html b/web/templates/web/child-update.html index bb65e0fe4..202690a49 100644 --- a/web/templates/web/child-update.html +++ b/web/templates/web/child-update.html @@ -29,11 +29,13 @@

{% trans "Update" %} {{ child.given_name }}

{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_delete button_class="btn-danger" name="deleteChild" %} - {% bootstrap_button trans_cancel href=url_children_list button_class=btn_secondary_classes %} - {% bootstrap_button trans_save button_class=btn_primary_classes %} -
- + {% form_buttons %} + {% bootstrap_button trans_delete button_class="btn-danger" name="deleteChild" %} + {% bootstrap_button trans_cancel href=url_children_list button_class=btn_secondary_classes %} + {% bootstrap_button trans_save button_class=btn_primary_classes %} + {% endform_buttons %} + + diff --git a/web/templates/web/demographic-data-update.html b/web/templates/web/demographic-data-update.html index 862dfc5a5..bd9f632f9 100644 --- a/web/templates/web/demographic-data-update.html +++ b/web/templates/web/demographic-data-update.html @@ -1,6 +1,7 @@ {% extends "web/base.html" %} {% load i18n %} {% load django_bootstrap5 %} +{% load web_extras %} {% load static %} {% block title %} {% trans "Update demographics" %} @@ -49,7 +50,9 @@
{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_save %} + {% form_buttons %} + {% bootstrap_button trans_save %} + {% endform_buttons %}
diff --git a/web/templates/web/participant-email-preferences.html b/web/templates/web/participant-email-preferences.html index 747e78337..5df88dcf7 100644 --- a/web/templates/web/participant-email-preferences.html +++ b/web/templates/web/participant-email-preferences.html @@ -20,8 +20,10 @@

{% trans "I would like to be contacted when:" %}

{% csrf_token %} {% bootstrap_form form %} - {% bootstrap_button trans_cancel href=url_email_prefs button_class=btn_secondary_classes %} - {% bootstrap_button trans_save name="password_update" button_class=btn_primary_classes %} + {% form_buttons %} + {% bootstrap_button trans_cancel href=url_email_prefs button_class=btn_secondary_classes %} + {% bootstrap_button trans_save name="password_update" button_class=btn_primary_classes %} + {% endform_buttons %}
diff --git a/web/templates/web/participant-signup.html b/web/templates/web/participant-signup.html index 210b8632d..d23f07a4c 100644 --- a/web/templates/web/participant-signup.html +++ b/web/templates/web/participant-signup.html @@ -1,6 +1,7 @@ {% extends "web/base.html" %} {% load django_bootstrap5 %} {% load bootstrap_icons %} +{% load web_extras %} {% load i18n %} {% block title %} {% trans "Sign up to participate" %} @@ -26,7 +27,9 @@

{% trans "By clicking 'Create Account', I agree that I have read and accepted the " %} {% trans "Privacy Statement" %}.

- {% bootstrap_button bs_icon_plus|add:trans_create_account %} + {% form_buttons %} + {% bootstrap_button bs_icon_plus|add:trans_create_account %} + {% endform_buttons %} diff --git a/web/templatetags/web_extras.py b/web/templatetags/web_extras.py index 7b27f3dd1..54875c252 100644 --- a/web/templatetags/web_extras.py +++ b/web/templatetags/web_extras.py @@ -283,3 +283,19 @@ def render(self, context): ) result.append("") return "".join(result) + + +@register.tag(name="form_buttons") +def form_buttons(parser, token): + nodelist = parser.parse(("endform_buttons",)) + parser.delete_first_token() + return FormButtonsNode(nodelist) + + +class FormButtonsNode(template.Node): + def __init__(self, nodelist): + self.nodelist = nodelist + + def render(self, context): + rendered_buttons = (n.render(context) for n in self.nodelist) + return f'
{"".join(rendered_buttons)}
'