aboutsummaryrefslogtreecommitdiff
path: root/okupy
diff options
context:
space:
mode:
Diffstat (limited to 'okupy')
-rw-r--r--okupy/accounts/forms.py17
-rw-r--r--okupy/accounts/urls.py15
-rw-r--r--okupy/accounts/views.py127
-rw-r--r--okupy/templates/settings-contact.html14
-rw-r--r--okupy/templates/settings-email.html2
-rw-r--r--okupy/templates/settings-gentoo.html10
-rw-r--r--okupy/templates/settings-profile.html8
-rw-r--r--okupy/tests/integration/test_settings.py10
8 files changed, 111 insertions, 92 deletions
diff --git a/okupy/accounts/forms.py b/okupy/accounts/forms.py
index 01a342a..47b66a2 100644
--- a/okupy/accounts/forms.py
+++ b/okupy/accounts/forms.py
@@ -69,7 +69,7 @@ class ProfileSettingsForm(forms.Form):
last_name = forms.CharField(
max_length=100, label='Last Name', required=False)
birthday = forms.DateField(
- input_formats='%m/%d/%Y', label='Birthday (format: month/day/year)', required=False)
+ input_formats='%m/%d/%Y', label='Birthday', required=False)
timezone = forms.ChoiceField(
choices=[(x, x) for x in pytz.common_timezones])
@@ -79,7 +79,10 @@ class PasswordSettingsForm(forms.Form):
), label='Old Password', required=False)
new_password = forms.CharField(max_length=30, widget=forms.PasswordInput(
), label='New Password', required=False)
- new_password_verify = forms.CharField(max_length=30, widget=forms.PasswordInput(), label='Repeat New Password', required=False)
+ new_password_verify = forms.CharField(max_length=30,
+ widget=forms.PasswordInput(),
+ label='Repeat New Password',
+ required=False)
def clean(self):
cleaned_data = super(PasswordSettingsForm, self).clean()
@@ -90,14 +93,18 @@ class PasswordSettingsForm(forms.Form):
raise forms.ValidationError(
'Please enter your current password to change the password.')
elif new_password != new_password_verify:
- raise forms.ValidationError('Passsword verification failed. Please re-enter the new password.')
+ raise forms.ValidationError(
+ "Paswords don't match. Please enter passwords again.")
elif (old_password and new_password) and (not new_password_verify):
- raise forms.ValidationError('Password verification failed. Please repeat your new password.')
+ raise forms.ValidationError(
+ 'Password verification failed. Please repeat your passwords.')
return cleaned_data
class EmailSettingsForm(forms.Form):
- email = forms.EmailField(max_length=254, label='Add Email', help_text='A valid email address, please.', required=False)
+ email = forms.EmailField(max_length=254, label='Add Email',
+ help_text='A valid email address, please.',
+ required=False)
class ContactSettingsForm(forms.Form):
diff --git a/okupy/accounts/urls.py b/okupy/accounts/urls.py
index 9212089..a43f13e 100644
--- a/okupy/accounts/urls.py
+++ b/okupy/accounts/urls.py
@@ -9,13 +9,18 @@ accounts_urlpatterns = patterns(
url(r'^login/$', v.login),
url(r'^ssl-auth/$', v.ssl_auth),
url(r'^logout/$', v.logout, name="logout"),
- url(r'^devlist/$', v.lists, {'acc_list': 'devlist'}, name="active_developers"),
- url(r'^former-devlist/$', v.lists, {'acc_list': 'former-devlist'}, name="former_developers"),
- url(r'^foundation-members/$', v.lists, {'acc_list': 'foundation-members'}, name="foundation_members"),
+ url(r'^devlist/$', v.lists, {'acc_list': 'devlist'},
+ name="active_developers"),
+ url(r'^former-devlist/$', v.lists, {'acc_list': 'former-devlist'},
+ name="former_developers"),
+ url(r'^foundation-members/$', v.lists, {'acc_list': 'foundation-members'},
+ name="foundation_members"),
url(r'^contact-settings/$', v.contact_settings, name="contact-settings"),
- url(r'^gentoo-dev-settings/$', v.gentoo_dev_settings, name="gentoo-dev-settings"),
+ url(r'^gentoo-dev-settings/$', v.gentoo_dev_settings,
+ name="gentoo-dev-settings"),
url(r'^profile-settings/$', v.profile_settings, name="profile-settings"),
- url(r'^password-settings/$', v.password_settings, name="password-settings"),
+ url(r'^password-settings/$', v.password_settings,
+ name="password-settings"),
url(r'^email-settings/$', v.email_settings, name="email-settings"),
url(r'^signup/$', v.signup),
url(r'^activate/(?P<token>[a-zA-Z0-9-_]+)/$', v.activate),
diff --git a/okupy/accounts/views.py b/okupy/accounts/views.py
index 2db9981..96b2614 100644
--- a/okupy/accounts/views.py
+++ b/okupy/accounts/views.py
@@ -30,7 +30,8 @@ from okupy.accounts.forms import (LoginForm, OpenIDLoginForm, SSLCertLoginForm,
OTPForm, SignupForm, SiteAuthForm,
StrongAuthForm, ProfileSettingsForm,
ContactSettingsForm, EmailSettingsForm,
- GentooAccountSettingsForm, PasswordSettingsForm)
+ GentooAccountSettingsForm,
+ PasswordSettingsForm)
from okupy.accounts.models import LDAPUser, OpenID_Attributes, Queue
from okupy.accounts.openid_store import DjangoDBOpenIDStore
from okupy.common.ldap_helpers import (get_bound_ldapuser,
@@ -375,7 +376,7 @@ def activate(request, token):
@otp_required
def profile_settings(request):
""" Primary account settings, """
- user_profile_info = get_bound_ldapuser(request)
+ user_info = get_bound_ldapuser(request)
profile_settings = None
if request.method == "POST":
profile_settings = ProfileSettingsForm(request.POST)
@@ -385,21 +386,21 @@ def profile_settings(request):
first_name = profile_settings.cleaned_data['first_name']
last_name = profile_settings.cleaned_data['last_name']
- if user_profile_info.first_name != first_name:
- user_profile_info.first_name = first_name
+ if user_info.first_name != first_name:
+ user_info.first_name = first_name
- if user_profile_info.last_name != last_name:
- user_profile_info.last_name = last_name
+ if user_info.last_name != last_name:
+ user_info.last_name = last_name
- user_profile_info.full_name = '%s %s' % (first_name, last_name)
- user_profile_info.gecos = '%s %s' % (first_name, last_name)
+ user_info.full_name = '%s %s' % (first_name, last_name)
+ user_info.gecos = '%s %s' % (first_name, last_name)
"""
- if user_profile_info.birthday != birthday:
- user_profile_info.birthday = birthday
+ if user_info.birthday != birthday:
+ user_info.birthday = birthday
"""
try:
- user_profile_info.save()
+ user_info.save()
except IntegrityError:
pass
except ldap.TYPE_OR_VALUE_EXISTS:
@@ -413,7 +414,7 @@ def profile_settings(request):
return render(request, 'settings-profile.html', {
'profile_settings': profile_settings,
- 'user_profile_info': user_profile_info,
+ 'user_info': user_info,
})
@@ -421,29 +422,32 @@ def profile_settings(request):
@otp_required
def password_settings(request):
""" Password settings """
- user_profile_info = get_bound_ldapuser(request)
+ user_info = get_bound_ldapuser(request)
password_settings = None
if request.method == "POST":
password_settings = PasswordSettingsForm(request.POST)
if password_settings.is_valid():
try:
new_password = password_settings.cleaned_data['new_password']
- new_password_verify = password_settings.cleaned_data['new_password_verify']
+ new_password_verify = password_settings.cleaned_data[
+ 'new_password_verify']
old_password = password_settings.cleaned_data['old_password']
if old_password and (new_password == new_password_verify):
- for hash in list(user_profile_info.password):
+ for hash in list(user_info.password):
print hash
try:
if ldap_md5_crypt.verify(old_password, hash):
- user_profile_info.password.append(ldap_md5_crypt.encrypt(new_password_verify))
- user_profile_info.password.remove(hash)
+ user_info.password.append(
+ ldap_md5_crypt.encrypt(
+ new_password_verify))
+ user_info.password.remove(hash)
break
except ValueError:
# ignore unknown hashes
pass
try:
- user_profile_info.save()
+ user_info.save()
except IntegrityError:
pass
except ldap.TYPE_OR_VALUE_EXISTS:
@@ -457,7 +461,7 @@ def password_settings(request):
return render(request, 'settings-password.html', {
'password_settings': password_settings,
- 'user_profile_info': user_profile_info,
+ 'user_info': user_info,
})
@@ -465,7 +469,7 @@ def password_settings(request):
@otp_required
def email_settings(request):
""" Email Settings """
- user_profile_info = get_bound_ldapuser(request)
+ user_info = get_bound_ldapuser(request)
email_settings = None
if request.method == "POST":
email_settings = EmailSettingsForm(request.POST)
@@ -474,12 +478,12 @@ def email_settings(request):
email = email_settings.cleaned_data['email']
if request.POST.get('delete'):
- user_profile_info.email.remove(email)
+ user_info.email.remove(email)
else:
- user_profile_info.email.append(email)
+ user_info.email.append(email)
try:
- user_profile_info.save()
+ user_info.save()
except IntegrityError:
pass
except ldap.TYPE_OR_VALUE_EXISTS:
@@ -493,7 +497,7 @@ def email_settings(request):
return render(request, 'settings-email.html', {
'email_settings': email_settings,
- 'user_profile_info': user_profile_info,
+ 'user_info': user_info,
})
@@ -501,13 +505,14 @@ def email_settings(request):
@otp_required
def contact_settings(request):
""" Contact details """
- user_profile_info = get_bound_ldapuser(request)
+ user_info = get_bound_ldapuser(request)
contact_settings = None
if request.method == "POST":
contact_settings = ContactSettingsForm(request.POST)
if contact_settings.is_valid():
try:
- gpg_fingerprint = contact_settings.cleaned_data['gpg_fingerprint']
+ gpg_fingerprint = contact_settings.cleaned_data[
+ 'gpg_fingerprint']
im = contact_settings.cleaned_data['im']
latitude = contact_settings.cleaned_data['latitude']
location = contact_settings.cleaned_data['location']
@@ -515,32 +520,32 @@ def contact_settings(request):
phone = contact_settings.cleaned_data['phone']
website = contact_settings.cleaned_data['website']
- if user_profile_info.location != location:
- user_profile_info.location = location
+ if user_info.location != location:
+ user_info.location = location
- if user_profile_info.phone != phone:
- user_profile_info.phone = phone
+ if user_info.phone != phone:
+ user_info.phone = phone
- if user_profile_info.website != website:
- user_profile_info.website.pop()
- user_profile_info.website.append(website)
+ if user_info.website != website:
+ user_info.website.pop()
+ user_info.website.append(website)
- if user_profile_info.im != im:
- user_profile_info.im.pop()
- user_profile_info.im.append(im)
+ if user_info.im != im:
+ user_info.im.pop()
+ user_info.im.append(im)
- if user_profile_info.longitude != longitude:
- user_profile_info.longitude = longitude
+ if user_info.longitude != longitude:
+ user_info.longitude = longitude
- if user_profile_info.latitude != latitude:
- user_profile_info.latitude = latitude
+ if user_info.latitude != latitude:
+ user_info.latitude = latitude
- if user_profile_info.gpg_fingerprint != gpg_fingerprint:
- user_profile_info.gpg_fingerprint.pop()
- user_profile_info.gpg_fingerprint.append(gpg_fingerprint)
+ if user_info.gpg_fingerprint != gpg_fingerprint:
+ user_info.gpg_fingerprint.pop()
+ user_info.gpg_fingerprint.append(gpg_fingerprint)
try:
- user_profile_info.save()
+ user_info.save()
except IntegrityError:
pass
except ldap.TYPE_OR_VALUE_EXISTS:
@@ -554,7 +559,7 @@ def contact_settings(request):
return render(request, 'settings-contact.html', {
'contact_settings': contact_settings,
- 'user_profile_info': user_profile_info,
+ 'user_info': user_info,
})
@@ -562,37 +567,39 @@ def contact_settings(request):
@otp_required
def gentoo_dev_settings(request):
""" Gentoo related information """
- user_profile_info = get_bound_ldapuser(request)
+ user_info = get_bound_ldapuser(request)
gentoo_account_settings = None
if request.method == "POST":
gentoo_account_settings = GentooAccountSettingsForm(request.POST)
if gentoo_account_settings.is_valid():
try:
devbug = gentoo_account_settings.cleaned_data['developer_bug']
- gentoo_join_date = gentoo_account_settings.cleaned_data['gentoo_join_date']
+ gentoo_join_date = gentoo_account_settings.cleaned_data[
+ 'gentoo_join_date']
gentoo_mentor = gentoo_account_settings.cleaned_data['mentor']
ssh_pubkey = gentoo_account_settings.cleaned_data['ssh_key']
- if user_profile_info.developer_bug != devbug:
- user_profile_info.developer_bug.append(devbug)
+ if user_info.developer_bug != devbug:
+ user_info.developer_bug.append(devbug)
- if user_profile_info.gentoo_join_date != gentoo_join_date:
- user_profile_info.gentoo_join_date.append(gentoo_join_date)
+ if user_info.gentoo_join_date != gentoo_join_date:
+ user_info.gentoo_join_date.append(gentoo_join_date)
- if user_profile_info.mentor != gentoo_mentor:
- user_profile_info.mentor.append(gentoo_mentor)
+ if user_info.mentor != gentoo_mentor:
+ user_info.mentor.append(gentoo_mentor)
if ssh_pubkey:
- user_profile_info.ssh_key.append(ssh_pubkey)
+ user_info.ssh_key.append(ssh_pubkey)
- if user_profile_info.is_retired or user_profile_info.gentoo_retire_date:
- gentoo_retire_date = gentoo_account_settings.cleaned_data['gentoo_retire_date']
- if user_profile_info.gentoo_retire_date != gentoo_retire_date:
- user_profile_info.gentoo_retire_date.append(
+ if user_info.is_retired or user_info.gentoo_retire_date:
+ gentoo_retire_date = gentoo_account_settings.cleaned_data[
+ 'gentoo_retire_date']
+ if user_info.gentoo_retire_date != gentoo_retire_date:
+ user_info.gentoo_retire_date.append(
gentoo_retire_date)
try:
- user_profile_info.save()
+ user_info.save()
except IntegrityError:
pass
except ldap.TYPE_OR_VALUE_EXISTS:
@@ -606,7 +613,7 @@ def gentoo_dev_settings(request):
return render(request, 'settings-gentoo.html', {
'gentoo_account_settings': gentoo_account_settings,
- 'user_profile_info': user_profile_info,
+ 'user_info': user_info,
})
diff --git a/okupy/templates/settings-contact.html b/okupy/templates/settings-contact.html
index 502e056..6912b1e 100644
--- a/okupy/templates/settings-contact.html
+++ b/okupy/templates/settings-contact.html
@@ -13,31 +13,31 @@
{{ contact_settings.non_field_errors }}
<div class="row-fluid">
{{ contact_settings.website.label_tag }}
- <input name="website" type="text" value="{{ user_profile_info.website.0 }}" /> {{ contact_settings.website.errors|striptags }}
+ <input name="website" type="text" value="{{ user_info.website.0 }}" /> {{ contact_settings.website.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.im.label_tag }}
- <input name="im" type="text" value="{{ user_profile_info.im.0 }}" /> {{ contact_settings.im.errors|striptags }}
+ <input name="im" type="text" value="{{ user_info.im.0 }}" /> {{ contact_settings.im.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.location.label_tag }}
- <input name="location" type="text" value="{{ user_profile_info.location }}" /> {{ contact_settings.location.errors|striptags }}
+ <input name="location" type="text" value="{{ user_info.location }}" /> {{ contact_settings.location.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.longitude.label_tag }}
- <input name="longitude" type="text" value="{{ user_profile_info.longitude }}" /> {{ contact_settings.longitude.errors|striptags }}
+ <input name="longitude" type="text" value="{{ user_info.longitude }}" /> {{ contact_settings.longitude.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.latitude.label_tag }}
- <input name="latitude" type="text" value="{{ user_profile_info.latitude }}" /> {{ contact_settings.latitude.errors|striptags }}
+ <input name="latitude" type="text" value="{{ user_info.latitude }}" /> {{ contact_settings.latitude.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.phone.label_tag }}
- <input name="phone" type="text" value="{{ user_profile_info.phone }}" /> {{ contact_settings.phone.errors|striptags }}
+ <input name="phone" type="text" value="{{ user_info.phone }}" /> {{ contact_settings.phone.errors|striptags }}
</div>
<div class="row-fluid">
{{ contact_settings.gpg_fingerprint.label_tag }}
- <input name="gpg_fingerprint" type="text" value="{{ user_profile_info.gpg_fingerprint.0 }}" /> {{ contact_settings.gpg_fingerprint.errors|striptags }}
+ <input name="gpg_fingerprint" type="text" value="{{ user_info.gpg_fingerprint.0 }}" /> {{ contact_settings.gpg_fingerprint.errors|striptags }}
</div>
<div class="row-fluid buttons">
diff --git a/okupy/templates/settings-email.html b/okupy/templates/settings-email.html
index 7f0af1d..e6a082c 100644
--- a/okupy/templates/settings-email.html
+++ b/okupy/templates/settings-email.html
@@ -19,7 +19,7 @@
</tr>
</thead>
<tbody>
- {% for mail in user_profile_info.email%}
+ {% for mail in user_info.email%}
<form action="." method="POST">{% csrf_token %}
<tr>
<td><input type="hidden" name="email" value="{{ mail }}" />{{mail}}</td>
diff --git a/okupy/templates/settings-gentoo.html b/okupy/templates/settings-gentoo.html
index 224c838..0ab16a6 100644
--- a/okupy/templates/settings-gentoo.html
+++ b/okupy/templates/settings-gentoo.html
@@ -7,24 +7,24 @@
<div>
<h1>Gentoo Developer Information</h1>
<h3>Change your Gentoo related details</h3>
- {% if user_profile_info.is_developer %}
+ {% if user_info.is_developer %}
<div class="form well">
<form action="." method="POST">{% csrf_token %}
<div class="row-fluid">
{{ gentoo_account_settings.developer_bug.label_tag }}
- <input name="developer_bug" type="text" value="{{ user_profile_info.developer_bug.0 }}" /> {{ gentoo_account_settings.developer_bug.errors|striptags }}
+ <input name="developer_bug" type="text" value="{{ user_info.developer_bug.0 }}" /> {{ gentoo_account_settings.developer_bug.errors|striptags }}
</div>
<div class="row-fluid">
{{ gentoo_account_settings.mentor.label_tag }}
- <input name="mentor" type="text" value="{{ user_profile_info.mentor.0 }}" /> {{ gentoo_account_settings.mentor.errors|striptags }}
+ <input name="mentor" type="text" value="{{ user_info.mentor.0 }}" /> {{ gentoo_account_settings.mentor.errors|striptags }}
</div>
<div class="row-fluid">
{{ gentoo_account_settings.gentoo_join_date.label_tag }}
- <input name="gentoo_join_date" type="text" value="{{ user_profile_info.gentoo_join_date.0 }}" /> {{ gentoo_account_settings.gentoo_join_date.errors|striptags }}
+ <input name="gentoo_join_date" type="text" value="{{ user_info.gentoo_join_date.0 }}" /> {{ gentoo_account_settings.gentoo_join_date.errors|striptags }}
</div>
<div class="row-fluid">
{{ gentoo_account_settings.gentoo_retire_date.label_tag }}
- <input name="gentoo_retire_date" type="text" value="{{ user_profile_info.gentoo_retire_date.0 }}" /> {{ gentoo_account_settings.gentoo_retire_date.errors|striptags }}
+ <input name="gentoo_retire_date" type="text" value="{{ user_info.gentoo_retire_date.0 }}" /> {{ gentoo_account_settings.gentoo_retire_date.errors|striptags }}
</div>
<div class="row-fluid">
{{ gentoo_account_settings.ssh_key.label_tag }} {{ gentoo_account_settings.ssh_key.errors|striptags }}
diff --git a/okupy/templates/settings-profile.html b/okupy/templates/settings-profile.html
index 05cd57c..2b9726c 100644
--- a/okupy/templates/settings-profile.html
+++ b/okupy/templates/settings-profile.html
@@ -13,19 +13,19 @@
{{ profile_settings.non_field_errors }}
<div class="row-fluid">
{{ profile_settings.first_name.label_tag }}
- <input name="first_name" type="text" value="{{ user_profile_info.first_name }}" /> {{ profile_settings.first_name.errors|striptags }}
+ <input name="first_name" type="text" value="{{ user_info.first_name }}" /> {{ profile_settings.first_name.errors|striptags }}
</div>
<div class="row-fluid">
{{ profile_settings.last_name.label_tag }}
- <input name="last_name" type="text" value="{{ user_profile_info.last_name }}" /> {{ profile_settings.last_name.errors|striptags }}
+ <input name="last_name" type="text" value="{{ user_info.last_name }}" /> {{ profile_settings.last_name.errors|striptags }}
</div>
<div class="row-fluid">
{{ profile_settings.email.label_tag }}
- <input name="email" type="text" value="{{ user_profile_info.email.0 }}" /> {{ profile_settings.email.errors|striptags }}
+ <input name="email" type="text" value="{{ user_info.email.0 }}" /> {{ profile_settings.email.errors|striptags }}
</div>
<!-- <div class="row-fluid">
{{ profile_settings.birthday.label_tag }}
- <input name="birthday" type="text" value="{{ user_profile_info.birthday }}" /> {{ profile_settings.birthday.errors|striptags }}
+ <input name="birthday" type="text" value="{{ user_info.birthday }}" /> {{ profile_settings.birthday.errors|striptags }}
</div> -->
<div class="row-fluid">
{{ profile_settings.timezone.label_tag }}
diff --git a/okupy/tests/integration/test_settings.py b/okupy/tests/integration/test_settings.py
index f22e926..3779e51 100644
--- a/okupy/tests/integration/test_settings.py
+++ b/okupy/tests/integration/test_settings.py
@@ -56,22 +56,22 @@ class SettingsIntegrationTests(TestCase):
self.assertTemplateUsed(response, 'base.html')
self.assertTemplateUsed(response, 'settings-gentoo.html')
- def test_profile_settings_page_returns_404_for_non_authenticated_users(self):
+ def test_profile_settings_page_returns_404_for_non_auth_users(self):
response = self.client.get('/profile-settings/')
self.assertTrue(response.status_code, 404)
- def test_password_settings_page_returns_404_for_non_authenticated_users(self):
+ def test_password_settings_page_returns_404_for_non_auth_users(self):
response = self.client.get('/password-settings/')
self.assertTrue(response.status_code, 404)
- def test_email_settings_page_returns_404_for_non_authenticated_users(self):
+ def test_email_settings_page_returns_404_for_non_auth_users(self):
response = self.client.get('/email-settings/')
self.assertTrue(response.status_code, 404)
- def test_contact_setttings_page_returns_404_for_non_authenticated_users(self):
+ def test_contact_setttings_page_returns_404_for_non_auth_users(self):
response = self.client.get('/contact-settings/')
self.assertTrue(response.status_code, 404)
- def test_gentoo_account_settings_page_returns_404_for_non_authenticated_users(self):
+ def test_gentoo_account_settings_page_returns_404_for_non_auth_users(self):
response = self.client.get('/gentoo-dev-settings/')
self.assertTrue(response.status_code, 404)