Commit 74c3e3b5e5adf20c4d2a8fe3c98be82454332231

Authored by Jacob Kaplan-Moss
1 parent a457ae4b

Stubbed out a setup.py and a test runner.

Showing 40 changed files with 211 additions and 82 deletions
  1 +*.pyc
  1 +Copyright (c) 2013, Django Software Foundation and individual contributors
  2 +
  3 +All rights reserved.
  4 +
  5 +Redistribution and use in source and binary forms, with or without modification,
  6 +are permitted provided that the following conditions are met:
  7 +
  8 + * Redistributions of source code must retain the above copyright notice,
  9 + this list of conditions and the following disclaimer.
  10 + * Redistributions in binary form must reproduce the above copyright notice,
  11 + this list of conditions and the following disclaimer in the documentation
  12 + and/or other materials provided with the distribution.
  13 + * Neither the name of django-contrib-comments nor the names of its contributors
  14 + may be used to endorse or promote products derived from this software
  15 + without specific prior written permission.
  16 +
  17 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  21 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  22 +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  23 +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24 +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  25 +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  26 +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1 +FIXME
1 -import warnings  
2 from django.conf import settings 1 from django.conf import settings
3 from django.core import urlresolvers 2 from django.core import urlresolvers
4 from django.core.exceptions import ImproperlyConfigured 3 from django.core.exceptions import ImproperlyConfigured
5 -from django.contrib.comments.models import Comment  
6 -from django.contrib.comments.forms import CommentForm  
7 from django.utils.importlib import import_module 4 from django.utils.importlib import import_module
8 5
9 -warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning) 6 +from django_comments.models import Comment
  7 +from django_comments.forms import CommentForm
10 8
11 -DEFAULT_COMMENTS_APP = 'django.contrib.comments' 9 +DEFAULT_COMMENTS_APP = 'django_comments'
12 10
13 def get_comment_app(): 11 def get_comment_app():
14 """ 12 """
15 - Get the comment app (i.e. "django.contrib.comments") as defined in the settings 13 + Get the comment app (i.e. "django_comments") as defined in the settings
16 """ 14 """
17 # Make sure the app's in INSTALLED_APPS 15 # Make sure the app's in INSTALLED_APPS
18 comments_app = get_comment_app_name() 16 comments_app = get_comment_app_name()
@@ -61,7 +59,7 @@ def get_form_target(): @@ -61,7 +59,7 @@ def get_form_target():
61 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form_target"): 59 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form_target"):
62 return get_comment_app().get_form_target() 60 return get_comment_app().get_form_target()
63 else: 61 else:
64 - return urlresolvers.reverse("django.contrib.comments.views.comments.post_comment") 62 + return urlresolvers.reverse("django_comments.views.comments.post_comment")
65 63
66 def get_flag_url(comment): 64 def get_flag_url(comment):
67 """ 65 """
@@ -70,7 +68,7 @@ def get_flag_url(comment): @@ -70,7 +68,7 @@ def get_flag_url(comment):
70 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_flag_url"): 68 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_flag_url"):
71 return get_comment_app().get_flag_url(comment) 69 return get_comment_app().get_flag_url(comment)
72 else: 70 else:
73 - return urlresolvers.reverse("django.contrib.comments.views.moderation.flag", 71 + return urlresolvers.reverse("django_comments.views.moderation.flag",
74 args=(comment.id,)) 72 args=(comment.id,))
75 73
76 def get_delete_url(comment): 74 def get_delete_url(comment):
@@ -80,7 +78,7 @@ def get_delete_url(comment): @@ -80,7 +78,7 @@ def get_delete_url(comment):
80 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_delete_url"): 78 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_delete_url"):
81 return get_comment_app().get_delete_url(comment) 79 return get_comment_app().get_delete_url(comment)
82 else: 80 else:
83 - return urlresolvers.reverse("django.contrib.comments.views.moderation.delete", 81 + return urlresolvers.reverse("django_comments.views.moderation.delete",
84 args=(comment.id,)) 82 args=(comment.id,))
85 83
86 def get_approve_url(comment): 84 def get_approve_url(comment):
@@ -90,5 +88,5 @@ def get_approve_url(comment): @@ -90,5 +88,5 @@ def get_approve_url(comment):
90 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_approve_url"): 88 if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_approve_url"):
91 return get_comment_app().get_approve_url(comment) 89 return get_comment_app().get_approve_url(comment)
92 else: 90 else:
93 - return urlresolvers.reverse("django.contrib.comments.views.moderation.approve", 91 + return urlresolvers.reverse("django_comments.views.moderation.approve",
94 args=(comment.id,)) 92 args=(comment.id,))
@@ -2,11 +2,11 @@ from __future__ import unicode_literals @@ -2,11 +2,11 @@ from __future__ import unicode_literals
2 2
3 from django.contrib import admin 3 from django.contrib import admin
4 from django.contrib.auth import get_user_model 4 from django.contrib.auth import get_user_model
5 -from django.contrib.comments.models import Comment  
6 from django.utils.translation import ugettext_lazy as _, ungettext, ungettext_lazy 5 from django.utils.translation import ugettext_lazy as _, ungettext, ungettext_lazy
7 -from django.contrib.comments import get_model  
8 from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete 6 from django.contrib.comments.views.moderation import perform_flag, perform_approve, perform_delete
9 7
  8 +from django_comments import get_model
  9 +from django_comments.models import Comment
10 10
11 class UsernameSearch(object): 11 class UsernameSearch(object):
12 """The User object may not be auth.User, so we need to provide 12 """The User object may not be auth.User, so we need to provide
1 from django.contrib.syndication.views import Feed 1 from django.contrib.syndication.views import Feed
2 from django.contrib.sites.models import get_current_site 2 from django.contrib.sites.models import get_current_site
3 -from django.contrib import comments  
4 from django.utils.translation import ugettext as _ 3 from django.utils.translation import ugettext as _
5 4
  5 +import django_comments
  6 +
6 class LatestCommentFeed(Feed): 7 class LatestCommentFeed(Feed):
7 """Feed of latest comments on the current site.""" 8 """Feed of latest comments on the current site."""
8 9
@@ -20,7 +21,7 @@ class LatestCommentFeed(Feed): @@ -20,7 +21,7 @@ class LatestCommentFeed(Feed):
20 return _("Latest comments on %(site_name)s") % dict(site_name=self.site.name) 21 return _("Latest comments on %(site_name)s") % dict(site_name=self.site.name)
21 22
22 def items(self): 23 def items(self):
23 - qs = comments.get_model().objects.filter( 24 + qs = django_comments.get_model().objects.filter(
24 site__pk = self.site.pk, 25 site__pk = self.site.pk,
25 is_public = True, 26 is_public = True,
26 is_removed = False, 27 is_removed = False,
@@ -3,13 +3,14 @@ from django import forms @@ -3,13 +3,14 @@ from django import forms
3 from django.forms.util import ErrorDict 3 from django.forms.util import ErrorDict
4 from django.conf import settings 4 from django.conf import settings
5 from django.contrib.contenttypes.models import ContentType 5 from django.contrib.contenttypes.models import ContentType
6 -from django.contrib.comments.models import Comment  
7 from django.utils.crypto import salted_hmac, constant_time_compare 6 from django.utils.crypto import salted_hmac, constant_time_compare
8 from django.utils.encoding import force_text 7 from django.utils.encoding import force_text
9 from django.utils.text import get_text_list 8 from django.utils.text import get_text_list
10 from django.utils import timezone 9 from django.utils import timezone
11 from django.utils.translation import ungettext, ugettext, ugettext_lazy as _ 10 from django.utils.translation import ungettext, ugettext, ugettext_lazy as _
12 11
  12 +from django_comments.models import Comment
  13 +
13 COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH', 3000) 14 COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH', 3000)
14 15
15 class CommentSecurityForm(forms.Form): 16 class CommentSecurityForm(forms.Form):
1 from django.conf import settings 1 from django.conf import settings
2 -from django.contrib.comments.managers import CommentManager  
3 from django.contrib.contenttypes import generic 2 from django.contrib.contenttypes import generic
4 from django.contrib.contenttypes.models import ContentType 3 from django.contrib.contenttypes.models import ContentType
5 from django.contrib.sites.models import Site 4 from django.contrib.sites.models import Site
@@ -9,6 +8,8 @@ from django.utils.translation import ugettext_lazy as _ @@ -9,6 +8,8 @@ from django.utils.translation import ugettext_lazy as _
9 from django.utils import timezone 8 from django.utils import timezone
10 from django.utils.encoding import python_2_unicode_compatible 9 from django.utils.encoding import python_2_unicode_compatible
11 10
  11 +from django_comments.managers import CommentManager
  12 +
12 COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000) 13 COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000)
13 14
14 15
@@ -29,7 +29,7 @@ a Weblog:: @@ -29,7 +29,7 @@ a Weblog::
29 Then we create a ``CommentModerator`` subclass specifying some 29 Then we create a ``CommentModerator`` subclass specifying some
30 moderation options:: 30 moderation options::
31 31
32 - from django.contrib.comments.moderation import CommentModerator, moderator 32 + from django_comments.moderation import CommentModerator, moderator
33 33
34 class EntryModerator(CommentModerator): 34 class EntryModerator(CommentModerator):
35 email_notification = True 35 email_notification = True
@@ -58,13 +58,14 @@ import datetime @@ -58,13 +58,14 @@ import datetime
58 58
59 from django.conf import settings 59 from django.conf import settings
60 from django.core.mail import send_mail 60 from django.core.mail import send_mail
61 -from django.contrib.comments import signals  
62 from django.db.models.base import ModelBase 61 from django.db.models.base import ModelBase
63 from django.template import Context, loader 62 from django.template import Context, loader
64 -from django.contrib import comments  
65 from django.contrib.sites.models import get_current_site 63 from django.contrib.sites.models import get_current_site
66 from django.utils import timezone 64 from django.utils import timezone
67 65
  66 +import django_comments
  67 +from django_comments import signals
  68 +
68 class AlreadyModerated(Exception): 69 class AlreadyModerated(Exception):
69 """ 70 """
70 Raised when a model which is already registered for moderation is 71 Raised when a model which is already registered for moderation is
@@ -286,8 +287,8 @@ class Moderator(object): @@ -286,8 +287,8 @@ class Moderator(object):
286 from the comment models. 287 from the comment models.
287 288
288 """ 289 """
289 - signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())  
290 - signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model()) 290 + signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=django_comments.get_model())
  291 + signals.comment_was_posted.connect(self.post_save_moderation, sender=django_comments.get_model())
291 292
292 def register(self, model_or_iterable, moderation_class): 293 def register(self, model_or_iterable, moderation_class):
293 """ 294 """
@@ -2,11 +2,12 @@ from django import template @@ -2,11 +2,12 @@ from django import template
2 from django.template.loader import render_to_string 2 from django.template.loader import render_to_string
3 from django.conf import settings 3 from django.conf import settings
4 from django.contrib.contenttypes.models import ContentType 4 from django.contrib.contenttypes.models import ContentType
5 -from django.contrib import comments  
6 from django.utils import six 5 from django.utils import six
7 from django.utils.deprecation import RenameMethodsBase 6 from django.utils.deprecation import RenameMethodsBase
8 from django.utils.encoding import smart_text 7 from django.utils.encoding import smart_text
9 8
  9 +import django_comments
  10 +
10 register = template.Library() 11 register = template.Library()
11 12
12 13
@@ -65,7 +66,7 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template. @@ -65,7 +66,7 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
65 def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None): 66 def __init__(self, ctype=None, object_pk_expr=None, object_expr=None, as_varname=None, comment=None):
66 if ctype is None and object_expr is None: 67 if ctype is None and object_expr is None:
67 raise template.TemplateSyntaxError("Comment nodes must be given either a literal object or a ctype and object pk.") 68 raise template.TemplateSyntaxError("Comment nodes must be given either a literal object or a ctype and object pk.")
68 - self.comment_model = comments.get_model() 69 + self.comment_model = django_comments.get_model()
69 self.as_varname = as_varname 70 self.as_varname = as_varname
70 self.ctype = ctype 71 self.ctype = ctype
71 self.object_pk_expr = object_pk_expr 72 self.object_pk_expr = object_pk_expr
@@ -130,7 +131,7 @@ class CommentFormNode(BaseCommentNode): @@ -130,7 +131,7 @@ class CommentFormNode(BaseCommentNode):
130 def get_form(self, context): 131 def get_form(self, context):
131 obj = self.get_object(context) 132 obj = self.get_object(context)
132 if obj: 133 if obj:
133 - return comments.get_form()(obj) 134 + return django_comments.get_form()(obj)
134 else: 135 else:
135 return None 136 return None
136 137
@@ -323,7 +324,7 @@ def comment_form_target(): @@ -323,7 +324,7 @@ def comment_form_target():
323 324
324 <form action="{% comment_form_target %}" method="post"> 325 <form action="{% comment_form_target %}" method="post">
325 """ 326 """
326 - return comments.get_form_target() 327 + return django_comments.get_form_target()
327 328
328 @register.simple_tag 329 @register.simple_tag
329 def get_comment_permalink(comment, anchor_pattern=None): 330 def get_comment_permalink(comment, anchor_pattern=None):
1 from django.conf.urls import patterns, url 1 from django.conf.urls import patterns, url
2 2
3 -urlpatterns = patterns('django.contrib.comments.views', 3 +urlpatterns = patterns('django_comments.views',
4 url(r'^post/$', 'comments.post_comment', name='comments-post-comment'), 4 url(r'^post/$', 'comments.post_comment', name='comments-post-comment'),
5 url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'), 5 url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'),
6 url(r'^flag/(\d+)/$', 'moderation.flag', name='comments-flag'), 6 url(r'^flag/(\d+)/$', 'moderation.flag', name='comments-flag'),
@@ -2,9 +2,6 @@ from __future__ import absolute_import @@ -2,9 +2,6 @@ from __future__ import absolute_import
2 2
3 from django import http 3 from django import http
4 from django.conf import settings 4 from django.conf import settings
5 -from django.contrib import comments  
6 -from django.contrib.comments import signals  
7 -from django.contrib.comments.views.utils import next_redirect, confirmation_view  
8 from django.core.exceptions import ObjectDoesNotExist, ValidationError 5 from django.core.exceptions import ObjectDoesNotExist, ValidationError
9 from django.db import models 6 from django.db import models
10 from django.shortcuts import render_to_response 7 from django.shortcuts import render_to_response
@@ -14,6 +11,9 @@ from django.utils.html import escape @@ -14,6 +11,9 @@ from django.utils.html import escape
14 from django.views.decorators.csrf import csrf_protect 11 from django.views.decorators.csrf import csrf_protect
15 from django.views.decorators.http import require_POST 12 from django.views.decorators.http import require_POST
16 13
  14 +import django_comments
  15 +from django_comments import signals
  16 +from django_comments.views.utils import next_redirect, confirmation_view
17 17
18 class CommentPostBadRequest(http.HttpResponseBadRequest): 18 class CommentPostBadRequest(http.HttpResponseBadRequest):
19 """ 19 """
@@ -72,7 +72,7 @@ def post_comment(request, next=None, using=None): @@ -72,7 +72,7 @@ def post_comment(request, next=None, using=None):
72 preview = "preview" in data 72 preview = "preview" in data
73 73
74 # Construct the comment form 74 # Construct the comment form
75 - form = comments.get_form()(target, data=data) 75 + form = django_comments.get_form()(target, data=data)
76 76
77 # Check security information 77 # Check security information
78 if form.security_errors(): 78 if form.security_errors():
@@ -2,13 +2,13 @@ from __future__ import absolute_import @@ -2,13 +2,13 @@ from __future__ import absolute_import
2 2
3 from django import template 3 from django import template
4 from django.conf import settings 4 from django.conf import settings
5 -from django.contrib import comments  
6 from django.contrib.auth.decorators import login_required, permission_required 5 from django.contrib.auth.decorators import login_required, permission_required
7 -from django.contrib.comments import signals  
8 -from django.contrib.comments.views.utils import next_redirect, confirmation_view  
9 from django.shortcuts import get_object_or_404, render_to_response 6 from django.shortcuts import get_object_or_404, render_to_response
10 from django.views.decorators.csrf import csrf_protect 7 from django.views.decorators.csrf import csrf_protect
11 8
  9 +import django_comments
  10 +from django_comments import signals
  11 +from django_comments.views.utils import next_redirect, confirmation_view
12 12
13 @csrf_protect 13 @csrf_protect
14 @login_required 14 @login_required
@@ -21,7 +21,7 @@ def flag(request, comment_id, next=None): @@ -21,7 +21,7 @@ def flag(request, comment_id, next=None):
21 comment 21 comment
22 the flagged `comments.comment` object 22 the flagged `comments.comment` object
23 """ 23 """
24 - comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID) 24 + comment = get_object_or_404(django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)
25 25
26 # Flag on POST 26 # Flag on POST
27 if request.method == 'POST': 27 if request.method == 'POST':
@@ -48,7 +48,7 @@ def delete(request, comment_id, next=None): @@ -48,7 +48,7 @@ def delete(request, comment_id, next=None):
48 comment 48 comment
49 the flagged `comments.comment` object 49 the flagged `comments.comment` object
50 """ 50 """
51 - comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID) 51 + comment = get_object_or_404(django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)
52 52
53 # Delete on POST 53 # Delete on POST
54 if request.method == 'POST': 54 if request.method == 'POST':
@@ -76,7 +76,7 @@ def approve(request, comment_id, next=None): @@ -76,7 +76,7 @@ def approve(request, comment_id, next=None):
76 comment 76 comment
77 the `comments.comment` object for approval 77 the `comments.comment` object for approval
78 """ 78 """
79 - comment = get_object_or_404(comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID) 79 + comment = get_object_or_404(django_comments.get_model(), pk=comment_id, site__pk=settings.SITE_ID)
80 80
81 # Delete on POST 81 # Delete on POST
82 if request.method == 'POST': 82 if request.method == 'POST':
@@ -100,10 +100,10 @@ def perform_flag(request, comment): @@ -100,10 +100,10 @@ def perform_flag(request, comment):
100 """ 100 """
101 Actually perform the flagging of a comment from a request. 101 Actually perform the flagging of a comment from a request.
102 """ 102 """
103 - flag, created = comments.models.CommentFlag.objects.get_or_create( 103 + flag, created = django_comments.models.CommentFlag.objects.get_or_create(
104 comment = comment, 104 comment = comment,
105 user = request.user, 105 user = request.user,
106 - flag = comments.models.CommentFlag.SUGGEST_REMOVAL 106 + flag = django_comments.models.CommentFlag.SUGGEST_REMOVAL
107 ) 107 )
108 signals.comment_was_flagged.send( 108 signals.comment_was_flagged.send(
109 sender = comment.__class__, 109 sender = comment.__class__,
@@ -114,10 +114,10 @@ def perform_flag(request, comment): @@ -114,10 +114,10 @@ def perform_flag(request, comment):
114 ) 114 )
115 115
116 def perform_delete(request, comment): 116 def perform_delete(request, comment):
117 - flag, created = comments.models.CommentFlag.objects.get_or_create( 117 + flag, created = django_comments.models.CommentFlag.objects.get_or_create(
118 comment = comment, 118 comment = comment,
119 user = request.user, 119 user = request.user,
120 - flag = comments.models.CommentFlag.MODERATOR_DELETION 120 + flag = django_comments.models.CommentFlag.MODERATOR_DELETION
121 ) 121 )
122 comment.is_removed = True 122 comment.is_removed = True
123 comment.save() 123 comment.save()
@@ -131,10 +131,10 @@ def perform_delete(request, comment): @@ -131,10 +131,10 @@ def perform_delete(request, comment):
131 131
132 132
133 def perform_approve(request, comment): 133 def perform_approve(request, comment):
134 - flag, created = comments.models.CommentFlag.objects.get_or_create( 134 + flag, created = django_comments.models.CommentFlag.objects.get_or_create(
135 comment = comment, 135 comment = comment,
136 user = request.user, 136 user = request.user,
137 - flag = comments.models.CommentFlag.MODERATOR_APPROVAL, 137 + flag = django_comments.models.CommentFlag.MODERATOR_APPROVAL,
138 ) 138 )
139 139
140 comment.is_removed = False 140 comment.is_removed = False
@@ -12,9 +12,10 @@ from django.http import HttpResponseRedirect @@ -12,9 +12,10 @@ from django.http import HttpResponseRedirect
12 from django.shortcuts import render_to_response, resolve_url 12 from django.shortcuts import render_to_response, resolve_url
13 from django.template import RequestContext 13 from django.template import RequestContext
14 from django.core.exceptions import ObjectDoesNotExist 14 from django.core.exceptions import ObjectDoesNotExist
15 -from django.contrib import comments  
16 from django.utils.http import is_safe_url 15 from django.utils.http import is_safe_url
17 16
  17 +import django_comments
  18 +
18 def next_redirect(request, fallback, **get_kwargs): 19 def next_redirect(request, fallback, **get_kwargs):
19 """ 20 """
20 Handle the "where should I go next?" part of comment views. 21 Handle the "where should I go next?" part of comment views.
@@ -50,7 +51,7 @@ def confirmation_view(template, doc="Display a confirmation view."): @@ -50,7 +51,7 @@ def confirmation_view(template, doc="Display a confirmation view."):
50 comment = None 51 comment = None
51 if 'c' in request.GET: 52 if 'c' in request.GET:
52 try: 53 try:
53 - comment = comments.get_model().objects.get(pk=request.GET['c']) 54 + comment = django_comments.get_model().objects.get(pk=request.GET['c'])
54 except (ObjectDoesNotExist, ValueError): 55 except (ObjectDoesNotExist, ValueError):
55 pass 56 pass
56 return render_to_response(template, 57 return render_to_response(template,
  1 +Metadata-Version: 1.1
  2 +Name: django-contrib.comments
  3 +Version: 1.5
  4 +Summary: The code formally known as django.contrib.comments.
  5 +Home-page: http://github.com/django/django-contrib-comments
  6 +Author: Django Software Foundation
  7 +Author-email: jacob@jacobian.org
  8 +License: BSD
  9 +Description: UNKNOWN
  10 +Platform: any
  11 +Classifier: Development Status :: 5 - Production/Stable
  12 +Classifier: Environment :: Web Environment
  13 +Classifier: Framework :: Django
  14 +Classifier: Intended Audience :: Developers
  15 +Classifier: Natural Language :: English
  16 +Classifier: License :: OSI Approved :: BSD License
  17 +Classifier: Operating System :: OS Independent
  18 +Classifier: Programming Language :: Python
  19 +Classifier: Programming Language :: Python :: 2.6
  20 +Classifier: Programming Language :: Python :: 2.7
  21 +Classifier: Programming Language :: Python :: 3
  22 +Classifier: Programming Language :: Python :: 3.2
  23 +Classifier: Programming Language :: Python :: 3.3
  1 +README.txt
  2 +setup.py
  3 +django_comments/__init__.py
  4 +django_comments/admin.py
  5 +django_comments/feeds.py
  6 +django_comments/forms.py
  7 +django_comments/managers.py
  8 +django_comments/models.py
  9 +django_comments/moderation.py
  10 +django_comments/signals.py
  11 +django_comments/urls.py
  12 +django_comments/templatetags/__init__.py
  13 +django_comments/templatetags/comments.py
  14 +django_comments/views/__init__.py
  15 +django_comments/views/comments.py
  16 +django_comments/views/moderation.py
  17 +django_comments/views/utils.py
  18 +django_contrib.comments.egg-info/PKG-INFO
  19 +django_contrib.comments.egg-info/SOURCES.txt
  20 +django_contrib.comments.egg-info/dependency_links.txt
  21 +django_contrib.comments.egg-info/top_level.txt
  22 +tests/custom_comments/__init__.py
  23 +tests/custom_comments/forms.py
  24 +tests/custom_comments/models.py
  25 +tests/custom_comments/views.py
@@ -2,19 +2,7 @@ @@ -2,19 +2,7 @@
2 Customizing the comments framework 2 Customizing the comments framework
3 ================================== 3 ==================================
4 4
5 -.. currentmodule:: django.contrib.comments  
6 -  
7 -.. warning::  
8 -  
9 - Django's comment framework has been deprecated and is no longer supported.  
10 - Most users will be better served with a custom solution, or a hosted  
11 - product like Disqus__.  
12 -  
13 - The code formerly known as ``django.contrib.comments`` is `still available  
14 - in an external repository`__.  
15 -  
16 - __ https://disqus.com/  
17 - __ https://github.com/django/django-contrib-comments 5 +.. currentmodule:: django_comments
18 6
19 If the built-in comment framework doesn't quite fit your needs, you can extend 7 If the built-in comment framework doesn't quite fit your needs, you can extend
20 the comment app's behavior to add custom data and logic. The comments framework 8 the comment app's behavior to add custom data and logic. The comments framework
@@ -73,15 +61,15 @@ the ``my_comment_app`` directory:: @@ -73,15 +61,15 @@ the ``my_comment_app`` directory::
73 In the ``models.py`` we'll define a ``CommentWithTitle`` model:: 61 In the ``models.py`` we'll define a ``CommentWithTitle`` model::
74 62
75 from django.db import models 63 from django.db import models
76 - from django.contrib.comments.models import Comment 64 + from django_comments.models import Comment
77 65
78 class CommentWithTitle(Comment): 66 class CommentWithTitle(Comment):
79 title = models.CharField(max_length=300) 67 title = models.CharField(max_length=300)
80 68
81 Most custom comment models will subclass the 69 Most custom comment models will subclass the
82 -:class:`~django.contrib.comments.models.Comment` model. However, 70 +:class:`~django_comments.models.Comment` model. However,
83 if you want to substantially remove or change the fields available in the 71 if you want to substantially remove or change the fields available in the
84 -:class:`~django.contrib.comments.models.Comment` model, but don't want to 72 +:class:`~django_comments.models.Comment` model, but don't want to
85 rewrite the templates, you could try subclassing from 73 rewrite the templates, you could try subclassing from
86 ``BaseCommentAbstractModel``. 74 ``BaseCommentAbstractModel``.
87 75
@@ -92,7 +80,7 @@ tricky: we have to both create a form and override @@ -92,7 +80,7 @@ tricky: we have to both create a form and override
92 field:: 80 field::
93 81
94 from django import forms 82 from django import forms
95 - from django.contrib.comments.forms import CommentForm 83 + from django_comments.forms import CommentForm
96 from my_comment_app.models import CommentWithTitle 84 from my_comment_app.models import CommentWithTitle
97 85
98 class CommentFormWithTitle(CommentForm): 86 class CommentFormWithTitle(CommentForm):
@@ -109,7 +97,7 @@ field:: @@ -109,7 +97,7 @@ field::
109 return data 97 return data
110 98
111 Django provides a couple of "helper" classes to make writing certain types of 99 Django provides a couple of "helper" classes to make writing certain types of
112 -custom comment forms easier; see :mod:`django.contrib.comments.forms` for 100 +custom comment forms easier; see :mod:`django_comments.forms` for
113 more. 101 more.
114 102
115 Finally, we'll define a couple of methods in ``my_comment_app/__init__.py`` to 103 Finally, we'll define a couple of methods in ``my_comment_app/__init__.py`` to
@@ -145,7 +133,7 @@ explained in the next section. @@ -145,7 +133,7 @@ explained in the next section.
145 Custom comment app API 133 Custom comment app API
146 ====================== 134 ======================
147 135
148 -The :mod:`django.contrib.comments` app defines the following methods; any 136 +The :mod:`django_comments` app defines the following methods; any
149 custom comment app must define at least one of them. All are optional, 137 custom comment app must define at least one of them. All are optional,
150 however. 138 however.
151 139
@@ -153,11 +141,11 @@ however. @@ -153,11 +141,11 @@ however.
153 141
154 Return the :class:`~django.db.models.Model` class to use for comments. This 142 Return the :class:`~django.db.models.Model` class to use for comments. This
155 model should inherit from 143 model should inherit from
156 - ``django.contrib.comments.models.BaseCommentAbstractModel``, which 144 + ``django_comments.models.BaseCommentAbstractModel``, which
157 defines necessary core fields. 145 defines necessary core fields.
158 146
159 The default implementation returns 147 The default implementation returns
160 - :class:`django.contrib.comments.models.Comment`. 148 + :class:`django_comments.models.Comment`.
161 149
162 .. function:: get_form() 150 .. function:: get_form()
163 151
@@ -168,7 +156,7 @@ however. @@ -168,7 +156,7 @@ however.
168 attached to. 156 attached to.
169 157
170 The default implementation returns 158 The default implementation returns
171 - :class:`django.contrib.comments.forms.CommentForm`. 159 + :class:`django_comments.forms.CommentForm`.
172 160
173 .. note:: 161 .. note::
174 162
@@ -192,25 +180,25 @@ however. @@ -192,25 +180,25 @@ however.
192 want to use the default ``post_comment()`` view, you will 180 want to use the default ``post_comment()`` view, you will
193 need to be aware that it requires the model and form to have 181 need to be aware that it requires the model and form to have
194 certain additional attributes and methods: see the 182 certain additional attributes and methods: see the
195 - ``django.contrib.comments.views.post_comment()`` view for details. 183 + ``django_comments.views.post_comment()`` view for details.
196 184
197 .. function:: get_flag_url() 185 .. function:: get_flag_url()
198 186
199 Return the URL for the "flag this comment" view. 187 Return the URL for the "flag this comment" view.
200 188
201 The default implementation returns a reverse-resolved URL pointing 189 The default implementation returns a reverse-resolved URL pointing
202 - to the ``django.contrib.comments.views.moderation.flag()`` view. 190 + to the ``django_comments.views.moderation.flag()`` view.
203 191
204 .. function:: get_delete_url() 192 .. function:: get_delete_url()
205 193
206 Return the URL for the "delete this comment" view. 194 Return the URL for the "delete this comment" view.
207 195
208 The default implementation returns a reverse-resolved URL pointing 196 The default implementation returns a reverse-resolved URL pointing
209 - to the ``django.contrib.comments.views.moderation.delete()`` view. 197 + to the ``django_comments.views.moderation.delete()`` view.
210 198
211 .. function:: get_approve_url() 199 .. function:: get_approve_url()
212 200
213 Return the URL for the "approve this comment from moderation" view. 201 Return the URL for the "approve this comment from moderation" view.
214 202
215 The default implementation returns a reverse-resolved URL pointing 203 The default implementation returns a reverse-resolved URL pointing
216 - to the ``django.contrib.comments.views.moderation.approve()`` view. 204 + to the ``django_comments.views.moderation.approve()`` view.
@@ -4,18 +4,6 @@ @@ -4,18 +4,6 @@
4 Example of using the built-in comments app 4 Example of using the built-in comments app
5 =========================================== 5 ===========================================
6 6
7 -.. warning::  
8 -  
9 - Django's comment framework has been deprecated and is no longer supported.  
10 - Most users will be better served with a custom solution, or a hosted  
11 - product like Disqus__.  
12 -  
13 - The code formerly known as ``django.contrib.comments`` is `still available  
14 - in an external repository`__.  
15 -  
16 - __ https://disqus.com/  
17 - __ https://github.com/django/django-contrib-comments  
18 -  
19 Follow the first three steps of the quick start guide in the 7 Follow the first three steps of the quick start guide in the
20 :doc:`documentation </ref/contrib/comments/index>`. 8 :doc:`documentation </ref/contrib/comments/index>`.
21 9
  1 +import os
  2 +from setuptools import setup, find_packages
  3 +
  4 +try:
  5 + f = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
  6 + long_description = f.read().strip()
  7 + f.close()
  8 +except IOError:
  9 + long_description = None
  10 +
  11 +setup(
  12 + name='django-contrib.comments',
  13 + version='1.5',
  14 + url="http://github.com/django/django-contrib-comments",
  15 + description='The code formally known as django.contrib.comments.',
  16 + long_description=long_description,
  17 + author='Django Software Foundation',
  18 + author_email='jacob@jacobian.org',
  19 + license='BSD',
  20 + platforms='any',
  21 + classifiers=[
  22 + 'Development Status :: 5 - Production/Stable',
  23 + 'Environment :: Web Environment',
  24 + 'Framework :: Django',
  25 + 'Intended Audience :: Developers',
  26 + 'Natural Language :: English',
  27 + 'License :: OSI Approved :: BSD License',
  28 + 'Operating System :: OS Independent',
  29 + 'Programming Language :: Python',
  30 + 'Programming Language :: Python :: 2.6',
  31 + 'Programming Language :: Python :: 2.7',
  32 + 'Programming Language :: Python :: 3',
  33 + 'Programming Language :: Python :: 3.2',
  34 + 'Programming Language :: Python :: 3.3',
  35 + ],
  36 + packages=find_packages(exclude=['tests']),
  37 + include_package_data=True,
  38 + test_suite='tests.runtests.main',
  39 +)
  40 +
  1 +#!/usr/bin/env python
  2 +
  3 +"""
  4 +Adapted from django-constance, which itself was adapted from django-adminfiles.
  5 +"""
  6 +
  7 +import os
  8 +import sys
  9 +
  10 +here = os.path.dirname(os.path.abspath(__file__))
  11 +parent = os.path.dirname(here)
  12 +sys.path[0:0] = [here, parent]
  13 +
  14 +from django.conf import settings
  15 +settings.configure(
  16 + DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3'}},
  17 + SECRET_KEY = "it's a secret to everyone",
  18 + INSTALLED_APPS = ["django_comments", "testapp", "custom_comments"],
  19 +)
  20 +
  21 +from django.test.simple import DjangoTestSuiteRunner
  22 +
  23 +def main():
  24 + runner = DjangoTestSuiteRunner()
  25 + failures = runner.run_tests(['testapp'], verbosity=1, interactive=True)
  26 + sys.exit(failures)
  27 +
  28 +if __name__ == '__main__':
  29 + main()
Please register or login to post a comment