-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix buttons problems in 'Change Email' section. #5219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,68 +9,104 @@ | |
{% block edit_content_header %} {% trans "Change Email" %} {% endblock %} | ||
|
||
{% block edit_content %} | ||
{% if user.emailaddress_set.all %} | ||
<p>{% trans 'The following email addresses are associated with your account:' %}</p> | ||
|
||
<form action="{% url 'account_email' %}" class="email_list" method="post"> | ||
{% csrf_token %} | ||
<fieldset class="blockLabels"> | ||
|
||
{% for emailaddress in user.emailaddress_set.all %} | ||
<div class="ctrlHolder"> | ||
<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 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/> | ||
|
||
{{ emailaddress.email }} | ||
{% if emailaddress.verified %} | ||
<span class="verified">{% trans "Verified" %}</span> | ||
{% else %} | ||
<span class="unverified">{% trans "Unverified" %}</span> | ||
{% endif %} | ||
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %} | ||
</label> | ||
</div> | ||
{% endfor %} | ||
|
||
<div class="buttonHolder"> | ||
<button class="secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button> | ||
<button class="secondaryAction" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button> | ||
<button class="primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button> | ||
</div> | ||
{% if user.emailaddress_set.all %} | ||
<p>{% trans 'The following email addresses are associated with your account:' %}</p> | ||
|
||
<form action="{% url 'account_email' %}" class="email_list" method="post"> | ||
{% csrf_token %} | ||
<fieldset class="blockLabels"> | ||
|
||
{% for emailaddress in user.emailaddress_set.all %} | ||
<div class="ctrlHolder"> | ||
<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 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good practice to use spaces around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. |
||
|
||
{{ emailaddress.email }} | ||
{% if emailaddress.verified %} | ||
<span class="verified">{% trans "Verified" %}</span> | ||
{% else %} | ||
<span class="unverified">{% trans "Unverified" %}</span> | ||
{% endif %} | ||
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %} | ||
</label> | ||
</div> | ||
{% endfor %} | ||
|
||
<div class="buttonHolder"> | ||
<button class="secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button> | ||
<button class="secondaryAction" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button> | ||
<button class="primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button> | ||
</div> | ||
|
||
</fieldset> | ||
</form> | ||
|
||
</fieldset> | ||
</form> | ||
{% else %} | ||
|
||
{% else %} | ||
<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." %}</p> | ||
<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." %}</p> | ||
|
||
{% endif %} | ||
{% endif %} | ||
|
||
<h2>{% trans "Add E-mail Address" %}</h2> | ||
|
||
<h2>{% trans "Add E-mail Address" %}</h2> | ||
|
||
<form method="post" action="{% url 'account_email' %}" class="add_email"> | ||
{% csrf_token %} | ||
{{ form.as_p}} | ||
<button name="action_add" type="submit">{% trans "Add E-mail" %}</button> | ||
</form> | ||
<form method="post" action="{% url 'account_email' %}" class="add_email"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button name="action_add" type="submit">{% trans "Add E-mail" %}</button> | ||
</form> | ||
|
||
{% endblock %} | ||
|
||
{% block footerjs %} | ||
|
||
(function() { | ||
var message = "{% trans 'Do you really want to remove the selected email address?' %}"; | ||
var actions = document.getElementsByName('action_remove'); | ||
if (actions.length) { | ||
actions[0].addEventListener("click", function(e) { | ||
if (! confirm(message)) { | ||
e.preventDefault(); | ||
} | ||
}); | ||
} | ||
})(); | ||
|
||
(function() { | ||
var primaryButton = document.querySelector("button[name=action_primary]"); | ||
var sendVerificationButton = document.querySelector("button[name=action_send"); | ||
|
||
{% if user.emailaddress_set.all %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. |
||
{% for emailaddress in user.emailaddress_set.all %} | ||
var email_{{ forloop.counter }} = document.querySelector("input[value='{{ emailaddress.email }}']") | ||
if (email_{{ forloop.counter }}.checked == true) { | ||
{% if emailaddress.primary %} | ||
primaryButton.style.display = 'None'; | ||
{% else %} | ||
primaryButton.style.display = 'block'; | ||
{% endif %} | ||
{% if emailaddress.verified %} | ||
sendVerificationButton.style.display = 'None'; | ||
{% else %} | ||
sendVerificationButton.style.display = 'block'; | ||
primaryButton.style.display = 'None'; | ||
{% endif %} | ||
} | ||
|
||
email_{{ forloop.counter }}.addEventListener('change', function() { | ||
{% if emailaddress.primary %} | ||
primaryButton.style.display = 'None'; | ||
{% else %} | ||
primaryButton.style.display = 'block'; | ||
{% endif %} | ||
{% if emailaddress.verified %} | ||
sendVerificationButton.style.display = 'None'; | ||
{% else %} | ||
sendVerificationButton.style.display = 'block'; | ||
primaryButton.style.display = 'None'; | ||
{% endif %} | ||
}) | ||
{% endfor %} | ||
{% endif %} | ||
})(); | ||
|
||
{% block extra_body %} | ||
<script type="text/javascript"> | ||
(function() { | ||
var message = "{% trans 'Do you really want to remove the selected email address?' %}"; | ||
var actions = document.getElementsByName('action_remove'); | ||
if (actions.length) { | ||
actions[0].addEventListener("click", function(e) { | ||
if (! confirm(message)) { | ||
e.preventDefault(); | ||
} | ||
}); | ||
} | ||
})(); | ||
</script> | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we have been using
"
for these blocks.