예제 #1
0
    def __init__(self, *args, **kwargs):
        AuthenticationForm.__init__(self, *args, **kwargs)
        self.error_messages['invalid_login'] = _(
            u"Пожалуйста, введите верные имя пользователя / адрес электронной почты  и пароль."
        )
        self.fields['username'].label = _(u"Логин / E-mail")

        self.helper = FormHelper(self)
        self.helper.form_action = '/accounts/login/'
        self.helper.label_class = 'col-md-4'
        self.helper.field_class = 'col-md-8'
        self.helper.layout.append(
            HTML(
                u"""<div class="form-group row" style="margin-bottom: 16px;margin-top: -16px;">
                                             <div class="col-md-offset-4 col-md-8">
                                               <a href="{% url "django.contrib.auth.views.password_reset" %}"><small class="text-muted">"""
                + _(u'Забыли пароль?') + """</small></a>
                                             </div>
                                           </div>
                                           <div class="form-group row">
                                             <div class="col-md-offset-4 col-md-8">
                                               <button type="submit" class="btn btn-secondary">"""
                + _(u'Войти') + """</button>
                                               <input type="hidden" name="next" value="{{ next }}" />
                                             </div>
                                           </div>"""))
예제 #2
0
    def __init__(self, request, *a, **kwa):

        AuthenticationForm.__init__(self, request, *a, **kwa)

        self.fields["next"].initial = request.GET.get("next", "")

        self.request = request
        self.redirect = None
예제 #3
0
 def __init__(self, user, ratings_required, ratings_range, num_rating_choices):
     AuthenticationForm.__init__(self)
     self.ratings_range, self.num_rating_choices = ratings_range, num_rating_choices
     choices = [(c, c) for c in ratings_range]
     def get_validator_list(rating_num):
         if rating_num <= num_rating_choices:
             return [validators.RequiredIfOtherFieldsGiven(['rating%d' % i for i in range(1, 9) if i != rating_num], _("This rating is required because you've entered at least one other rating."))]
         else:
             return []
     self.fields.extend([
         oldforms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
             validator_list=[self.hasNoProfanities]),
         oldforms.RadioSelectField(field_name="rating1", choices=choices,
             is_required=ratings_required and num_rating_choices > 0,
             validator_list=get_validator_list(1),
         ),
         oldforms.RadioSelectField(field_name="rating2", choices=choices,
             is_required=ratings_required and num_rating_choices > 1,
             validator_list=get_validator_list(2),
         ),
         oldforms.RadioSelectField(field_name="rating3", choices=choices,
             is_required=ratings_required and num_rating_choices > 2,
             validator_list=get_validator_list(3),
         ),
         oldforms.RadioSelectField(field_name="rating4", choices=choices,
             is_required=ratings_required and num_rating_choices > 3,
             validator_list=get_validator_list(4),
         ),
         oldforms.RadioSelectField(field_name="rating5", choices=choices,
             is_required=ratings_required and num_rating_choices > 4,
             validator_list=get_validator_list(5),
         ),
         oldforms.RadioSelectField(field_name="rating6", choices=choices,
             is_required=ratings_required and num_rating_choices > 5,
             validator_list=get_validator_list(6),
         ),
         oldforms.RadioSelectField(field_name="rating7", choices=choices,
             is_required=ratings_required and num_rating_choices > 6,
             validator_list=get_validator_list(7),
         ),
         oldforms.RadioSelectField(field_name="rating8", choices=choices,
             is_required=ratings_required and num_rating_choices > 7,
             validator_list=get_validator_list(8),
         ),
     ])
     if user.is_authenticated():
         self["username"].is_required = False
         self["username"].validator_list = []
         self["password"].is_required = False
         self["password"].validator_list = []
         self.user_cache = user
 def __init__(self, user, ratings_required, ratings_range, num_rating_choices):
     AuthenticationForm.__init__(self)
     self.ratings_range, self.num_rating_choices = ratings_range, num_rating_choices
     choices = [(c, c) for c in ratings_range]
     def get_validator_list(rating_num):
         if rating_num <= num_rating_choices:
             return [validators.RequiredIfOtherFieldsGiven(['rating%d' % i for i in range(1, 9) if i != rating_num], _("This rating is required because you've entered at least one other rating."))]
         else:
             return []
     self.fields.extend([
         oldforms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
             validator_list=[self.hasNoProfanities]),
         oldforms.RadioSelectField(field_name="rating1", choices=choices,
             is_required=ratings_required and num_rating_choices > 0,
             validator_list=get_validator_list(1),
         ),
         oldforms.RadioSelectField(field_name="rating2", choices=choices,
             is_required=ratings_required and num_rating_choices > 1,
             validator_list=get_validator_list(2),
         ),
         oldforms.RadioSelectField(field_name="rating3", choices=choices,
             is_required=ratings_required and num_rating_choices > 2,
             validator_list=get_validator_list(3),
         ),
         oldforms.RadioSelectField(field_name="rating4", choices=choices,
             is_required=ratings_required and num_rating_choices > 3,
             validator_list=get_validator_list(4),
         ),
         oldforms.RadioSelectField(field_name="rating5", choices=choices,
             is_required=ratings_required and num_rating_choices > 4,
             validator_list=get_validator_list(5),
         ),
         oldforms.RadioSelectField(field_name="rating6", choices=choices,
             is_required=ratings_required and num_rating_choices > 5,
             validator_list=get_validator_list(6),
         ),
         oldforms.RadioSelectField(field_name="rating7", choices=choices,
             is_required=ratings_required and num_rating_choices > 6,
             validator_list=get_validator_list(7),
         ),
         oldforms.RadioSelectField(field_name="rating8", choices=choices,
             is_required=ratings_required and num_rating_choices > 7,
             validator_list=get_validator_list(8),
         ),
     ])
     if user.is_authenticated():
         self["username"].is_required = False
         self["username"].validator_list = []
         self["password"].is_required = False
         self["password"].validator_list = []
         self.user_cache = user
예제 #5
0
파일: __init__.py 프로젝트: znick/anytask
    def __init__(self, *args, **kwargs):
        AuthenticationForm.__init__(self, *args, **kwargs)
        self.error_messages['invalid_login'] = _(u"Пожалуйста, введите верные имя пользователя / адрес электронной почты  и пароль.")
        self.fields['username'].label = _(u"Логин / E-mail")

        self.helper = FormHelper(self)
        self.helper.form_action = '/accounts/login/'
        self.helper.label_class = 'col-md-4'
        self.helper.field_class = 'col-md-8'
        self.helper.layout.append(HTML(u"""<div class="form-group row" style="margin-bottom: 16px;margin-top: -16px;">
                                             <div class="col-md-offset-4 col-md-8">
                                               <a href="{% url "django.contrib.auth.views.password_reset" %}"><small class="text-muted">""" + _(u'Забыли пароль?') + """</small></a>
                                             </div>
                                           </div>
                                           <div class="form-group row">
                                             <div class="col-md-offset-4 col-md-8">
                                               <button type="submit" class="btn btn-secondary">""" + _(u'Войти') + """</button>
                                               <input type="hidden" name="next" value="{{ next }}" />
                                             </div>
                                           </div>"""))
예제 #6
0
파일: forms.py 프로젝트: judgerain/codelist
 def __init__(self, *args, **kwargs):
     AuthenticationForm.__init__(self, *args, **kwargs)
     self.fields['username'].label = "Логин"
     self.fields['password'].label = "Пароль"
예제 #7
0
 def __init__(self, request):
     AuthenticationForm.__init__(self, request)
예제 #8
0
파일: views.py 프로젝트: incuna/authentic
 def __init__(self, request = None, **kwargs):
     AuthenticationForm.__init__(self, request, **kwargs)
     if request and NONCE_FIELD_NAME in request.REQUEST:
         self.initial[NONCE_FIELD_NAME] = request.REQUEST.get(NONCE_FIELD_NAME)
예제 #9
0
파일: forms.py 프로젝트: keiko713/shiritori
 def __init__(self, request=None, *args, **kwargs):
     AuthenticationForm.__init__(self, request=None, *args, **kwargs)
예제 #10
0
 def __init__(self, *args, **kwargs):
     BootstrapMixin.__init__(self, *args, **kwargs)
     AuthenticationForm.__init__(self, *args, **kwargs)
     self.fields['username'].label = u"Email / Login"
예제 #11
0
 def __init__(self, request=None, **kwargs):
     AuthenticationForm.__init__(self, request, **kwargs)
     if request and NONCE_FIELD_NAME in request.REQUEST:
         self.initial[NONCE_FIELD_NAME] = request.REQUEST.get(
             NONCE_FIELD_NAME)