From 88d060c530c28f7d6d9af52efc64b77bc79fce0d Mon Sep 17 00:00:00 2001 From: Pavlos Ratis Date: Wed, 25 Sep 2013 15:09:26 +0300 Subject: support multiple values (+ planet/universe fields) --- okupy/accounts/forms.py | 6 +- okupy/accounts/views.py | 61 ++++++++---- okupy/templates/settings-contact.html | 107 +++++++++++++++++--- okupy/templates/settings-email.html | 2 +- okupy/templates/settings-gentoo.html | 181 +++++++++++++++++++++++++++++----- 5 files changed, 292 insertions(+), 65 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/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 @@

Contact Settings

Change your contact to details.

-
{% csrf_token %} - {{ contact_settings.errors }} - {{ contact_settings.non_field_errors }} -
+ {{ contact_settings.errors }} + {{ contact_settings.non_field_errors }} +
+ {% if user_info.website %} + + + + + + + + + {% for website in user_info.website %} + {% csrf_token %} + + + + + + {% endfor %} + +
Websites
{{ website }}
+ {% endif %} +
{% csrf_token %} {{ contact_settings.website.label_tag }} - {{ contact_settings.website.errors|striptags }} -
-
+ {{ contact_settings.website.errors|striptags }} +
+ +
+ +
+
+
+ {% if user_info.im %} + + + + + + + + + {% for im in user_info.im %} + {% csrf_token %} + + + + + + {% endfor %} + +
IMs
{{ im }}
+ {% endif %} +
{% csrf_token %} {{ contact_settings.im.label_tag }} - {{ contact_settings.im.errors|striptags }} -
+ {{ contact_settings.im.errors|striptags }} +
+ +
+ +
+
+
+ {% if user_info.gpg_fingerprint %} + + + + + + + + + {% for gpg_fingerprint in user_info.gpg_fingerprint %} + {% csrf_token %} + + + + + + {% endfor %} + +
GPG Fingerprints
{{ gpg_fingerprint }}
+ {% endif %} +
{% csrf_token %} + {{ contact_settings.gpg_fingerprint.label_tag }} + {{ contact_settings.gpg_fingerprint.errors|striptags }} +
+ +
+
+
+
+
{% csrf_token %}
{{ contact_settings.location.label_tag }} {{ contact_settings.location.errors|striptags }} @@ -35,12 +117,9 @@ {{ contact_settings.phone.label_tag }} {{ contact_settings.phone.errors|striptags }}
-
- {{ contact_settings.gpg_fingerprint.label_tag }} - {{ contact_settings.gpg_fingerprint.errors|striptags }} -
+
- +
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%}
{% csrf_token %} - {{mail}} + {{ mail }}
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 @@
-

Gentoo Developer Information

-

Change your Gentoo related details

- {% if user_info.is_developer %} +

Gentoo Account Settings

+

Change Gentoo related information.

-
{% csrf_token %} -
- {{ gentoo_account_settings.developer_bug.label_tag }} - {{ gentoo_account_settings.developer_bug.errors|striptags }} -
-
+ {{ gentoo_account_settings.errors }} + {{ gentoo_account_settings.non_field_errors }} +
+ {% if user_info.developer_bug %} + + + + + + + + + {% for devbug in user_info.developer_bug %} + {% csrf_token %} + + + {% if user_info.is_recruiter %} + + {% endif %} + + + {% endfor %} + +
Developer Bug
{{ devbug }}
+ {% endif %} + {% if user_info.recruiter %} +
{% csrf_token %} + {{ gentoo_account_settings.developer_bug.label_tag }} + {{ gentoo_account_settings.developer_bug.errors|striptags }} +
+ +
+
+ {% endif %} +
+
+
+ {% if user_info.gentoo_join_date %} + + + + + + + + + {% for gjd in user_info.gentoo_join_date %} + {% csrf_token %} + + + {% if user_info.is_recruiter %} + + {% endif %} + + + {% endfor %} + +
Gentoo Join Date
{{ gjd }}
+ {% endif %} + {% if user_info.is_recruiter %} +
{% csrf_token %} + {{ gentoo_account_settings.gentoo_join_date.label_tag }} + {{ gentoo_account_settings.gentoo_join_date.errors|striptags }} +
+ +
+
+ {% endif %} +
+
+
+ {% if user_info.mentor %} + + + + + + + + + {% for mentor in user_info.mentor %} + {% csrf_token %} + + + {% if user_info.is_recruiter %} + + {% endif %} + + + {% endfor %} + +
Mentor
{{ mentor }}
+ {% endif %} + {% if user_info.is_recuriter %} +
{% csrf_token %} {{ gentoo_account_settings.mentor.label_tag }} - {{ gentoo_account_settings.mentor.errors|striptags }} -
-
- {{ gentoo_account_settings.gentoo_join_date.label_tag }} - {{ gentoo_account_settings.gentoo_join_date.errors|striptags }} -
-
+ {{ gentoo_account_settings.mentor.errors|striptags }} +
+ +
+ + {% endif %} +
+
+
+ {% if user_info.gentoo_retire_date %} + + + + + + + + + {% for grd in user_info.gentoo_retire_date %} + {% csrf_token %} + + + {% if user_info.is_recruiter %} + + {% endif %} + + + {% endfor %} + +
Gentoo Retire Date
{{ grd }}
+ {% endif %} + {% if user_info.is_recruiter %} +
{% csrf_token %} {{ gentoo_account_settings.gentoo_retire_date.label_tag }} - {{ gentoo_account_settings.gentoo_retire_date.errors|striptags }} -
-
- {{ gentoo_account_settings.ssh_key.label_tag }} {{ gentoo_account_settings.ssh_key.errors|striptags }} - {{ gentoo_account_settings.ssh_key }} -
-
- -
- + {{ gentoo_account_settings.gentoo_retire_date.errors|striptags }} +
+ +
+ + {% endif %} +
+
+ {% if user_info.is_developer %} +
{% csrf_token %} +
+ {{ gentoo_account_settings.planet_feed.label_tag }} + {{ gentoo_account_settings.planet_feed.errors|striptags }} +
+
+ {{ gentoo_account_settings.universe_feed.label_tag }} + {{ gentoo_account_settings.universe_feed.errors|striptags }} +
+
+
+ +
+
+ {% endif %}
- {% endif %}
-- cgit v1.2.3-65-gdbad