diff options
Diffstat (limited to 'okupy')
-rw-r--r-- | okupy/accounts/forms.py | 6 | ||||
-rw-r--r-- | okupy/accounts/views.py | 61 | ||||
-rw-r--r-- | okupy/common/ldap_helpers.py | 3 | ||||
-rw-r--r-- | okupy/templates/index.html | 2 | ||||
-rw-r--r-- | okupy/templates/settings-contact.html | 107 | ||||
-rw-r--r-- | okupy/templates/settings-email.html | 2 | ||||
-rw-r--r-- | okupy/templates/settings-gentoo.html | 181 | ||||
-rw-r--r-- | okupy/tests/unit/test_login.py | 4 |
8 files changed, 296 insertions, 70 deletions
diff --git a/okupy/accounts/forms.py b/okupy/accounts/forms.py index d26c34b..b73d335 100644 --- a/okupy/accounts/forms.py +++ b/okupy/accounts/forms.py @@ -108,6 +108,7 @@ class EmailSettingsForm(forms.Form): gravatar = forms.EmailField(max_length=254, label='Gravatar Email', required=False) + class ContactSettingsForm(forms.Form): website = forms.URLField(label='Website', required=False) im = forms.CharField(max_length=100, label='IM', required=False) @@ -126,8 +127,9 @@ class GentooAccountSettingsForm(forms.Form): developer_bug = forms.CharField( label='Developer Bugs (Bug Number)', required=False) mentor = forms.CharField(max_length=100, label='Mentor', required=False) - ssh_key = forms.CharField(widget=forms.Textarea( - attrs={'cols': 50, 'rows': 8}), label='SSH Key', required=False) + planet_feed = forms.URLField(label='Gentoo Planet Feed', required=False) + universe_feed = forms.URLField( + label='Gentoo Universe Feed', required=False) # OpenID forms. diff --git a/okupy/accounts/views.py b/okupy/accounts/views.py index 6487c8b..4616102 100644 --- a/okupy/accounts/views.py +++ b/okupy/accounts/views.py @@ -531,18 +531,20 @@ def contact_settings(request): phone = contact_settings.cleaned_data['phone'] website = contact_settings.cleaned_data['website'] - if user_info.location != location: + if location and user_info.location != location: user_info.location = location if user_info.phone != phone: user_info.phone = phone - if user_info.website != website: - user_info.website.pop() + if request.POST.get('delete_web'): + user_info.website.remove(website) + elif website and (not website in user_info.website): user_info.website.append(website) - if user_info.im != im: - user_info.im.pop() + if request.POST.get('delete_im'): + user_info.im.remove(im) + elif im and (not im in user_info.im): user_info.im.append(im) if user_info.longitude != longitude: @@ -551,8 +553,10 @@ def contact_settings(request): if user_info.latitude != latitude: user_info.latitude = latitude - if user_info.gpg_fingerprint != gpg_fingerprint: - user_info.gpg_fingerprint.pop() + if request.POST.get('delete_gpg'): + user_info.gpg_fingerprint.remove(gpg_fingerprint) + elif gpg_fingerprint and \ + (not gpg_fingerprint in user_info.gpg_fingerprint): user_info.gpg_fingerprint.append(gpg_fingerprint) try: @@ -590,27 +594,42 @@ def gentoo_dev_settings(request): 'gentoo_join_date'] gentoo_mentor = gentoo_account_settings.cleaned_data[ 'mentor'] - ssh_pubkey = gentoo_account_settings.cleaned_data[ - 'ssh_key'] - - if user_info.developer_bug != devbug: + gentoo_retire_date = gentoo_account_settings.cleaned_data[ + 'gentoo_retire_date'] + gentoo_mentor = gentoo_account_settings.cleaned_data[ + 'mentor'] + planet_feed = gentoo_account_settings.cleaned_data[ + 'planet_feed'] + universe_feed = gentoo_account_settings.cleaned_data[ + 'universe_feed'] + + if request.POST.get('delete_devbug'): + user_info.devbug.remove(devbug) + elif devbug and (not devbug in user_info.developer_bug): user_info.developer_bug.append(devbug) - if user_info.gentoo_join_date != gentoo_join_date: + if request.POST.get('delete_gjd'): + user_info.gentoo_join_date.remove(gentoo_join_date) + elif gentoo_join_date and (not gentoo_join_date in user_info.gentoo_join_date): user_info.gentoo_join_date.append(gentoo_join_date) - if user_info.mentor != gentoo_mentor: + if request.POST.get('delete_mentor'): + user_info.mentor.remove(gentoo_mentor) + elif gentoo_mentor and \ + (not gentoo_mentor in user_info.mentor): user_info.mentor.append(gentoo_mentor) - if ssh_pubkey: - user_info.ssh_key.append(ssh_pubkey) + if user_info.gentoo_retire_date: + if request.POST.get('delete_grd'): + user_info.gentoo_retire_date.remove(gentoo_retire_date) + elif gentoo_retire_date and (not gentoo_retire_date in user_info.gentoo_retire_date): + user_info.gentoo_retire_date.append(gentoo_retire_date) + + if user_info.planet_feed != planet_feed: + user_info.planet_feed = planet_feed - 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) + if user_info.universe_feed != universe_feed: + user_info.universe_feed = universe_feed try: user_info.save() diff --git a/okupy/common/ldap_helpers.py b/okupy/common/ldap_helpers.py index 2a5250f..4d872d3 100644 --- a/okupy/common/ldap_helpers.py +++ b/okupy/common/ldap_helpers.py @@ -8,9 +8,6 @@ from okupy import OkupyError from okupy.accounts.models import LDAPUser from okupy.crypto.ciphers import cipher -from django.conf import settings #debug -from django.db import connections - def get_bound_ldapuser(request, password=None, username=None): """ diff --git a/okupy/templates/index.html b/okupy/templates/index.html index f464d46..01ff084 100644 --- a/okupy/templates/index.html +++ b/okupy/templates/index.html @@ -46,6 +46,7 @@ </div> </p> </div> + {% if user.is_developer %} <div class="row-fluid"> <p> <div class="span9"> @@ -77,6 +78,7 @@ </div> </p> </div> + {% endif %} {% endfor %} </div> </div> diff --git a/okupy/templates/settings-contact.html b/okupy/templates/settings-contact.html index 05d21ba..9929e66 100644 --- a/okupy/templates/settings-contact.html +++ b/okupy/templates/settings-contact.html @@ -8,17 +8,99 @@ <h1>Contact Settings</h1> <h3>Change your contact to details.</h3> <div class="form well"> - <form action="." method="POST">{% csrf_token %} - {{ contact_settings.errors }} - {{ contact_settings.non_field_errors }} - <div class="row-fluid"> + {{ contact_settings.errors }} + {{ contact_settings.non_field_errors }} + <div class="row-fluid"> + {% if user_info.website %} + <table class="table"> + <thead> + <tr> + <th>Websites</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for website in user_info.website %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="website" value="{{ website }}" />{{ website }}</td> + <td><input class="btn" type="submit" name="delete_web" value="Delete" /></td> + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + <form action="." method="POST">{% csrf_token %} {{ contact_settings.website.label_tag }} - <input name="website" type="text" value="{{ user_info.website.0 }}" /> {{ contact_settings.website.errors|striptags }} - </div> - <div class="row-fluid"> + <input name="website" type="text" /> {{ contact_settings.website.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + <br /> + </div> + <div class="row-fluid"> + {% if user_info.im %} + <table class="table"> + <thead> + <tr> + <th>IMs</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for im in user_info.im %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="im" value="{{ im }}" />{{ im }}</td> + <td><input class="btn" type="submit" name="delete_im" value="Delete" /></td> + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + <form action="." method="POST">{% csrf_token %} {{ contact_settings.im.label_tag }} - <input name="im" type="text" value="{{ user_info.im.0 }}" /> {{ contact_settings.im.errors|striptags }} - </div> + <input name="im" type="text" /> {{ contact_settings.im.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + <br /> + </div> + <div class="row-fluid"> + {% if user_info.gpg_fingerprint %} + <table class="table"> + <thead> + <tr> + <th>GPG Fingerprints</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for gpg_fingerprint in user_info.gpg_fingerprint %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="gpg_fingerprint" value="{{ gpg_fingerprint }}" />{{ gpg_fingerprint }}</td> + <td><input class="btn" type="submit" name="delete_gpg" value="Delete" /></td> + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + <form action="." method="POST">{% csrf_token %} + {{ contact_settings.gpg_fingerprint.label_tag }} + <input name="gpg_fingerprint" type="text" /> {{ contact_settings.gpg_fingerprint.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + <br/> + </div> + <form action="." method="POST">{% csrf_token %} <div class="row-fluid"> {{ contact_settings.location.label_tag }} <input name="location" type="text" value="{{ user_info.location }}" /> {{ contact_settings.location.errors|striptags }} @@ -35,12 +117,9 @@ {{ contact_settings.phone.label_tag }} <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_info.gpg_fingerprint.0 }}" /> {{ contact_settings.gpg_fingerprint.errors|striptags }} - </div> + <br /> <div class="row-fluid buttons"> - <input class="btn btn-primary" type="submit" value="Save" /> + <input class="btn btn-primary" type="submit" value="Update" /> </div> </form> </div> diff --git a/okupy/templates/settings-email.html b/okupy/templates/settings-email.html index 1c21f28..1f02bfa 100644 --- a/okupy/templates/settings-email.html +++ b/okupy/templates/settings-email.html @@ -22,7 +22,7 @@ {% for mail in user_info.email%} <form action="." method="POST">{% csrf_token %} <tr> - <td><input type="hidden" name="email" value="{{ mail }}" />{{mail}}</td> + <td><input type="hidden" name="email" value="{{ mail }}" />{{ mail }}</td> <td><input class="btn" type="submit" name="delete" value="Delete" /></td> </tr> </form> diff --git a/okupy/templates/settings-gentoo.html b/okupy/templates/settings-gentoo.html index 85a2916..b5192e0 100644 --- a/okupy/templates/settings-gentoo.html +++ b/okupy/templates/settings-gentoo.html @@ -5,37 +5,164 @@ <div class="row"> <div id="page" class="span10"> <div> - <h1>Gentoo Developer Information</h1> - <h3>Change your Gentoo related details</h3> - {% if user_info.is_developer %} + <h1>Gentoo Account Settings</h1> + <h3>Change Gentoo related information.</h3> <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_info.developer_bug.0 }}" /> {{ gentoo_account_settings.developer_bug.errors|striptags }} - </div> - <div class="row-fluid"> + {{ gentoo_account_settings.errors }} + {{ gentoo_account_settings.non_field_errors }} + <div class="row-fluid"> + {% if user_info.developer_bug %} + <table class="table"> + <thead> + <tr> + <th>Developer Bug</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for devbug in user_info.developer_bug %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="developer_bug" value="{{ devbug }}" />{{ devbug }}</td> + {% if user_info.is_recruiter %} + <td><input class="btn" type="submit" name="delete_devbug" value="Delete" /></td> + {% endif %} + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + {% if user_info.recruiter %} + <form action="." method="POST">{% csrf_token %} + {{ gentoo_account_settings.developer_bug.label_tag }} + <input name="developer_bug" type="text" /> {{ gentoo_account_settings.developer_bug.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + {% endif %} + <br /> + </div> + <div class="row-fluid"> + {% if user_info.gentoo_join_date %} + <table class="table"> + <thead> + <tr> + <th>Gentoo Join Date</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for gjd in user_info.gentoo_join_date %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="gentoo_join_date" value="{{ gjd }}" />{{ gjd }}</td> + {% if user_info.is_recruiter %} + <td><input class="btn" type="submit" name="delete_gjd" value="Delete" /></td> + {% endif %} + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + {% if user_info.is_recruiter %} + <form action="." method="POST">{% csrf_token %} + {{ gentoo_account_settings.gentoo_join_date.label_tag }} + <input name="im" type="text" /> {{ gentoo_account_settings.gentoo_join_date.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + {% endif %} + <br /> + </div> + <div class="row-fluid"> + {% if user_info.mentor %} + <table class="table"> + <thead> + <tr> + <th>Mentor</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for mentor in user_info.mentor %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="mentor" value="{{ mentor }}" />{{ mentor }}</td> + {% if user_info.is_recruiter %} + <td><input class="btn" type="submit" name="delete_mentor" value="Delete" /></td> + {% endif %} + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + {% if user_info.is_recuriter %} + <form action="." method="POST">{% csrf_token %} {{ gentoo_account_settings.mentor.label_tag }} - <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_info.gentoo_join_date.0 }}" /> {{ gentoo_account_settings.gentoo_join_date.errors|striptags }} - </div> - <div class="row-fluid"> + <input name="mentor" type="text" /> {{ gentoo_account_settings.mentor.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + {% endif %} + <br/> + </div> + <div class="row-fluid"> + {% if user_info.gentoo_retire_date %} + <table class="table"> + <thead> + <tr> + <th>Gentoo Retire Date</th> + <th> </th> + </tr> + </thead> + <tbody> + {% for grd in user_info.gentoo_retire_date %} + <form action="." method="POST">{% csrf_token %} + <tr> + <td><input type="hidden" name="gentoo_retire_date" value="{{ grd }}" />{{ grd }}</td> + {% if user_info.is_recruiter %} + <td><input class="btn" type="submit" name="delete_grd" value="Delete" /></td> + {% endif %} + </tr> + </form> + {% endfor %} + </tbody> + </table> + {% endif %} + {% if user_info.is_recruiter %} + <form action="." method="POST">{% csrf_token %} {{ gentoo_account_settings.gentoo_retire_date.label_tag }} - <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 }} - {{ gentoo_account_settings.ssh_key }} - </div> - <div class="row-fluid buttons"> - <input class="btn btn-primary" type="submit" value="Update" /> - </div> - </form> + <input name="gentoo_retire_date" type="text" /> {{ gentoo_account_settings.gentoo_retire_date.errors|striptags }} + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Add" /> + </div> + </form> + {% endif %} + <br/> + </div> + {% if user_info.is_developer %} + <form action="." method="POST">{% csrf_token %} + <div class="row-fluid"> + {{ gentoo_account_settings.planet_feed.label_tag }} + <input name="planet_feed" type="text" value="{{ user_info.planet_feed }}" /> {{ gentoo_account_settings.planet_feed.errors|striptags }} + </div> + <div class="row-fluid"> + {{ gentoo_account_settings.universe_feed.label_tag }} + <input name="universe_feed" type="text" value="{{ user_info.universe_feed }}" /> {{ gentoo_account_settings.universe_feed.errors|striptags }} + </div> + <br /> + <div class="row-fluid buttons"> + <input class="btn btn-primary" type="submit" value="Update" /> + </div> + </form> + {% endif %} </div> - {% endif %} </div> </div> </div> diff --git a/okupy/tests/unit/test_login.py b/okupy/tests/unit/test_login.py index c9948db..07bf089 100644 --- a/okupy/tests/unit/test_login.py +++ b/okupy/tests/unit/test_login.py @@ -149,7 +149,7 @@ class LoginUnitTestsNoLDAP(OkupyTestCase): response = login(request) response.context = RequestContext(request) self.assertMessage(response, - "Can't contact the LDAP server or the database", 40) + "Can't contact the LDAP server or the database", 40) def test_no_ldap_connection_raises_ldaperror_in_login(self): request = set_request(uri='/login', post=vars.LOGIN_WRONG, @@ -157,7 +157,7 @@ class LoginUnitTestsNoLDAP(OkupyTestCase): response = login(request) response.context = RequestContext(request) self.assertMessage(response, - "Can't contact the LDAP server or the database", 40) + "Can't contact the LDAP server or the database", 40) def test_no_ldap_connection_in_logout_sends_notification_mail(self): request = set_request(uri='/login', post=vars.LOGIN_ALICE, |