diff options
-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 | ||||
-rw-r--r-- | app/lttr/models.py | 13 | ||||
-rw-r--r-- | app/lttr/validators.py | 1 | ||||
-rw-r--r-- | app/media/models.py | 2 | ||||
-rw-r--r-- | app/taxonomy/models.py | 9 | ||||
-rw-r--r-- | app/utils/widgets.py | 3 | ||||
-rw-r--r-- | config/req.txt | 44 |
15 files changed, 54 insertions, 104 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 + diff --git a/app/lttr/models.py b/app/lttr/models.py index 5fed036..6414039 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -5,7 +5,6 @@ from django.contrib.gis.db import models from django.db.models.signals import post_save from django.contrib.sites.models import Site from django.template.loader import select_template -from django.utils.translation import ugettext_lazy as _ from django.utils import timezone from django.utils.text import slugify from django.urls import reverse @@ -356,10 +355,10 @@ class StatusType(models.IntegerChoices): class MailingStatus(models.Model): - newsletter_mailing = models.ForeignKey(NewsletterMailing, on_delete=models.CASCADE, verbose_name=_('newsletter')) - subscriber = models.ForeignKey(Subscriber, on_delete=models.CASCADE, verbose_name=_('subscriber')) + newsletter_mailing = models.ForeignKey(NewsletterMailing, on_delete=models.CASCADE, verbose_name=('newsletter')) + subscriber = models.ForeignKey(Subscriber, on_delete=models.CASCADE, verbose_name=('subscriber')) status = models.IntegerField(choices=StatusType.choices, null=True) - creation_date = models.DateTimeField(_('creation date'), auto_now_add=True) + creation_date = models.DateTimeField(('creation date'), auto_now_add=True) def newsletter(self): return self.newsletter_mailing.newsletter @@ -371,8 +370,8 @@ class MailingStatus(models.Model): class Meta: ordering = ('-creation_date',) - verbose_name = _('subscriber mailing status') - verbose_name_plural = _('subscriber mailing statuses') + verbose_name = ('subscriber mailing status') + verbose_name_plural = ('subscriber mailing statuses') ''' @@ -386,7 +385,7 @@ n.send_mailings() def send_notification_email(newsletter, message, instance): recipient_list = ['sng@luxagraf.net',] - subject = _('[%(site)s] New Subscriber to "%(object)s"') % { + subject = ('[%(site)s] New Subscriber to "%(object)s"') % { 'site': Site.objects.get_current().name, 'object': newsletter, } diff --git a/app/lttr/validators.py b/app/lttr/validators.py index a6355bf..581043c 100644 --- a/app/lttr/validators.py +++ b/app/lttr/validators.py @@ -1,6 +1,5 @@ from django.contrib.auth import get_user_model from django.forms.utils import ValidationError -from django.utils.translation import ugettext_lazy as _ def validate_email_nouser(email): diff --git a/app/media/models.py b/app/media/models.py index c385018..e20b397 100644 --- a/app/media/models.py +++ b/app/media/models.py @@ -6,7 +6,7 @@ from PIL import Image from django.core.exceptions import ValidationError from django.db import models from django.contrib.sitemaps import Sitemap -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.functional import cached_property from django.urls import reverse from django.apps import apps diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py index 4db3294..06f3ab8 100644 --- a/app/taxonomy/models.py +++ b/app/taxonomy/models.py @@ -1,6 +1,5 @@ from django.contrib.gis.db import models from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ from django.utils.functional import cached_property from taggit.models import TagBase, GenericTaggedItemBase @@ -11,8 +10,8 @@ class LuxTag(TagBase): color_rgb = models.CharField(max_length=20, blank=True) class Meta: - verbose_name = _("Tag") - verbose_name_plural = _("Tags") + verbose_name = ("Tag") + verbose_name_plural = ("Tags") @cached_property def get_absolute_url(self): @@ -37,8 +36,8 @@ class Category(models.Model): return self.name class Meta: - verbose_name = _("Category") - verbose_name_plural = _("Categories") + verbose_name = ("Category") + verbose_name_plural = ("Categories") def get_absolute_url(self): return reverse("taxonomy:cat-detail", kwargs={"slug": self.slug}) diff --git a/app/utils/widgets.py b/app/utils/widgets.py index f4a7a4a..f0f8821 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -4,7 +4,6 @@ from django.contrib import admin from django.contrib.admin.widgets import AdminFileWidget from django.contrib.gis.admin import OSMGeoAdmin from django.utils.safestring import mark_safe -from django.utils.translation import ugettext_lazy as _ from django.template.loader import render_to_string from django.template import Context from django.forms.widgets import SelectMultiple @@ -51,7 +50,7 @@ class CustomSelectMultiple(SelectMultiple): class TagListFilter(admin.SimpleListFilter): # Human-readable title which will be displayed in the # right admin sidebar just above the filter options. - title = _('tag') + title = ('tag') # Parameter for the filter that will be used in the URL query. parameter_name = 'tag' diff --git a/config/req.txt b/config/req.txt index 4d0221b..e69de29 100644 --- a/config/req.txt +++ b/config/req.txt @@ -1,44 +0,0 @@ -asgiref==3.4.1 -backcall==0.2.0 -beautifulsoup4==4.10.0 -bleach==4.1.0 -certifi==2021.5.30 -charset-normalizer==2.0.6 -decorator==5.1.0 -Django==3.2.8 -django-bleach==0.9.0 -django-debug-toolbar==3.2.2 -django-extensions==3.1.3 -django-gravatar2==1.4.4 -django-taggit==1.5.1 -idna==3.2 -ipython==7.28.0 -jedi==0.18.0 -Jinja2==3.0.2 -jsmin==3.0.0 -lxml==4.6.3 -Markdown==3.3.4 -MarkupSafe==2.0.1 -matplotlib-inline==0.1.3 -packaging==21.0 -parso==0.8.2 -pexpect==4.8.0 -pickleshare==0.7.5 -Pillow==8.3.2 -prompt-toolkit==3.0.20 -psycopg2-binary==2.9.1 -ptyprocess==0.7.0 -Pygments==2.10.0 -pyparsing==2.4.7 -python-resize-image==1.1.19 -pytz==2021.3 -requests==2.26.0 -six==1.16.0 -smartypants==2.0.1 -soupsieve==2.2.1 -sqlparse==0.4.2 -traitlets==5.1.0 -typogrify==2.0.7 -urllib3==1.26.7 -wcwidth==0.2.5 -webencodings==0.5.1 |