예제 #1
0
 def get_inv_text(self, inv):
     if inv == consts.PM_SEND_INV:
         return gettext("Sending")
     elif inv == consts.PM_REJECT_INV:
         return gettext("Rejected")
     else:
         return gettext("Accepted")
예제 #2
0
 def clean_password_1(self):
     pw0 = self.cleaned_data['password_0']
     pw1 = self.cleaned_data['password_1']
     if not re.search('^[a-zA-Z]+$',pw0) and re.search('^[0-9]+$',pw0):
         raise forms.ValidationError(gettext('error password format'))
         
     if pw0 != pw1 or len(pw0) == 0 is True:
         raise forms.ValidationError(gettext('password must same as twice'))
     
     return pw1
예제 #3
0
파일: forms.py 프로젝트: hciplab/project
 def clean_password_1(self):
     pw0 = self.cleaned_data['password_0']
     pw1 = self.cleaned_data['password_1']
     if pw0 != pw1 or len(pw0) == 0 is True:
         raise forms.ValidationError(gettext('password must same as twice'))
     
     return pw1
예제 #4
0
    def clean_password_1(self):
        pw0 = self.cleaned_data['password_0']
        pw1 = self.cleaned_data['password_1']
        if pw0 != pw1 or len(pw0) == 0 is True:
            raise forms.ValidationError(gettext('password must same as twice'))

        return pw1
예제 #5
0
    def clean_email(self):
        email = self.cleaned_data["email"]
        self.cache_user = q_get(User, email__iexact=email,
                                 status=consts.USER_ENABLE)

        if self.cache_user is None:
            raise forms.ValidationError(gettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
        return email
예제 #6
0
파일: forms.py 프로젝트: hciplab/project
    def clean_email(self):
        email = self.cleaned_data["email"]
        self.cache_user = q_get(User, email__iexact=email,
                                 status=consts.USER_ENABLE)

        if self.cache_user is None:
            raise forms.ValidationError(gettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
        return email
예제 #7
0
class NewUserForm(forms.ModelForm):
    name = forms.CharField(
        label=gettext("user id"),
        min_length=3,
        max_length=32,
        help_text=gettext("login account"),
        validators=[validate_slug,
                    UniqueValidator(User, 'name')])

    #nick = forms.CharField(label=gettext("nick name"),
    #                       min_length = 2,
    #                       max_length = 32,
    #                       help_text=gettext("display name"),
    #                       validators=[validate_slug,
    #                                   UniqueValidator(User, 'nick')])

    password_0 = forms.CharField(label=gettext("password"),
                                 min_length=6,
                                 max_length=12,
                                 required=False,
                                 widget=forms.PasswordInput)

    password_1 = forms.CharField(
        label=gettext("password(replay)"),
        min_length=6,
        max_length=12,
        required=False,
        help_text=gettext("password must same as twice"),
        widget=forms.PasswordInput)

    email = forms.EmailField(label=gettext("email address"),
                             help_text=gettext("eg:[email protected]"),
                             validators=[UniqueValidator(User, 'email')])

    accept = forms.BooleanField(
        label=gettext("accept privacy"),
        error_messages={'required': gettext('must accept privacy')},
        help_text="<a href='/about/privacy/' target='_blank'>privacy</a>")

    def clean_password_1(self):
        pw0 = self.cleaned_data['password_0']
        pw1 = self.cleaned_data['password_1']
        if pw0 != pw1 or len(pw0) == 0 is True:
            raise forms.ValidationError(gettext('password must same as twice'))

        return pw1

    class Meta:
        model = User
        fields = ('name', 'password_0', 'password_1', 'email')
예제 #8
0
class PasswordResetForm(forms.Form):
    email = forms.EmailField(label=gettext("E-mail"), max_length=75)

    def clean_email(self):
        email = self.cleaned_data["email"]
        self.cache_user = q_get(User, email__iexact=email,
                                 status=consts.USER_ENABLE)

        if self.cache_user is None:
            raise forms.ValidationError(gettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
        return email
예제 #9
0
 def __call__(self, value):
     if is_exist(self.m, **{self.n: value}):
         raise ValidationError(gettext('has exist'))
예제 #10
0
class NewUserForm(forms.ModelForm):
    name = forms.CharField(label='',
                           min_length = 3,
                           max_length = 40,
                           #help_text=gettext("min_length"),
                           #validators=[validate_slug,
                           validators=[validate_slug,
                                       UniqueValidator(User, 'name')],
                           error_messages={
                                           'required': '请输入用户名,用户名长度不少于3个字符,不能使用中文',
                                           'invalid': '请输入有效的用户名',
                                           'min_length':'用户名长度不少于3个字符,不能使用中文',
                                           'max_length':'用户名长度不能多于40个字符,不能使用中文',
                                           },
                           widget=forms.TextInput(attrs={'class':'text'}),
                        

                           )
    #nick = forms.CharField(label=gettext("nick name"),
    #                       min_length = 2,
    #                       max_length = 32,
    #                       help_text=gettext("display name"),
    #                       validators=[validate_slug,
    #                                   UniqueValidator(User, 'nick')])
    
    email = forms.EmailField(label=gettext("email address"),
                             help_text=gettext("eg:[email protected]"),
                             validators=[UniqueValidator(User, 'email')],
                             widget=forms.TextInput(attrs={'class':'text'}),
                             error_messages={
                                           'required': '请输入电邮地址',
                                           'invalid': '请输入有效的电邮地址',
                                           },
                             )   
    
    phone = forms.CharField(label=gettext("phone"),
                            min_length=11,
                            max_length=11,
                            required=False,
                            widget=forms.TextInput(attrs={'class':'text'}),
                            )
    
    title = forms.CharField(label=gettext("title"),
                            help_text=gettext("eg:taobao,diaosi ','"),
                            min_length=2,
                            max_length=200,
                            required=False,
                            widget=forms.TextInput(attrs={'class':'text'}),
                            )
    
    password_0 = forms.CharField(label=gettext("password"),
                                 min_length = 7,
                                 max_length = 12,
                                # required=False,
                                 widget=forms.PasswordInput(attrs={'class':'text'}),
                                 error_messages={
                                           'required': '请输入密码,密码长度不少于7个字符,至少包含一个字母或数字',
                                           'invalid': '密码长度不少于7个字符,至少包含一个字母或数字',
                                           'min_length':'密码长度不少于7个字符,至少包含一个字母或数字',
                                           },
                                 validators=[RegexValidator(re.compile(r'[^a-zA-Z+]|^.{1,6}$')),RegexValidator(re.compile(r'[^0-9+]|^.{1,6}$'))],
                                 )
    

    password_1 = forms.CharField(label=gettext("password(replay)"),
                                 min_length = 7,
                                 max_length = 12,
                                # required=False,
                                 help_text=gettext("password must same as twice"),
                                 widget=forms.PasswordInput(attrs={'class':'text'}),
                                 error_messages={
                                           'required': '请输入密码,密码长度不少于7个字符,至少包含一个字母或数字',
                                           'invalid': '密码长度不少于7个字符,至少包含一个字母或数字',
                                           'min_length':'密码长度不少于7个字符,至少包含一个字母或数字',
                                           },
                                validators=[RegexValidator(re.compile(r'[^a-zA-Z+]|^.{1,6}$')),RegexValidator(re.compile(r'[^0-9+]|^.{1,6}$'))],
                                    )


    accept = forms.BooleanField(label=gettext("accept privacy"),
                                error_messages={'required': gettext('must accept privacy')},
                                help_text="<a href='/about/privacy/' target='_blank'>privacy</a>",
                                
                                
                                
                                )
    
    def clean_password_1(self):
        pw0 = self.cleaned_data['password_0']
        pw1 = self.cleaned_data['password_1']
        if not re.search('^[a-zA-Z]+$',pw0) and re.search('^[0-9]+$',pw0):
            raise forms.ValidationError(gettext('error password format'))
            
        if pw0 != pw1 or len(pw0) == 0 is True:
            raise forms.ValidationError(gettext('password must same as twice'))
        
        return pw1
        
    class Meta:
        model = User
        fields = ('name',  'email','phone','title','password_0', 'password_1')
예제 #11
0
 def clean_password(self):
     pw=self.cleaned_data['password']
     if not re.search('^[a-zA-Z]+$',pw) and re.search('^[0-9]+$',pw):
         raise forms.ValidationError(gettext('error password format'))
     
     return pw