Ticket #11870: 11870_3.diff

File 11870_3.diff, 3.5 KB (added by Thejaswi Puthraya, 14 years ago)

git patch against the latest checkout with the required tests

  • django/contrib/comments/__init__.py

    diff --git a/django/contrib/comments/__init__.py b/django/contrib/comments/__init__.py
    index 42384e7..4d32af0 100644
    a b  
    11from django.conf import settings
    22from django.core import urlresolvers
    33from django.core.exceptions import ImproperlyConfigured
    4 from django.contrib.comments.models import Comment
    5 from django.contrib.comments.forms import CommentForm
    64from django.utils.importlib import import_module
    75
    86DEFAULT_COMMENTS_APP = 'django.contrib.comments'
    def get_model():  
    4038    if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_model"):
    4139        return get_comment_app().get_model()
    4240    else:
     41        from django.contrib.comments.models import Comment
    4342        return Comment
    4443
    4544def get_form():
    def get_form():  
    4948    if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form"):
    5049        return get_comment_app().get_form()
    5150    else:
     51        from django.contrib.comments.forms import CommentForm
    5252        return CommentForm
    5353
    5454def get_form_target():
  • django/contrib/comments/models.py

    diff --git a/django/contrib/comments/models.py b/django/contrib/comments/models.py
    index 5e128d2..2c5dff4 100644
    a b from django.db import models  
    88from django.core import urlresolvers
    99from django.utils.translation import ugettext_lazy as _
    1010from django.conf import settings
     11from django.contrib.comments import get_model
    1112
    1213COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH',3000)
    1314
    class CommentFlag(models.Model):  
    166167    if you want rating look elsewhere.
    167168    """
    168169    user      = models.ForeignKey(User, verbose_name=_('user'), related_name="comment_flags")
    169     comment   = models.ForeignKey(Comment, verbose_name=_('comment'), related_name="flags")
     170    comment   = models.ForeignKey(get_model(), verbose_name=_('comment'), related_name="flags")
    170171    flag      = models.CharField(_('flag'), max_length=30, db_index=True)
    171172    flag_date = models.DateTimeField(_('date'), default=None)
    172173
  • tests/regressiontests/comment_tests/tests/app_api_tests.py

    diff --git a/tests/regressiontests/comment_tests/tests/app_api_tests.py b/tests/regressiontests/comment_tests/tests/app_api_tests.py
    index c4d9ebf..9e94634 100644
    a b  
    11from django.conf import settings
    22from django.contrib import comments
    3 from django.contrib.comments.models import Comment
     3from django.contrib.comments.models import Comment, CommentFlag
    44from django.contrib.comments.forms import CommentForm
    55from regressiontests.comment_tests.tests import CommentTestCase
    66
    class CommentAppAPITests(CommentTestCase):  
    2828        c = Comment(id=12345)
    2929        self.assertEqual(comments.get_approve_url(c), "/approve/12345/")
    3030
     31    def testCommentFlagCommentModel(self):
     32        self.assertEqual(CommentFlag.comment.field.related.parent_model, Comment)
     33
    3134
    3235class CustomCommentTest(CommentTestCase):
    3336    urls = 'regressiontests.comment_tests.urls'
    class CustomCommentTest(CommentTestCase):  
    6972    def getGetApproveURL(self):
    7073        c = Comment(id=12345)
    7174        self.assertEqual(comments.get_approve_url(c), "/approve/12345/")
     75
     76    def testCommentFlagCommentModel(self):
     77        from regressiontests.comment_tests.custom_comments.models import CustomComment
     78        self.assertEqual(CommentFlag.comment.field.related.parent_model, CustomComment)
     79
Back to Top