refactor user settings

This commit is contained in:
Matthias 2021-10-31 13:42:41 +01:00
parent dd74cf19a7
commit 06822303bc
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -47,51 +47,53 @@
<p>{% trans 'The following email addresses are associated with your account:' %}</p> <p>{% trans 'The following email addresses are associated with your account:' %}</p>
<form action="{% url 'account_email' %}" class="email_list" method="post"> <form action="{% url 'account_email' %}" class="email_list" method="post">
{% csrf_token %} {% csrf_token %}
<fieldset class="blockLabels"> <fieldset class="blockLabels">
{% for emailaddress in user.emailaddress_set.all %} {% for emailaddress in user.emailaddress_set.all %}
<div class="ctrlHolder"> <div class="ctrlHolder">
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}"> <label for="email_radio_{{forloop.counter}}"
class="{% if emailaddress.primary %}primary_email{%endif%}">
<input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/> <input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked" {%endif %} value="{{emailaddress.email}}" />
{{ emailaddress.email }} {{ emailaddress.email }}
{% if emailaddress.verified %} {% if emailaddress.verified %}
<span class="verified">{% trans "Verified" %}</span> <span class="verified">{% trans "Verified" %}</span>
{% else %} {% else %}
<span class="unverified">{% trans "Unverified" %}</span> <span class="unverified">{% trans "Unverified" %}</span>
{% endif %} {% endif %}
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %} {% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
</label> </label>
</div> </div>
{% endfor %} {% endfor %}
<div class="buttonHolder"> <div class="buttonHolder">
<button class="btn btn-primary secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button> <button class="btn btn-primary secondaryAction" type="submit" name="action_primary">{% trans 'Make Primary' %}</button>
<button class="btn btn-primary secondaryAction" type="submit" name="action_send" {% if not mail_conf %}disabled{% endif %}>{% trans 'Re-send Verification' %}</button> <button class="btn btn-primary secondaryAction" type="submit" name="action_send" {% if not mail_conf %}disabled{% endif %}>{% trans 'Re-send Verification' %}</button>
<button class="btn btn-primary primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button> <button class="btn btn-primary primaryAction" type="submit" name="action_remove">{% trans 'Remove' %}</button>
</div> </div>
</fieldset> </fieldset>
</form> </form>
{% else %} {% else %}
<p><strong>{% trans 'Warning:'%}</strong> <p><strong>{% trans 'Warning:'%}</strong>
{% trans "You currently do not have any email address set up. You should really add an email address so you can receive notifications, reset your password, etc." %} {% trans "You currently do not have any email address set up. You should really add an email address so you can
receive notifications, reset your password, etc." %}
</p> </p>
{% endif %} {% endif %}
{% if can_add_email %} {% if can_add_email %}
<br> <br>
<h4>{% trans "Add Email Address" %}</h4> <h5>{% trans "Add Email Address" %}</h5>
<form method="post" action="{% url 'account_email' %}" class="add_email"> <form method="post" action="{% url 'account_email' %}" class="add_email">
{% csrf_token %} {% csrf_token %}
{{ add_email_form|crispy }} {{ add_email_form|crispy }}
<button class="btn btn-primary" name="action_add" type="submit">{% trans "Add Email" %}</button> <button class="btn btn-primary" name="action_add" type="submit">{% trans "Add Email" %}</button>
</form> </form>
{% endif %} {% endif %}
<br> <br>
</div> </div>
@ -103,37 +105,39 @@
<div> <div>
{% if social_form.accounts %} {% if social_form.accounts %}
<p>{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}</p> <p>{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}</p>
<form method="post" action="{% url 'socialaccount_connections' %}">
{% csrf_token %}
<fieldset>
{% if social_form.non_field_errors %}
<div id="errorMsg">{{ social_form.non_field_errors }}</div>
{% endif %}
{% for base_account in social_form.accounts %}
{% with base_account.get_provider_account as account %}
<div>
<label for="id_account_{{ base_account.id }}">
<input id="id_account_{{ base_account.id }}" type="radio" name="account" value="{{ base_account.id }}"/>
<span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">
<span class='brand-icon' brand_name='{{account.get_brand.id}}'></span>{{account.get_brand.name}}</span>
{{ account }}
</label>
</div>
{% endwith %}
{% endfor %}
<div>
<button class="btn btn-primary" type="submit">{% trans 'Remove' %}</button> <form method="post" action="{% url 'socialaccount_connections' %}">
</div> {% csrf_token %}
</fieldset> <fieldset>
{% if social_form.non_field_errors %}
<div id="errorMsg">{{ social_form.non_field_errors }}</div>
{% endif %}
{% for base_account in social_form.accounts %}
{% with base_account.get_provider_account as account %}
<div>
<label for="id_account_{{ base_account.id }}">
<input id="id_account_{{ base_account.id }}" type="radio" name="account"
value="{{ base_account.id }}" />
<span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">
<span class='brand-icon'
brand_name='{{account.get_brand.id}}'></span>{{account.get_brand.name}}</span>
{{ account }}
</label>
</div>
{% endwith %}
{% endfor %}
<div>
<button class="btn btn-primary" type="submit">{% trans 'Remove' %}</button>
</div>
</fieldset>
</form> </form>
{% else %} {% else %}
<p>{% trans 'You currently have no social network accounts connected to this account.' %}</p> <p>{% trans 'You currently have no social network accounts connected to this account.' %}</p>
{% endif %} {% endif %}
@ -141,7 +145,7 @@
<br> <br>
<h4>{% trans 'Add a 3rd Party Account' %}</h4> <h4>{% trans 'Add a 3rd Party Account' %}</h4>
<div> <div>
{% include "socialaccount/snippets/provider_list.html" with process="connect" %} {% include "socialaccount/snippets/provider_list.html" with process="connect" %}
</div> </div>
{% include "socialaccount/snippets/login_extra.html" %} {% include "socialaccount/snippets/login_extra.html" %}
<br> <br>
@ -186,25 +190,29 @@
<form action="{% url 'set_language' %}" method="post"> <form action="{% url 'set_language' %}" method="post">
{% csrf_token %} {% csrf_token %}
<input name="next" type="hidden" value="{% url 'settings' %}"> <input name="next" type="hidden" value="{% url 'settings' %}">
<div class="col-sm-6" style="width: 200px;"><div id="div_id_language" class="form-group"><div class="controls "> <div class="col-sm-6" style="width: 200px;">
<select name="language" class="select form-control"> <div id="div_id_language" class="form-group">
{% get_current_language as LANGUAGE_CODE %} <div class="controls ">
{% get_available_languages as LANGUAGES %} <select name="language" class="select form-control">
{% get_language_info_list for LANGUAGES as languages %} {% get_current_language as LANGUAGE_CODE %}
{% for language in languages %} {% get_available_languages as LANGUAGES %}
{% define language.code as lang_code %} {% get_language_info_list for LANGUAGES as languages %}
{% define locale_stats|keyvalue:lang_code as lang_translated %} {% for language in languages %}
<option value="{{ lang_code }}"{% if lang_code == LANGUAGE_CODE %} selected{% endif %}> {% define language.code as lang_code %}
{{ language.name_local }} ({{ lang_code }}) {% define locale_stats|keyvalue:lang_code as lang_translated %}
{% if lang_translated %} <option value="{{ lang_code }}" {% if lang_code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ lang_code }})
{% if lang_translated %}
{% blocktrans %}{{ lang_translated }}% translated{% endblocktrans %} {% blocktrans %}{{ lang_translated }}% translated{% endblocktrans %}
{% else %} {% else %}
{% trans 'No translations available' %} {% trans 'No translations available' %}
{% endif %} {% endif %}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
</div></div></div> </div>
</div>
</div>
<div class="col-sm-6" style="width: auto;"> <div class="col-sm-6" style="width: auto;">
<input type="submit" value="{% trans 'Set Language' %}" class="btn btn btn-primary"> <input type="submit" value="{% trans 'Set Language' %}" class="btn btn btn-primary">
</div> </div>
@ -212,7 +220,9 @@
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<h4>{% trans "Help the translation efforts!" %}</h4> <h4>{% trans "Help the translation efforts!" %}</h4>
<p>{% blocktrans with link="https://crowdin.com/project/inventree" %}Native language translation of the InvenTree web application is <a href="{{link}}">community contributed via crowdin</a>. Contributions are welcomed and encouraged.{% endblocktrans %}</p> <p>{% blocktrans with link="https://crowdin.com/project/inventree" %}Native language translation of the
InvenTree web application is <a href="{{link}}">community contributed via crowdin</a>. Contributions are
welcomed and encouraged.{% endblocktrans %}</p>
</div> </div>
</div> </div>
@ -220,14 +230,14 @@
{% block js_ready %} {% block js_ready %}
(function() { (function() {
var message = "{% trans 'Do you really want to remove the selected email address?' %}"; var message = "{% trans 'Do you really want to remove the selected email address?' %}";
var actions = document.getElementsByName('action_remove'); var actions = document.getElementsByName('action_remove');
if (actions.length) { if (actions.length) {
actions[0].addEventListener("click", function(e) { actions[0].addEventListener("click", function(e) {
if (! confirm(message)) { if (! confirm(message)) {
e.preventDefault(); e.preventDefault();
} }
}); });
} }
})(); })();
{% endblock %} {% endblock %}