From 02d42cadddeabe53551bdd501add6697a82b1095 Mon Sep 17 00:00:00 2001 From: Carlos Oliveira Date: Tue, 10 Feb 2015 16:04:25 -0200 Subject: [PATCH] Verifying if social networks are enabled --- colab/accounts/forms.py | 21 +++++++++++++++------ colab/accounts/templates/accounts/user_detail.html | 34 ++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/colab/accounts/forms.py b/colab/accounts/forms.py index 315498a..5bf8cb2 100644 --- a/colab/accounts/forms.py +++ b/colab/accounts/forms.py @@ -15,11 +15,15 @@ from django.utils.translation import ugettext_lazy as _ from conversejs.models import XMPPAccount +from colab import settings + from .utils.validators import validate_social_account from .utils import mailman User = get_user_model() +SOCIAL_NETWORK_ENABLED = getattr(settings, 'SOCIAL_NETWORK_ENABLED') + class SocialAccountField(forms.Field): def __init__(self, *args, **kwargs): @@ -107,6 +111,7 @@ class UserForm(forms.ModelForm): class UserUpdateForm(UserForm): + bio = forms.CharField( widget=forms.Textarea(attrs={'rows': '6', 'maxlength': '200'}), max_length=200, @@ -122,12 +127,16 @@ class UserUpdateForm(UserForm): class Meta: model = User fields = ('first_name', 'last_name', - 'institution', 'role', 'twitter', 'facebook', - 'google_talk', 'github', 'webpage', 'bio') - - twitter = SocialAccountField(url='https://twitter.com/', required=False) - facebook = SocialAccountField(url='https://graph.facebook.com/', - required=False) + 'institution', 'role') + if SOCIAL_NETWORK_ENABLED: + fields += ('twitter', 'facebook', 'google_talk', 'github') + fields += ('webpage', 'bio') + + if SOCIAL_NETWORK_ENABLED: + twitter = SocialAccountField(url='https://twitter.com/', + required=False) + facebook = SocialAccountField(url='https://graph.facebook.com/', + required=False) class ListsForm(forms.Form): diff --git a/colab/accounts/templates/accounts/user_detail.html b/colab/accounts/templates/accounts/user_detail.html index eac8758..2dd8660 100644 --- a/colab/accounts/templates/accounts/user_detail.html +++ b/colab/accounts/templates/accounts/user_detail.html @@ -60,25 +60,27 @@ {% endif %} {% if request.user.is_active %} -
  • - {% if user_.twitter %} - {{ user_.twitter }} - {% endif %} - {% if user_.facebook %} - {{ user_.facebook }} - {% endif %} -
  • + {% if SOCIAL_NETWORK_ENABLED %} +
  • + {% if user_.twitter %} + {{ user_.twitter }} + {% endif %} + {% if user_.facebook %} + {{ user_.facebook }} + {% endif %} +
  • - {% if user_.google_talk %} -
  • {{ user_.google_talk }}
  • - {% endif %} + {% if user_.google_talk %} +
  • {{ user_.google_talk }}
  • + {% endif %} - {% if user_.github %} -
  • {{ user_.github }}
  • - {% endif %} + {% if user_.github %} +
  • {{ user_.github }}
  • + {% endif %} - {% if user_.webpage %} -
  • {{ user_.webpage }}
  • + {% if user_.webpage %} +
  • {{ user_.webpage }}
  • + {% endif %} {% endif %} {% endif %} -- libgit2 0.21.2