diff --git a/warehouse/templates/accounts/login.html b/warehouse/templates/accounts/login.html index 79599f9019e0..f4725fc2f28d 100644 --- a/warehouse/templates/accounts/login.html +++ b/warehouse/templates/accounts/login.html @@ -27,29 +27,17 @@

{% trans title=title %}Log in to {{ title }}{% endtrans % {% for error in form.form_errors %}
  • {{ error }}
  • {% endfor %} {% endif %} -
    - - {{ form.username(placeholder=gettext("Your username") , - autocapitalize="off", - autocomplete="username", - spellcheck="false", - required="required", - class_="form-group__field", - aria_describedby="username-errors", - tabindex="1", - ) }} -
    - {% if form.username.errors %} - - {% endif %} -
    +{{ render_form_field( + form.username, + label=gettext("Username"), + placeholder=gettext("Your username"), + class_="form-group__field", + autocapitalize="off", + autocomplete="username", + spellcheck="false", + required="required", + tabindex="1" +) }}
    diff --git a/warehouse/templates/accounts/register.html b/warehouse/templates/accounts/register.html index a0f3bd248f6b..530d1a95af42 100644 --- a/warehouse/templates/accounts/register.html +++ b/warehouse/templates/accounts/register.html @@ -62,79 +62,40 @@

    {% trans title=title %}Create an account on {{ title }}{% {% for error in form.form_errors %}
  • {{ error }}
  • {% endfor %} {% endif %} -
    - - {{ form.full_name(placeholder=gettext("Your name") , - autocomplete="name", - autocapitalize="off", - spellcheck="false", - class_="form-group__field", - aria_describedby="name-errors", - ) }} -
    - {% if form.full_name.errors %} - - {% endif %} -
    -
    -
    - - {{ form.email(placeholder=gettext("Your email address") , - autocomplete="email", - spellcheck="false", - required="required", - class_="form-group__field", - aria_describedby="email-errors", - ) }} -
    - {% if form.email.errors %} - - {% endif %} -
    -
    +{{ render_form_field( + form.full_name, + label=gettext("Name"), + placeholder=gettext("Your name"), + class_="form-group__field", + autocomplete="name", + autocapitalize="off", + spellcheck="false" +) }} +{{ render_form_field( + form.email, + label=gettext("Email address"), + placeholder=gettext("Your email address"), + class_="form-group__field", + autocomplete="email", + spellcheck="false", + required="required" +) }} {# The following is a honeypot field and is hidden from the user #}
    {{ form.confirm_form(class="form-group__field", aria_hidden='true',) }}
    -
    - - {{ form.username(placeholder=gettext("Select a username") , - autocapitalize="off", - autocomplete="username", - spellcheck="false", - required="required", - class_="form-group__field", - aria_describedby="username-errors", - ) }} -
    - {% if form.username.errors %} - - {% endif %} -
    -
    +{{ render_form_field( + form.username, + label=gettext("Username"), + placeholder=gettext("Select a username"), + class_="form-group__field", + autocapitalize="off", + autocomplete="username", + spellcheck="false", + required="required" +) }}
    diff --git a/warehouse/templates/base.html b/warehouse/templates/base.html index 7bb221ccfa31..fb1f7537b34c 100644 --- a/warehouse/templates/base.html +++ b/warehouse/templates/base.html @@ -1,4 +1,6 @@ {# SPDX-License-Identifier: Apache-2.0 -#} +{% from "macros/forms.html" import render_form_field with context %} + {% macro humanize(timestamp, relative="true", time="false") -%}

    {% include "warehouse:templates/includes/sponsors-footer.html" %} {% endblock body %} - + \ No newline at end of file diff --git a/warehouse/templates/macros/forms.html b/warehouse/templates/macros/forms.html new file mode 100644 index 000000000000..cd80d30134c7 --- /dev/null +++ b/warehouse/templates/macros/forms.html @@ -0,0 +1,18 @@ +{% macro render_form_field(field, label=None, placeholder=None, class_="form-group__input", show_required=True) %} +
    + + {{ field(placeholder=placeholder or label or field.label.text, class_=class_, **{"aria-describedby": field.id + "-errors"}) }} + {% if field.errors %} + + {% endif %} +
    +{% endmacro %} \ No newline at end of file diff --git a/warehouse/templates/manage/organizations.html b/warehouse/templates/manage/organizations.html index 101504f77143..cb0ce3cf70ae 100644 --- a/warehouse/templates/manage/organizations.html +++ b/warehouse/templates/manage/organizations.html @@ -201,34 +201,21 @@

    {% trans %}Request a new organization{% endtrans %}

    type="hidden" value="{{ request.session.get_csrf_token() }}"> {{ form_errors(create_organization_application_form) }} -
    - - {{ create_organization_application_form.name(placeholder=gettext("Select an organization account name") , - autocapitalize="off", - autocomplete="off", - spellcheck="false", - required="required", - class_="form-group__field", - aria_describedby="name-errors" - ) }} -
    - {% if create_organization_application_form.name.errors %} - - {% endif %} -
    -

    - {% trans %}This account name is used in URLs on PyPI.{% endtrans %} -
    - {% trans %}For example{% endtrans %}: psf -

    -
    + {{ render_form_field( + create_organization_application_form.name, + label=gettext("Organization Account Name"), + placeholder=gettext("Select an organization account name"), + class_="form-group__field", + autocapitalize="off", + autocomplete="off", + spellcheck="false", + required="required" +) }} +

    + {% trans %}This account name is used in URLs on PyPI.{% endtrans %} +
    + {% trans %}For example{% endtrans %}: psf +

    -
    - - {{ create_organization_application_form.description(placeholder=gettext("Description of your business, product, or project") , - autocomplete="off", - autocapitalize="off", - spellcheck="true", - class_="form-group__field", - aria_describedby="description-errors", - ) }} -
    - {% if create_organization_application_form.description.errors %} - - {% endif %} -
    -
    + {{ render_form_field( + create_organization_application_form.description, + label=gettext("Organization Description"), + placeholder=gettext("Description of your business, product, or project"), + class_="form-group__field", + autocomplete="off", + autocapitalize="off", + spellcheck="true" +) }}