-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add profile/user update page. (#335)
- Loading branch information
1 parent
9ad8d29
commit 8144884
Showing
6 changed files
with
193 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ def setUpTestData(cls): | |
profile = ProfileFactory.create(user__username="test") | ||
cls.user = profile.user | ||
cls.profile_url = reverse("profile") | ||
cls.update_profile_url = reverse("update_user") | ||
|
||
def test_redirect_when_unauthenticated(self): | ||
response = self.client.get(self.profile_url, follow=True) | ||
|
@@ -26,3 +27,35 @@ def test_profile(self): | |
self.assertContains(response, "Profile Info") | ||
self.assertContains(response, "test") | ||
self.assertContains(response, "Jane Doe") | ||
|
||
def test_update_profile_initial_data(self): | ||
self.client.force_login(self.user) | ||
response = self.client.get(self.update_profile_url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, "Update Profile Info") | ||
self.assertContains(response, "test") | ||
self.assertContains(response, "Jane") | ||
self.assertContains(response, "Doe") | ||
self.assertContains(response, "You have not confirmed your email address.") | ||
|
||
def test_update_profile(self): | ||
self.client.force_login(self.user) | ||
response = self.client.post( | ||
self.update_profile_url, | ||
data={ | ||
"username": "janedoe", | ||
"email": "[email protected]", | ||
"first_name": "Jane", | ||
"last_name": "Doe", | ||
"receive_newsletter": True, | ||
"receive_program_updates": True, | ||
"receive_event_updates": True, | ||
}, | ||
follow=True, | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, "Profile Info") | ||
self.user.profile.refresh_from_db() | ||
self.assertEqual(self.user.profile.receiving_newsletter, True) | ||
self.assertEqual(self.user.profile.receiving_event_updates, True) | ||
self.assertEqual(self.user.profile.receiving_program_updates, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends "base.html" %} | ||
{% load i18n wagtailcore_tags static %} | ||
|
||
{% block title %}{% translate "Update Profile | Djangonaut Space" %}{% endblock %} | ||
{% block meta_title %}{% translate "Update Profile | Djangonaut Space" %}{% endblock %} | ||
|
||
|
||
{% block extra_css %} | ||
<link rel="stylesheet" href="{% static 'css/registration.css' %}"> | ||
{% endblock extra_css %} | ||
|
||
{% block content %} | ||
<main class="section my-3 mx-5"> | ||
<div class="section-container"> | ||
<h1 class="text-5xl mb-6">{% translate "Update Profile Info" %}</h1> | ||
|
||
<div class="row "> | ||
<div class="col"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
|
||
{{ form }} | ||
<button type="submit" class="mt-4">{% translate "Save" %}</button> | ||
<a class="px-4 text-ds-purple hover:underline cursor-pointer" href="{% url "profile" %}"> {% trans "Cancel" %}</a> | ||
</form> | ||
</div> | ||
<div class="col"></div> | ||
</div> | ||
</div> | ||
</main> | ||
{% endblock content %} |