app/soc/views/site/user/profile.py
changeset 249 325fb70c61a9
parent 245 b14c2c4d3484
child 260 8b393bef717a
equal deleted inserted replaced
248:95e0b84e71c5 249:325fb70c61a9
    26 
    26 
    27 from django import http
    27 from django import http
    28 from django import newforms as forms
    28 from django import newforms as forms
    29 from django.utils.translation import ugettext_lazy
    29 from django.utils.translation import ugettext_lazy
    30 
    30 
    31 from soc.logic import common
    31 from soc.logic import validate
    32 from soc.logic import out_of_band
    32 from soc.logic import out_of_band
    33 from soc.logic.site import id_user
    33 from soc.logic.site import id_user
    34 from soc.views import simple
    34 from soc.views import simple
    35 from soc.views.helpers import forms_helpers
    35 from soc.views.helpers import forms_helpers
    36 from soc.views.helpers import list_helpers
    36 from soc.views.helpers import list_helpers
    68 
    68 
    69     if not link_name:
    69     if not link_name:
    70       # link name not supplied (which is OK), so do not try to validate it
    70       # link name not supplied (which is OK), so do not try to validate it
    71       return None
    71       return None
    72 
    72 
    73     if not common.isLinkNameFormatValid(link_name):
    73     if not validate.isLinkNameFormatValid(link_name):
    74       raise forms.ValidationError('This link name is in wrong format.')
    74       raise forms.ValidationError('This link name is in wrong format.')
    75     
    75     
    76     return link_name
    76     return link_name
    77 
    77 
    78   def clean_id(self):
    78   def clean_id(self):
   211   class Meta:
   211   class Meta:
   212     model = None
   212     model = None
   213  
   213  
   214   def clean_link_name(self):
   214   def clean_link_name(self):
   215     link_name = self.cleaned_data.get('link_name')
   215     link_name = self.cleaned_data.get('link_name')
   216     if not common.isLinkNameFormatValid(link_name):
   216     if not validate.isLinkNameFormatValid(link_name):
   217       raise forms.ValidationError("This link name is in wrong format.")
   217       raise forms.ValidationError("This link name is in wrong format.")
   218     else:
   218     else:
   219       key_name = self.data.get('key_name')
   219       key_name = self.data.get('key_name')
   220       if not id_user.isLinkNameAvailableForId(
   220       if not id_user.isLinkNameAvailableForId(
   221           link_name, id=id_user.getUserFromKeyName(key_name).id) :
   221           link_name, id=id_user.getUserFromKeyName(key_name).id) :
   363     model = None
   363     model = None
   364   
   364   
   365   
   365   
   366   def clean_link_name(self):
   366   def clean_link_name(self):
   367     link_name = self.cleaned_data.get('link_name')
   367     link_name = self.cleaned_data.get('link_name')
   368     if not common.isLinkNameFormatValid(link_name):
   368     if not validate.LinkNameFormatValid(link_name):
   369       raise forms.ValidationError("This link name is in wrong format.")
   369       raise forms.ValidationError("This link name is in wrong format.")
   370     else:
   370     else:
   371       if id_user.doesLinkNameExist(link_name):
   371       if id_user.doesLinkNameExist(link_name):
   372         raise forms.ValidationError("This link name is already in use.")
   372         raise forms.ValidationError("This link name is already in use.")
   373     return link_name
   373     return link_name