當前位置: 首頁>>代碼示例>>Python>>正文


Python forms.RegistrationForm方法代碼示例

本文整理匯總了Python中registration.forms.RegistrationForm方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.RegistrationForm方法的具體用法?Python forms.RegistrationForm怎麽用?Python forms.RegistrationForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在registration.forms的用法示例。


在下文中一共展示了forms.RegistrationForm方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def __init__(self, *args, **kwargs):
        super(RegistrationForm, self).__init__(*args, **kwargs)
        self.fields['username'].label = _(u"Логин")
        self.fields['first_name'].label = _(u"Имя")
        self.fields['last_name'].label = _(u"Фамилия")
        self.fields['show_email'].label = _(u"Показывать мой e-mail всем пользователям")

        self.fields.keyOrder = [
            'username',
            'first_name',
            'last_name',
            'email',
            'show_email',
            'password1',
            'password2',
            #'invite',
        ] 
開發者ID:znick,項目名稱:anytask,代碼行數:19,代碼來源:__init__.py

示例2: test_form_class

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def test_form_class(self):
        """
        Test that the default form class returned is
        ``registration.forms.RegistrationForm``.

        """
        self.failUnless(self.backend.get_form_class(_mock_request()) is forms.RegistrationForm) 
開發者ID:znick,項目名稱:anytask,代碼行數:9,代碼來源:backends.py

示例3: test_registration_view_initial

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def test_registration_view_initial(self):
        """
        A ``GET`` to the ``register`` view uses the appropriate
        template and populates the registration form into the context.

        """
        response = self.client.get(reverse('registration_register'))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response,
                                'registration/registration_form.html')
        self.failUnless(isinstance(response.context['form'],
                                   forms.RegistrationForm)) 
開發者ID:znick,項目名稱:anytask,代碼行數:14,代碼來源:views.py

示例4: __init__

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def __init__(self, *args, **kwargs):
        super(RegistrationForm, self).__init__(*args,  **kwargs)
        self.fields['username'].error_messages['required'] = 'Please enter a username.'
        self.fields['email'].error_messages['required'] = 'Please enter your email address.'
        self.fields['email'].error_messages['invalid'] = 'Please enter a valid email address.'
        self.fields['password1'].error_messages['required'] = 'Please enter a password.'
        self.fields['password2'].error_messages['required'] = 'Please enter a password.' 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:9,代碼來源:forms.py

示例5: test_is_registration_form

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def test_is_registration_form(self):
        form = DirigibleRegistrationForm()
        self.assertTrue(isinstance(form, RegistrationForm)) 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:5,代碼來源:test_forms.py

示例6: register

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def register(self, form):
        """
        Save all the fields not included in the standard `RegistrationForm`
        into the JSON `data` field of an `ExtraUserDetail` object
        """
        standard_fields = set(RegistrationForm().fields.keys())
        extra_fields = set(form.fields.keys()).difference(standard_fields)
        # Don't save the user unless we successfully store the extra data
        with transaction.atomic():
            new_user = super().register(form)
            extra_data = {k: form.cleaned_data[k] for k in extra_fields}
            new_user.extra_details.data.update(extra_data)
            new_user.extra_details.save()
        return new_user 
開發者ID:kobotoolbox,項目名稱:kpi,代碼行數:16,代碼來源:views.py

示例7: test_registration_form

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def test_registration_form(self):
        """
        Test that ``RegistrationForm`` enforces username constraints
        and matching passwords.

        """
        # Create a user so we can verify that duplicate usernames aren't
        # permitted.
        User.objects.create_user('alice', 'alice@example.com', 'secret')

        invalid_data_dicts = [
            # Non-alphanumeric username.
            {'data': {'username': 'foo/bar',
                      'email': 'foo@example.com',
                      'password1': 'foo',
                      'password2': 'foo'},
            'error': ('username', [u"This value may contain only letters, numbers and @/./+/-/_ characters."])},
            # Already-existing username.
            {'data': {'username': 'alice',
                      'email': 'alice@example.com',
                      'password1': 'secret',
                      'password2': 'secret'},
            'error': ('username', [u"A user with that username already exists."])},
            # Mismatched passwords.
            {'data': {'username': 'foo',
                      'email': 'foo@example.com',
                      'password1': 'foo',
                      'password2': 'bar'},
            'error': ('__all__', [u"The two password fields didn't match."])},
            ]

        for invalid_dict in invalid_data_dicts:
            with translation.override('en'):
                form = forms.RegistrationForm(data=invalid_dict['data'])
                self.failIf(form.is_valid())
                self.assertEqual(form.errors[invalid_dict['error'][0]],
                                 invalid_dict['error'][1])

        form = forms.RegistrationForm(data={'username': 'foo',
                                            'email': 'foo@example.com',
                                            'password1': 'foo',
                                            'password2': 'foo'})
        self.failUnless(form.is_valid()) 
開發者ID:znick,項目名稱:anytask,代碼行數:45,代碼來源:forms.py

示例8: test_registration_form

# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationForm [as 別名]
def test_registration_form(self):
        """
        Test that ``RegistrationForm`` enforces username constraints
        and matching passwords.

        """
        invalid_data_dicts = [
            # Non-alphanumeric username.
            {
            'data':
            { 'username': 'foo/bar',
              'email': 'foo@example.com',
              'password1': 'foo',
              'password2': 'foo' },
            'error':
            ('username', [u"Enter a valid value."])
            },
            # Already-existing username.
            {
            'data':
            { 'username': 'alice',
              'email': 'alice@example.com',
              'password1': 'secret',
              'password2': 'secret' },
            'error':
            ('username', [u"This username is already taken. Please choose another."])
            },
            # Mismatched passwords.
            {
            'data':
            { 'username': 'foo',
              'email': 'foo@example.com',
              'password1': 'foo',
              'password2': 'bar' },
            'error':
            ('__all__', [u"You must type the same password each time"])
            },
            ]

        for invalid_dict in invalid_data_dicts:
            form = forms.RegistrationForm(data=invalid_dict['data'])
            self.failIf(form.is_valid())
            self.assertEqual(form.errors[invalid_dict['error'][0]], invalid_dict['error'][1])

        form = forms.RegistrationForm(data={ 'username': 'foo',
                                             'email': 'foo@example.com',
                                             'password1': 'foo',
                                             'password2': 'foo' })
        self.failUnless(form.is_valid()) 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:51,代碼來源:tests.py


注:本文中的registration.forms.RegistrationForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。