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


Python CommentForm.is_valid方法代碼示例

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


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

示例1: testProfanities

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
    def testProfanities(self):
        """Test COMMENTS_ALLOW_PROFANITIES and PROFANITIES_LIST settings"""
        a = Article.objects.get(pk=1)
        d = self.getValidData(a)

        # Try with COMMENTS_ALLOW_PROFANITIES off
        with self.settings(COMMENTS_ALLOW_PROFANITIES=False):
            f = CommentForm(a, data=dict(d, comment="What a rooster!"))
            self.assertFalse(f.is_valid())

        # Now with COMMENTS_ALLOW_PROFANITIES on
        with self.settings(COMMENTS_ALLOW_PROFANITIES=True):
            f = CommentForm(a, data=dict(d, comment="What a rooster!"))
            self.assertTrue(f.is_valid())
開發者ID:505Forensics,項目名稱:django,代碼行數:16,代碼來源:test_comment_form.py

示例2: tamperWithForm

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
 def tamperWithForm(self, **kwargs):
     a = Article.objects.get(pk=1)
     d = self.getValidData(a)
     d.update(kwargs)
     f = CommentForm(Article.objects.get(pk=1), data=d)
     self.assertFalse(f.is_valid())
     return f
開發者ID:Aaron1011,項目名稱:oh-mainline,代碼行數:9,代碼來源:comment_form_tests.py

示例3: ajax_comment_post

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
def ajax_comment_post(request):
    print request.POST
    try:
        form = CommentForm(request.POST)
    except Exception as e:
        print e
    print "HERE"
    if form.is_valid():
        form.save()
        return HttpResponse("IT WORKED!")
    return HttpResponse("FAIL!")
開發者ID:AmandaMaxy,項目名稱:Hacksy,代碼行數:13,代碼來源:views.py

示例4: post_comment

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
def post_comment(request):
    if request.method == 'POST':
        prod_id = request.POST['object_pk']
        prod = Product.objects.get(pk=prod_id)
        form = CommentForm(target_object=prod, data=request.POST)
        if form.is_valid():
            form.save()
            return redirect('store_home')
    else:
        form = CommentForm() 
    return render(request, "register.html", {'form': form})
開發者ID:mcrisan,項目名稱:store,代碼行數:13,代碼來源:views.py

示例5: testProfanities

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
    def testProfanities(self):
        """Test COMMENTS_ALLOW_PROFANITIES and PROFANITIES_LIST settings"""
        a = Article.objects.get(pk=1)
        d = self.getValidData(a)

        # Save settings in case other tests need 'em
        saved = settings.PROFANITIES_LIST, settings.COMMENTS_ALLOW_PROFANITIES

        # Don't wanna swear in the unit tests if we don't have to...
        settings.PROFANITIES_LIST = ["rooster"]

        # Try with COMMENTS_ALLOW_PROFANITIES off
        settings.COMMENTS_ALLOW_PROFANITIES = False
        f = CommentForm(a, data=dict(d, comment="What a rooster!"))
        self.assertFalse(f.is_valid())

        # Now with COMMENTS_ALLOW_PROFANITIES on
        settings.COMMENTS_ALLOW_PROFANITIES = True
        f = CommentForm(a, data=dict(d, comment="What a rooster!"))
        self.assertTrue(f.is_valid())

        # Restore settings
        settings.PROFANITIES_LIST, settings.COMMENTS_ALLOW_PROFANITIES = saved
開發者ID:Aaron1011,項目名稱:oh-mainline,代碼行數:25,代碼來源:comment_form_tests.py

示例6: testDjango12Hash

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
    def testDjango12Hash(self):
        # Ensure we can use the hashes generated by Django 1.2
        a = Article.objects.get(pk=1)
        d = self.getValidData(a)

        content_type = d['content_type']
        object_pk = d['object_pk']
        timestamp = d['timestamp']

        # The Django 1.2 method hard-coded here:
        info = (content_type, object_pk, timestamp, settings.SECRET_KEY)
        security_hash = sha_constructor("".join(info)).hexdigest()

        d['security_hash'] = security_hash
        f = CommentForm(a, data=d)
        self.assertTrue(f.is_valid(), f.errors)
開發者ID:Aaron1011,項目名稱:oh-mainline,代碼行數:18,代碼來源:comment_form_tests.py

示例7: testValidPost

# 需要導入模塊: from django.contrib.comments.forms import CommentForm [as 別名]
# 或者: from django.contrib.comments.forms.CommentForm import is_valid [as 別名]
 def testValidPost(self):
     a = Article.objects.get(pk=1)
     f = CommentForm(a, data=self.getValidData(a))
     self.assertTrue(f.is_valid(), f.errors)
     return f
開發者ID:Aaron1011,項目名稱:oh-mainline,代碼行數:7,代碼來源:comment_form_tests.py


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