Fix pluralization in check pending

This commit is contained in:
Gabriel Augendre 2020-08-20 10:12:33 +02:00
parent 75e54218d9
commit c997c6b9aa

View file

@ -2,6 +2,7 @@ from django.conf import settings
from django.core.mail import mail_admins from django.core.mail import mail_admins
from django.core.management import BaseCommand from django.core.management import BaseCommand
from django.urls import reverse from django.urls import reverse
from django.utils.translation import ngettext
from articles.models import Comment from articles.models import Comment
@ -16,8 +17,9 @@ class Command(BaseCommand):
url = (settings.BLOG["base_url"] + url).replace( url = (settings.BLOG["base_url"] + url).replace(
"//", "/" "//", "/"
) + "?status__exact=pending" ) + "?status__exact=pending"
comments = "comment" message = ngettext(
if count > 1: "There is %(count)d comment pending review.\n%(url)s",
comments += "s" "There are %(count)d comments pending review.\n%(url)s",
message = f"There are {count} {comments} pending review.\n{url}" count,
mail_admins("Comments pending", message) ) % {"count": count, "url": url}
mail_admins("Comments pending review", message)