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