def get_edit_form(): """ Returns a (new) comment edit form object """ if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_edit_form"): return get_comment_app().get_edit_form() else: return CommentEditForm
def get_edit_form_target(comment): """ Returns the target URL for the comment edit form submission view. """ if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_edit_form_target"): return get_comment_app().get_edit_form_target() else: return urlresolvers.reverse("comments_extension.views.moderation.edit", args=(comment.id,))
def get_edit_modelform(comment): """ Returns the comment ModelForm instance """ if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_edit_modelform"): return get_comment_app().get_edit_modelform() else: return CommentEditForm(instance=comment)
def test_zinnia_trackback(self): setup_test_template_loader({'404.html': ''}) response = self.client.post('/trackback/404/') self.assertEquals(response.status_code, 404) restore_template_loaders() self.assertEquals(self.client.post('/trackback/1/').status_code, 301) self.assertEquals(self.client.get('/trackback/1/').status_code, 301) entry = Entry.objects.get(slug='test-1') self.assertEquals(entry.trackback_count, 0) entry.trackback_enabled = False entry.save() self.assertEquals( self.client.post('/trackback/1/', { 'url': 'http://example.com' }).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>1</error>\n <message>Trackback is not enabled for ' 'Test 1</message>\n \n</response>\n') entry.trackback_enabled = True entry.save() connect_discussion_signals() get_user_flagger() # Memoize user flagger for stable query number if comments.get_comment_app_name() == comments.DEFAULT_COMMENTS_APP: # If we are not using the default comment app, # we can count the database queries executed. with self.assertNumQueries(6): self.assertEquals( self.client.post('/trackback/1/', { 'url': 'http://example.com' }).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>0</error>\n \n</response>\n') else: self.assertEquals( self.client.post('/trackback/1/', { 'url': 'http://example.com' }).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>0</error>\n \n</response>\n') disconnect_discussion_signals() entry = Entry.objects.get(pk=entry.pk) self.assertEquals(entry.trackback_count, 1) self.assertEquals( self.client.post('/trackback/1/', { 'url': 'http://example.com' }).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>1</error>\n <message>Trackback is already registered' '</message>\n \n</response>\n')
def test_zinnia_trackback(self): setup_test_template_loader( {'404.html': ''}) response = self.client.post('/trackback/404/') self.assertEquals(response.status_code, 404) restore_template_loaders() self.assertEquals( self.client.post('/trackback/1/').status_code, 301) self.assertEquals( self.client.get('/trackback/1/').status_code, 301) entry = Entry.objects.get(slug='test-1') self.assertEquals(entry.trackback_count, 0) entry.trackback_enabled = False entry.save() self.assertEquals( self.client.post('/trackback/1/', {'url': 'http://example.com'}).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>1</error>\n <message>Trackback is not enabled for ' 'Test 1</message>\n \n</response>\n') entry.trackback_enabled = True entry.save() connect_discussion_signals() get_user_flagger() # Memoize user flagger for stable query number if comments.get_comment_app_name() == comments.DEFAULT_COMMENTS_APP: # If we are not using the default comment app, # we can count the database queries executed. with self.assertNumQueries(6): self.assertEquals( self.client.post('/trackback/1/', {'url': 'http://example.com'}).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n' ' <error>0</error>\n \n</response>\n') else: self.assertEquals( self.client.post('/trackback/1/', {'url': 'http://example.com'}).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>0</error>\n \n</response>\n') disconnect_discussion_signals() entry = Entry.objects.get(pk=entry.pk) self.assertEquals(entry.trackback_count, 1) self.assertEquals( self.client.post('/trackback/1/', {'url': 'http://example.com'}).content, '<?xml version="1.0" encoding="utf-8"?>\n<response>\n \n ' '<error>1</error>\n <message>Trackback is already registered' '</message>\n \n</response>\n')
def test_zinnia_trackback(self): self.inhibit_templates('zinnia/entry_trackback.xml', '404.html') response = self.client.post('/trackback/404/') self.assertEquals(response.status_code, 404) self.assertEquals( self.client.post('/trackback/1/').status_code, 301) entry = Entry.objects.get(slug='test-1') entry.trackback_enabled = False entry.save() self.assertEquals(entry.trackback_count, 0) response = self.client.post('/trackback/1/', {'url': 'http://example.com'}) self.assertEquals(response['Content-Type'], 'text/xml') self.assertEquals(response.context['error'], 'Trackback is not enabled for Test 1') entry.trackback_enabled = True entry.save() connect_discussion_signals() get_user_flagger() # Memoize user flagger for stable query number if comments.get_comment_app_name() == comments.DEFAULT_COMMENTS_APP: # If we are using the default comment app, # we can count the database queries executed. with self.assertNumQueries(6): response = self.client.post('/trackback/1/', {'url': 'http://example.com'}) else: response = self.client.post('/trackback/1/', {'url': 'http://example.com'}) self.assertEquals(response['Content-Type'], 'text/xml') self.assertEquals('error' in response.context, False) disconnect_discussion_signals() entry = Entry.objects.get(pk=entry.pk) self.assertEquals(entry.trackback_count, 1) response = self.client.post('/trackback/1/', {'url': 'http://example.com'}) self.assertEquals(response.context['error'], 'Trackback is already registered')