diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/django_comments/abstracts.py | 31 | ||||
-rw-r--r-- | app/lib/django_comments/admin.py | 11 | ||||
-rw-r--r-- | app/lib/django_comments/managers.py | 4 | ||||
-rw-r--r-- | app/lib/django_comments/models.py | 13 | ||||
-rw-r--r-- | app/lib/django_comments/moderation.py | 1 | ||||
-rw-r--r-- | app/lib/django_comments/signals.py | 9 | ||||
-rw-r--r-- | app/lib/django_comments/templatetags/comments.py | 4 | ||||
-rw-r--r-- | app/lib/django_comments/views/utils.py | 4 | ||||
-rw-r--r-- | app/lib/templatetags/templatetags/number_to_word.py | 9 |
9 files changed, 42 insertions, 44 deletions
diff --git a/app/lib/django_comments/abstracts.py b/app/lib/django_comments/abstracts.py index e74ea02..0cf5a69 100644 --- a/app/lib/django_comments/abstracts.py +++ b/app/lib/django_comments/abstracts.py @@ -9,7 +9,6 @@ from django.utils.html import mark_safe from django.db import models from django.utils import timezone from six import python_2_unicode_compatible -from django.utils.translation import ugettext_lazy as _ try: from django.urls import reverse except ImportError: @@ -28,10 +27,10 @@ class BaseCommentAbstractModel(models.Model): # Content-object field content_type = models.ForeignKey(ContentType, - verbose_name=_('content type'), + verbose_name=('content type'), related_name="content_type_set_for_%(class)s", on_delete=models.CASCADE) - object_pk = models.TextField(_('object ID')) + object_pk = models.TextField(('object ID')) content_object = GenericForeignKey(ct_field="content_type", fk_field="object_pk") # Metadata about the comment @@ -66,25 +65,25 @@ class CommentAbstractModel(BaseCommentAbstractModel): # Who posted this comment? If ``user`` is set then it was an authenticated # user; otherwise at least user_name should have been set and the comment # was posted by a non-authenticated user. - user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('user'), + user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=('user'), blank=True, null=True, related_name="%(class)s_comments", on_delete=models.SET_NULL) - user_name = models.CharField(_("user's name"), max_length=50, blank=True) + user_name = models.CharField(("user's name"), max_length=50, blank=True) # Explicit `max_length` to apply both to Django 1.7 and 1.8+. - user_email = models.EmailField(_("user's email address"), max_length=254, + user_email = models.EmailField(("user's email address"), max_length=254, blank=True) - user_url = models.URLField(_("user's URL"), blank=True) + user_url = models.URLField(("user's URL"), blank=True) - comment = models.TextField(_('comment'), max_length=COMMENT_MAX_LENGTH) + comment = models.TextField(('comment'), max_length=COMMENT_MAX_LENGTH) # Metadata about the comment - submit_date = models.DateTimeField(_('date/time submitted'), default=None, db_index=True) - ip_address = models.GenericIPAddressField(_('IP address'), unpack_ipv4=True, blank=True, null=True) - is_public = models.BooleanField(_('is public'), default=True, - help_text=_('Uncheck this box to make the comment effectively ' + submit_date = models.DateTimeField(('date/time submitted'), default=None, db_index=True) + ip_address = models.GenericIPAddressField(('IP address'), unpack_ipv4=True, blank=True, null=True) + is_public = models.BooleanField(('is public'), default=True, + help_text=('Uncheck this box to make the comment effectively ' 'disappear from the site.')) - is_removed = models.BooleanField(_('is removed'), default=False, - help_text=_('Check this box if the comment is inappropriate. ' + is_removed = models.BooleanField(('is removed'), default=False, + help_text=('Check this box if the comment is inappropriate. ' 'A "This comment has been removed" message will ' 'be displayed instead.')) @@ -95,8 +94,8 @@ class CommentAbstractModel(BaseCommentAbstractModel): abstract = True ordering = ('submit_date',) permissions = [("can_moderate", "Can moderate comments")] - verbose_name = _('comment') - verbose_name_plural = _('comments') + verbose_name = ('comment') + verbose_name_plural = ('comments') def __str__(self): return "%s: %s..." % (self.name, self.comment[:50]) diff --git a/app/lib/django_comments/admin.py b/app/lib/django_comments/admin.py index 8451c70..0f25755 100644 --- a/app/lib/django_comments/admin.py +++ b/app/lib/django_comments/admin.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals from django.contrib import admin from django.contrib.auth import get_user_model -from django.utils.translation import ugettext_lazy as _, ungettext from django_comments import get_model from django_comments.views.moderation import perform_flag, perform_approve, perform_delete @@ -26,11 +25,11 @@ class CommentsAdmin(admin.ModelAdmin): {'fields': ('content_type', 'object_pk', 'site')} ), ( - _('Content'), + ('Content'), {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')} ), ( - _('Metadata'), + ('Metadata'), {'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')} ), ) @@ -59,19 +58,19 @@ class CommentsAdmin(admin.ModelAdmin): self._bulk_flag(request, queryset, perform_flag, lambda n: ungettext('flagged', 'flagged', n)) - flag_comments.short_description = _("Flag selected comments") + flag_comments.short_description = ("Flag selected comments") def approve_comments(self, request, queryset): self._bulk_flag(request, queryset, perform_approve, lambda n: ungettext('approved', 'approved', n)) - approve_comments.short_description = _("Approve selected comments") + approve_comments.short_description = ("Approve selected comments") def remove_comments(self, request, queryset): self._bulk_flag(request, queryset, perform_delete, lambda n: ungettext('removed', 'removed', n)) - remove_comments.short_description = _("Remove selected comments") + remove_comments.short_description = ("Remove selected comments") def _bulk_flag(self, request, queryset, action, done_message): """ diff --git a/app/lib/django_comments/managers.py b/app/lib/django_comments/managers.py index 9e1fc77..33d9e2a 100644 --- a/app/lib/django_comments/managers.py +++ b/app/lib/django_comments/managers.py @@ -1,6 +1,6 @@ from django.db import models from django.contrib.contenttypes.models import ContentType -from django.utils.encoding import force_text +from django.utils.encoding import force_str class CommentManager(models.Manager): @@ -18,5 +18,5 @@ class CommentManager(models.Manager): ct = ContentType.objects.get_for_model(model) qs = self.get_queryset().filter(content_type=ct) if isinstance(model, models.Model): - qs = qs.filter(object_pk=force_text(model._get_pk_val())) + qs = qs.filter(object_pk=force_str(model._get_pk_val())) return qs diff --git a/app/lib/django_comments/models.py b/app/lib/django_comments/models.py index 204cf2e..fdae25d 100644 --- a/app/lib/django_comments/models.py +++ b/app/lib/django_comments/models.py @@ -2,7 +2,6 @@ from six import python_2_unicode_compatible from django.conf import settings from django.db import models from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ from .abstracts import ( COMMENT_MAX_LENGTH, BaseCommentAbstractModel, CommentAbstractModel, @@ -29,16 +28,16 @@ class CommentFlag(models.Model): if you want rating look elsewhere. """ user = models.ForeignKey( - settings.AUTH_USER_MODEL, verbose_name=_('user'), related_name="comment_flags", + settings.AUTH_USER_MODEL, verbose_name=('user'), related_name="comment_flags", on_delete=models.CASCADE, ) comment = models.ForeignKey( # Translators: 'comment' is a noun here. - Comment, verbose_name=_('comment'), related_name="flags", on_delete=models.CASCADE, + Comment, verbose_name=('comment'), related_name="flags", on_delete=models.CASCADE, ) # Translators: 'flag' is a noun here. - flag = models.CharField(_('flag'), max_length=30, db_index=True) - flag_date = models.DateTimeField(_('date'), default=None) + flag = models.CharField(('flag'), max_length=30, db_index=True) + flag_date = models.DateTimeField(('date'), default=None) # Constants for flag types SUGGEST_REMOVAL = "removal suggestion" @@ -48,8 +47,8 @@ class CommentFlag(models.Model): class Meta: db_table = 'django_comment_flags' unique_together = [('user', 'comment', 'flag')] - verbose_name = _('comment flag') - verbose_name_plural = _('comment flags') + verbose_name = ('comment flag') + verbose_name_plural = ('comment flags') def __str__(self): return "%s flag of comment ID %s by %s" % ( diff --git a/app/lib/django_comments/moderation.py b/app/lib/django_comments/moderation.py index 3e5c412..5cf85d9 100644 --- a/app/lib/django_comments/moderation.py +++ b/app/lib/django_comments/moderation.py @@ -62,7 +62,6 @@ from django.core.mail import send_mail from django.db.models.base import ModelBase from django.template import loader from django.utils import timezone -from django.utils.translation import ugettext as _ import django_comments from django_comments import signals diff --git a/app/lib/django_comments/signals.py b/app/lib/django_comments/signals.py index 079afaf..0572a4b 100644 --- a/app/lib/django_comments/signals.py +++ b/app/lib/django_comments/signals.py @@ -9,13 +9,16 @@ from django.dispatch import Signal # discarded and a 400 response. This signal is sent at more or less # the same time (just before, actually) as the Comment object's pre-save signal, # except that the HTTP request is sent along with this signal. -comment_will_be_posted = Signal(providing_args=["comment", "request"]) +# Arguments: "comment", "request" +comment_will_be_posted = Signal() # Sent just after a comment was posted. See above for how this differs # from the Comment object's post-save signal. -comment_was_posted = Signal(providing_args=["comment", "request"]) +# Arguments: "comment", "request" +comment_was_posted = Signal() # Sent after a comment was "flagged" in some way. Check the flag to see if this # was a user requesting removal of a comment, a moderator approving/removing a # comment, or some other custom user flag. -comment_was_flagged = Signal(providing_args=["comment", "flag", "created", "request"]) +# Arguments: "comment", "flag", "created", "request" +comment_was_flagged = Signal() diff --git a/app/lib/django_comments/templatetags/comments.py b/app/lib/django_comments/templatetags/comments.py index 9b2d1a4..440a8f6 100644 --- a/app/lib/django_comments/templatetags/comments.py +++ b/app/lib/django_comments/templatetags/comments.py @@ -3,7 +3,7 @@ from django.template.loader import render_to_string from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib.sites.shortcuts import get_current_site -from django.utils.encoding import smart_text +from django.utils.encoding import smart_str import django_comments @@ -85,7 +85,7 @@ class BaseCommentNode(template.Node): qs = self.comment_model.objects.filter( content_type=ctype, - object_pk=smart_text(object_pk), + object_pk=smart_str(object_pk), site__pk=site_id, ) diff --git a/app/lib/django_comments/views/utils.py b/app/lib/django_comments/views/utils.py index a5f5c11..793fc43 100644 --- a/app/lib/django_comments/views/utils.py +++ b/app/lib/django_comments/views/utils.py @@ -12,7 +12,7 @@ except ImportError: # Python 2 from django.http import HttpResponseRedirect from django.shortcuts import render, resolve_url from django.core.exceptions import ObjectDoesNotExist -from django.utils.http import is_safe_url +from django.utils.http import url_has_allowed_host_and_scheme import django_comments @@ -28,7 +28,7 @@ def next_redirect(request, fallback, **get_kwargs): Returns an ``HttpResponseRedirect``. """ next = request.POST.get('next') - if not is_safe_url(url=next, allowed_hosts={request.get_host()}): + if not url_has_allowed_host_and_scheme(url=next, allowed_hosts={request.get_host()}): next = resolve_url(fallback) if get_kwargs: diff --git a/app/lib/templatetags/templatetags/number_to_word.py b/app/lib/templatetags/templatetags/number_to_word.py index c153932..03fa993 100644 --- a/app/lib/templatetags/templatetags/number_to_word.py +++ b/app/lib/templatetags/templatetags/number_to_word.py @@ -1,4 +1,3 @@ -from django.utils.translation import ungettext, ugettext as _ import re from django import template from django.utils.safestring import mark_safe @@ -6,9 +5,9 @@ register = template.Library() -SPECIAL_CASES = (_('ten'), _('eleven'), _('twelve'), _('thirteen'), _('fourteen'), _('fifteen'), _('sixteen'), _('seventeen'), _('eighteen'), _('nineteen'),) -BASE_INT = (_('twenty'), _('thirty'), _('forty'), _('fifty'), _('sixty'), _('seventy'), _('eighty'), _('ninety')) -PRIME_NUM = (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'),) +SPECIAL_CASES = (('ten'), ('eleven'), ('twelve'), ('thirteen'), ('fourteen'), ('fifteen'), ('sixteen'), ('seventeen'), ('eighteen'), ('nineteen'),) +BASE_INT = (('twenty'), ('thirty'), ('forty'), ('fifty'), ('sixty'), ('seventy'), ('eighty'), ('ninety')) +PRIME_NUM = (('one'), ('two'), ('three'), ('four'), ('five'), ('six'), ('seven'), ('eight'), ('nine'),) @register.filter def number_to_word(value): @@ -26,4 +25,4 @@ def number_to_word(value): else: word = PRIME_NUM[int(value[:1])-1] return word -
\ No newline at end of file + |