Browse Source

Improve copy in "Profile" > "Email and Password" section

When an account has a password, replace "Set Password"
button's label with "Change Password"
pull/504/head
Pēteris Caune 4 years ago
parent
commit
6ed983cdd5
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 29 additions and 3 deletions
  1. +13
    -0
      hc/accounts/tests/test_profile.py
  2. +4
    -0
      static/css/profile.css
  3. +12
    -3
      templates/accounts/profile.html

+ 13
- 0
hc/accounts/tests/test_profile.py View File

@ -9,6 +9,7 @@ class ProfileTestCase(BaseTestCase):
r = self.client.get("/accounts/profile/")
self.assertContains(r, "Email and Password")
self.assertContains(r, "Change Password")
def test_leaving_works(self):
self.client.login(username="[email protected]", password="password")
@ -75,3 +76,15 @@ class ProfileTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password")
r = self.client.get("/accounts/profile/")
self.assertContains(r, "Alices Key")
def test_it_handles_unusable_password(self):
self.alice.set_unusable_password()
self.alice.save()
# Authenticate using the ProfileBackend and a token:
token = self.profile.prepare_token("login")
self.client.login(username="alice", token=token)
r = self.client.get("/accounts/profile/")
self.assertContains(r, "Set Password")
self.assertNotContains(r, "Change Password")

+ 4
- 0
static/css/profile.css View File

@ -65,3 +65,7 @@ span.loading {
#my-keys th {
border-top: 0;
}
.settings-bar {
line-height: 34px;
}

+ 12
- 3
templates/accounts/profile.html View File

@ -38,7 +38,7 @@
<form method="post">
{% csrf_token %}
<h2>Email and Password</h2>
<p>
<p class="settings-bar">
Your account's email address is
<code>{{ request.user.email }}</code>
@ -47,12 +47,21 @@
class="btn btn-default pull-right">Change Email</a>
</p>
<p class="clearfix"></p>
<p>
Attach a password to your {{ site_name }} account
{% if request.user.has_usable_password %}
<p class="settings-bar">
Password authentication is enabled.
<a
href="{% url 'hc-set-password' %}"
class="btn btn-default pull-right">Change Password</a>
</p>
{% else %}
<p class="settings-bar">
Attach a password to your {{ site_name }} account.
<a
href="{% url 'hc-set-password' %}"
class="btn btn-default pull-right">Set Password</a>
</p>
{% endif %}
</form>
</div>
{% if changed_password %}


Loading…
Cancel
Save