Exemplo n.º 1
0
 def clean(self):
     cleaned_data = super(StuProfileForm, self).clean()
     ruser = self.ruser
     if ruser:
         first_name = ruser.first_name.rstrip().lstrip()
         last_name = ruser.last_name.rstrip().lstrip()
         birthdate = cleaned_data.get('birthdate')
         byear = ""
         if birthdate:
             byear = birthdate.year
         if cleaned_data['tckimlikno'] and cleaned_data['ykimlikno']:
             raise forms.ValidationError(_("Please fill only one of them:tckimlikno,ykimlikno"))
         elif not cleaned_data['tckimlikno'] and cleaned_data['country'] == 'TR':
             raise forms.ValidationError(_("TC identity number can not be empty for Turkish citizens"))
         elif not cleaned_data.get('ykimlikno') and cleaned_data['country'] != 'TR':
             raise forms.ValidationError(_("Foreign identity number can not be empty for non Turkish citizens"))
         elif cleaned_data['tckimlikno'] and cleaned_data['country'] == 'TR':
             tcknosorgu = UserProfile.objects.filter(tckimlikno=cleaned_data['tckimlikno'])
             if tcknosorgu:
                 if tcknosorgu[0].user.username != ruser.username:
                     raise forms.ValidationError(_("Bu TC Kimlik numarasına sahip başka hesap var."))
             tckisvalid = UserProfileOPS.validateTCKimlikNo(cleaned_data['tckimlikno'].rstrip().lstrip(), first_name,
                                                            last_name, byear)
             if tckisvalid == -1:
                 raise forms.ValidationError(_("An error occured while verifing your TC identity number"))
             elif not tckisvalid:
                 raise forms.ValidationError(_(("Your identity information can not be verified, Please enter"
                                                "your TC identity number, your name, your last name (with Turkish"
                                                "characters if exist) and your birth date precisely")))
     else:
         raise forms.ValidationError(_("User not found"))
     return cleaned_data
Exemplo n.º 2
0
 def clean(self):
     cleaned_data = super(StuProfileForm, self).clean()
     ruser = self.ruser
     if ruser:
         first_name = ruser.first_name.rstrip().lstrip()
         last_name = ruser.last_name.rstrip().lstrip()
         byear = cleaned_data["birthdate"].year
         if cleaned_data["tckimlikno"] and cleaned_data["ykimlikno"]:
             raise forms.ValidationError(_("Please fill only one of them:tckimlikno,ykimlikno"))
         elif not cleaned_data["tckimlikno"] and cleaned_data["country"] == "TR":
             raise forms.ValidationError(_("TC identifier no can not be empty for Turkish citizens"))
         elif not cleaned_data["ykimlikno"] and cleaned_data["country"] != "TR":
             raise forms.ValidationError(_("Foreigner identifier no can not be blank for non Turkish citizens"))
         elif cleaned_data["tckimlikno"] and cleaned_data["country"] == "TR":
             tckisvalid = UserProfileOPS.validateTCKimlikNo(
                 cleaned_data["tckimlikno"].rstrip().lstrip(), first_name, last_name, byear
             )
             if tckisvalid == -1:
                 raise forms.ValidationError(_("Error occured during verify your TC identifier no"))
             elif not tckisvalid:
                 raise forms.ValidationError(
                     _(
                         "Your identification informations couldn't be verified, Please enter \
                                                  your TC identifier no, your name, your last name (with Turkish character) \
                                                  and your bird date completely"
                     )
                 )
     else:
         raise forms.ValidationError(_("User not found"))
     return cleaned_data
Exemplo n.º 3
0
 def clean(self):
     cleaned_data = super(StuProfileForm, self).clean()
     ruser = self.ruser
     if ruser:
         first_name = ruser.first_name.rstrip().lstrip()
         last_name = ruser.last_name.rstrip().lstrip()
         birthdate = cleaned_data.get('birthdate')
         byear = ""
         if birthdate:
             byear = birthdate.year
         if cleaned_data['tckimlikno'] and cleaned_data['ykimlikno']:
             raise forms.ValidationError(
                 _("Please fill only one of them:tckimlikno,ykimlikno"))
         elif not cleaned_data['tckimlikno'] and cleaned_data[
                 'country'] == 'TR':
             raise forms.ValidationError(
                 _("TC identity number can not be empty for Turkish citizens"
                   ))
         elif not cleaned_data.get(
                 'ykimlikno') and cleaned_data['country'] != 'TR':
             raise forms.ValidationError(
                 _("Foreign identity number can not be empty for non Turkish citizens"
                   ))
         elif cleaned_data['tckimlikno'] and cleaned_data['country'] == 'TR':
             tcknosorgu = UserProfile.objects.filter(
                 tckimlikno=cleaned_data['tckimlikno'])
             if tcknosorgu:
                 if tcknosorgu[0].user.username != ruser.username:
                     raise forms.ValidationError(
                         _("Bu TC Kimlik numarasına sahip başka hesap var.")
                     )
             tckisvalid = UserProfileOPS.validateTCKimlikNo(
                 cleaned_data['tckimlikno'].rstrip().lstrip(), first_name,
                 last_name, byear)
             if tckisvalid == -1:
                 raise forms.ValidationError(
                     _("An error occured while verifing your TC identity number"
                       ))
             elif not tckisvalid:
                 raise forms.ValidationError(
                     _(("Your identity information can not be verified, Please enter"
                        "your TC identity number, your name, your last name (with Turkish"
                        "characters if exist) and your birth date precisely"
                        )))
     else:
         raise forms.ValidationError(_("User not found"))
     return cleaned_data
Exemplo n.º 4
0
 def clean(self):
     cleaned_data = super(StuProfileForm, self).clean()
     ruser = self.ruser
     if ruser:
         first_name = ruser.first_name.rstrip().lstrip()
         last_name = ruser.last_name.rstrip().lstrip()
         byear = cleaned_data['birthdate'].year
         if cleaned_data['tckimlikno'] and cleaned_data['ykimlikno']:
             raise forms.ValidationError(
                 _("Please fill only one of them:tckimlikno,ykimlikno"))
         elif not cleaned_data['tckimlikno'] and cleaned_data[
                 'country'] == 'TR':
             raise forms.ValidationError(
                 _("TC identifier no can not be empty for Turkish citizens")
             )
         elif not cleaned_data[
                 'ykimlikno'] and cleaned_data['country'] != 'TR':
             raise forms.ValidationError(
                 _("Foreigner identifier no can not be blank for non Turkish citizens"
                   ))
         elif cleaned_data['tckimlikno'] and cleaned_data['country'] == 'TR':
             tckisvalid = UserProfileOPS.validateTCKimlikNo(
                 cleaned_data['tckimlikno'].rstrip().lstrip(), first_name,
                 last_name, byear)
             if tckisvalid == -1:
                 raise forms.ValidationError(
                     _("Error occured during verify your TC identifier no"))
             elif not tckisvalid:
                 raise forms.ValidationError(
                     _("Your identification informations couldn't be verified, Please enter \
                                                  your TC identifier no, your name, your last name (with Turkish character) \
                                                  and your bird date completely"
                       ))
     else:
         raise forms.ValidationError(_("User not found"))
     return cleaned_data