Skip to content
Snippets Groups Projects
Unverified Commit 20be674b authored by Todd Dembrey's avatar Todd Dembrey Committed by GitHub
Browse files

Merge pull request #418 from OpenTechFund/feature/23-editable-user-profile

Feature/23 editable user profile
parents bff81dd0 50d771fa
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,10 @@ class ProfileForm(forms.ModelForm):
if not self.instance.is_apply_staff:
del self.fields['slack']
if not self.instance.has_usable_password():
# User is registered with oauth - no password change allowed
del self.fields['email']
def clean_slack(self):
slack = self.cleaned_data['slack']
if slack:
......
......@@ -13,7 +13,7 @@
</form>
<div class="wrapper wrapper--inner-space-large">
<a class="link link--button link--button-long-text" href="{% url "social:begin" "google-oauth2" %}?next={% url "users:account" %}">Log in with your OTF email</a>
<a class="link link--button link--button-long-text" href="{% url "social:begin" "google-oauth2" %}">Log in with your OTF email</a>
</div>
</div>
{% endblock %}
......@@ -41,7 +41,7 @@ class AdminFactory(UserFactory):
is_admin = True
class StaffFactory(UserFactory):
class StaffFactory(OAuthUserFactory):
class Meta:
exclude = ('slack_temp', )
is_staff = True
......
......@@ -48,6 +48,13 @@ class TestStaffProfileForm(BaseTestProfileForm):
def setUp(self):
self.staff = StaffFactory()
def test_cant_change_password(self):
new_email = 'me@this.com'
form = self.submit_form(self.staff, email=new_email)
self.assertFalse('email' in form.fields)
self.staff.refresh_from_db()
self.assertNotEqual(new_email, self.staff.email)
def test_can_set_slack_name(self):
slack_name = '@foobar'
self.submit_form(self.staff, slack=slack_name)
......
......@@ -43,3 +43,7 @@ class TestStaffProfileView(BaseTestProfielView):
def test_can_set_slack_name(self):
response = self.client.get(self.url, follow=True)
self.assertContains(response, 'Slack name')
def test_can_not_set_email(self):
response = self.client.get(self.url, follow=True)
self.assertNotContains(response, 'Email')
......@@ -317,7 +317,7 @@ SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = STAFF_EMAIL_DOMAINS
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
SOCIAL_AUTH_LOGIN_ERROR_URL = 'users:account'
SOCIAL_AUTH_LOGIN_ERROR_URL = 'users:login'
SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL = 'users:account'
# For pipelines, see http://python-social-auth.readthedocs.io/en/latest/pipeline.html?highlight=pipelines#authentication-pipeline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment