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


Python forms.EmailUserCreationForm類代碼示例

本文整理匯總了Python中cards.forms.EmailUserCreationForm的典型用法代碼示例。如果您正苦於以下問題:Python EmailUserCreationForm類的具體用法?Python EmailUserCreationForm怎麽用?Python EmailUserCreationForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_clean_username_exception

    def test_clean_username_exception(self):
        Player.objects.create_user(username='test-user')
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        with self.assertRaises(ValidationError):
            form.clean_username()
開發者ID:broccolirob,項目名稱:deck,代碼行數:7,代碼來源:test_forms.py

示例2: FormTestCase

class FormTestCase(TestCase):
    def setUp(self):
        # Create a player so that this username we're testing is already taken
        self.player = Player.objects.create_user(username='test-user')
        self.form_same_username = EmailUserCreationForm()
        self.form_diff_username = EmailUserCreationForm()

    def test_clean_username_exception(self):
        # set up the form for testing
        self.form_same_username.cleaned_data = {'username': 'test-user'}
        self.form_diff_username.cleaned_data = {'username': 'mike'}
        # use a context manager to watch for the validation error being raised
        with self.assertRaises(ValidationError):
            self.form_same_username.clean_username()
        # asserts clean username is the same as
        self.assertEqual(self.form_diff_username.clean_username(), 'mike')

    def test_register_sends_email(self):
        self.form_diff_username.cleaned_data = {
            'username': 'test',
            'email': '[email protected]',
            'password1': 'test-pw',
            'password2': 'test-pw',
        }
        self.form_diff_username.save()
        # Check there is an email to send
        self.assertEqual(len(mail.outbox), 1)
        # Check the subject is what we expect
        self.assertEqual(mail.outbox[0].subject, 'Welcome!')
開發者ID:mlee284045,項目名稱:playing-cards,代碼行數:29,代碼來源:test_form.py

示例3: test_clean_username

    def test_clean_username(self):
        form = EmailUserCreationForm()
        form.cleaned_data = {
            'username': 'test-user',
        }

        self.assertTrue(form.clean_username() == 'test-user')
開發者ID:broccolirob,項目名稱:deck,代碼行數:7,代碼來源:test_forms.py

示例4: test_clean_username

    def test_clean_username(self):
        # review this again!
        # set up the form for testing
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        # use a context manager to watch for the validation error being raised
        self.assertEquals(form.clean_username(), 'test-user')
開發者ID:masterfung,項目名稱:RocketU-Django,代碼行數:8,代碼來源:tests.py

示例5: test_clean_username_exception

 def test_clean_username_exception(self):
     # Create a player so that this username we're testing is already taken
     Player.objects.create_user(username='test-user')
     # set up the form for testing
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     # use a context manager to watch for the validation error being raised
     with self.assertRaises(ValidationError):
         form.clean_username()
開發者ID:michaelperret,項目名稱:playing-cards,代碼行數:9,代碼來源:tests.py

示例6: test_register_sends_email

 def test_register_sends_email(self):
     form = EmailUserCreationForm()
     form.cleaned_data = {
         'username': 'test',
         'email': '[email protected]',
         'password1': 'test-pw',
         'password2': 'test-pw',
     }
     form.save()
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(mail.outbox[0].subject, 'Welcome!')
開發者ID:brittkistner,項目名稱:playing_cards,代碼行數:11,代碼來源:test_forms.py

示例7: register

def register(request):
    if request.method == 'POST':
        form = EmailUserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect("profile")
    else:
        form = EmailUserCreationForm()

    return render(request, "registration/register.html", {
        'form': form,
    })
開發者ID:amulius,項目名稱:playing-cards,代碼行數:12,代碼來源:views.py

示例8: register

def register(request):
    if request.method == "POST":
        form = EmailUserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            # text_content = 'Thank you for signing up for our website, {}'.format(user.username)
            # html_content = '<h2>Thanks {} for signing up!</h2> <div>I hope you enjoy using our site</div>'
            # .format(user.username)
            # msg = EmailMultiAlternatives("Welcome!", text_content, settings.DEFAULT_FROM_EMAIL, [user.email])
            # msg.attach_alternative(html_content, "text/html")
            # msg.send()
            return redirect("profile")
    else:
        form = EmailUserCreationForm()

    return render(request, "registration/register.html", {"form": form})
開發者ID:roxna,項目名稱:playing-cards,代碼行數:16,代碼來源:views.py

示例9: register

def register(request):
    if request.method == 'POST':
        form = EmailUserCreationForm(request.POST)
        if form.is_valid():
            user = form.save()
            text_content = 'Thank you for signing up for our website, {} {}!'.format(user.first_name, user.last_name)
            html_content = '<h2>Thanks {} {} for signing up!</h2> <div>I hope you enjoy using our site</div>' \
                           '<p>You signed up at {}.</p>'.format(user.first_name, user.last_name, user.date_joined)
            msg = EmailMultiAlternatives("Welcome!", text_content, settings.DEFAULT_FROM_EMAIL, [user.email])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
            return redirect("profile")
    else:
        form = EmailUserCreationForm()

    return render(request, "registration/register.html", {
        'form': form,
    })
開發者ID:masterfung,項目名稱:RocketU-Django,代碼行數:18,代碼來源:views.py

示例10: test_clean_username_ok

 def test_clean_username_ok(self):
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     self.assertEqual(form.clean_username(), 'test-user')
開發者ID:armenarmen,項目名稱:playing-cards,代碼行數:4,代碼來源:tests.py

示例11: test_clean_username

 def test_clean_username(self):
     # set up the form for testing
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     self.assertEquals(form.clean_username(), 'test-user')
開發者ID:brittkistner,項目名稱:playing_cards,代碼行數:5,代碼來源:test_forms.py

示例12: setUp

 def setUp(self):
     # Create a player so that this username we're testing is already taken
     self.player = Player.objects.create_user(username='test-user')
     self.form_same_username = EmailUserCreationForm()
     self.form_diff_username = EmailUserCreationForm()
開發者ID:mlee284045,項目名稱:playing-cards,代碼行數:5,代碼來源:test_form.py

示例13: test_clean_username_success

    def test_clean_username_success(self):
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'testie'}

        # watch for the correct output
        self.assertEqual(form.clean_username(), 'testie')
開發者ID:michaelperret,項目名稱:playing-cards,代碼行數:6,代碼來源:tests.py

示例14: test_clean_username_pass

 def test_clean_username_pass(self):
     Player.objects.create_user(username='bla')
     form = EmailUserCreationForm()
     form.cleaned_data = {'username':'test'}
     self.assertEqual(form.clean_username(), 'test')
開發者ID:kevintandean,項目名稱:playing-cards,代碼行數:5,代碼來源:test.py

示例15: test_clean_username_success

    def test_clean_username_success(self):
        """Test that we get the proper result from username not already taken"""
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        self.assertEqual(form.clean_username(), 'test-user')
開發者ID:kremerben,項目名稱:playing-cards,代碼行數:6,代碼來源:tests.py


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