management commands sending emails: mark strings as translatable
This commit is contained in:
parent
0db2e60263
commit
ae61712fbc
@ -9,12 +9,13 @@ from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from nsupdate.main.models import Domain
|
||||
from nsupdate.main.dnstools import FQDN, query_ns, NameServerNotAvailable
|
||||
|
||||
|
||||
MSG = """\
|
||||
MSG = _("""\
|
||||
Your domain: %(domain)s (comment: %(comment)s)
|
||||
|
||||
Issue: The nameserver of the domain is not reachable and was set to not available
|
||||
@ -38,7 +39,7 @@ If you really want that domain to work and you really control that nameserver:
|
||||
Alternatively, if you do not use the domain with our service, delete the
|
||||
domain entry, so it is removed from our database. This will also remove all
|
||||
hosts that were added to this domain (if any).
|
||||
"""
|
||||
""")
|
||||
|
||||
|
||||
def check_dns(domain):
|
||||
@ -97,7 +98,7 @@ class Command(BaseCommand):
|
||||
if notify_user:
|
||||
from_addr = None # will use DEFAULT_FROM_EMAIL
|
||||
to_addr = creator.email
|
||||
subject = "issue with your domain %(domain)s" % dict(domain=domain)
|
||||
subject = _("issue with your domain %(domain)s") % dict(domain=domain)
|
||||
msg = MSG % dict(domain=domain, comment=comment)
|
||||
send_mail(subject, msg, from_addr, [to_addr], fail_silently=True)
|
||||
msg = "setting unavailable flag for domain %s (created by %s)\n" % (domain, creator, )
|
||||
|
@ -7,11 +7,12 @@ from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from nsupdate.main.models import Host
|
||||
|
||||
|
||||
ABUSE_MSG = """\
|
||||
ABUSE_MSG = _("""\
|
||||
Your host: %(fqdn)s (comment: %(comment)s)
|
||||
|
||||
Issue: The abuse flag for your host was set.
|
||||
@ -42,7 +43,7 @@ Notes:
|
||||
a valid, well-behaved dyndns2-compatible update client
|
||||
- if you already used such a software and you ran into this problem,
|
||||
complain to whoever wrote it about it sending nochg updates
|
||||
"""
|
||||
""")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@ -141,7 +142,7 @@ class Command(BaseCommand):
|
||||
if notify_user:
|
||||
from_addr = None # will use DEFAULT_FROM_EMAIL
|
||||
to_addr = creator.email
|
||||
subject = "issue with your host %(fqdn)s" % dict(fqdn=fqdn)
|
||||
subject = _("issue with your host %(fqdn)s") % dict(fqdn=fqdn)
|
||||
msg = ABUSE_MSG % dict(fqdn=fqdn, comment=comment, faults_count=faults_count)
|
||||
send_mail(subject, msg, from_addr, [to_addr], fail_silently=True)
|
||||
if reset_client:
|
||||
|
@ -9,6 +9,7 @@ from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from nsupdate.main.models import Host
|
||||
|
||||
@ -21,17 +22,17 @@ S_delete = 5 # staleness level leading to host being deleted
|
||||
|
||||
NEVER = datetime.fromtimestamp(DAY, timezone.utc) # 2.1.1970
|
||||
|
||||
LOG_MSG_STALE = "%(host)s has not seen IP updates since a long time, staleness: %(staleness)d -> please fix!"
|
||||
LOG_MSG_UNAVAILABLE = "%(host)s IP has still not been updated, staleness: %(staleness)d -> made host unavailable."
|
||||
LOG_MSG_DELETE = "%(host)s IP has still not been updated, staleness: %(staleness)d -> deleted host."
|
||||
LOG_MSG_STALE = _("%(host)s has not seen IP updates since a long time, staleness: %(staleness)d -> please fix!")
|
||||
LOG_MSG_UNAVAILABLE = _("%(host)s IP has still not been updated, staleness: %(staleness)d -> made host unavailable.")
|
||||
LOG_MSG_DELETE = _("%(host)s IP has still not been updated, staleness: %(staleness)d -> deleted host.")
|
||||
|
||||
EMAIL_MSG_START = """\
|
||||
EMAIL_MSG_START = _("""\
|
||||
Your host: %(host)s (comment: %(comment)s)
|
||||
|
||||
Issue: \
|
||||
"""
|
||||
""")
|
||||
|
||||
EMAIL_MSG_END = """
|
||||
EMAIL_MSG_END = _("""
|
||||
|
||||
Explanation:
|
||||
You created the host on our service, but it has not been updated for a very long time.
|
||||
@ -61,9 +62,9 @@ Resolution:
|
||||
Hint: to avoid this issue for static or mostly-static IP hosts, consider
|
||||
sending 1 unconditional update every month. some dyndns2 compatible updaters
|
||||
can do that, too.
|
||||
"""
|
||||
""")
|
||||
|
||||
EMAIL_MSG_END_DELETED = """
|
||||
EMAIL_MSG_END_DELETED = _("""
|
||||
|
||||
Explanation:
|
||||
You created the host on our service, but it has not been updated for a very long time.
|
||||
@ -73,7 +74,7 @@ Thus, we assume that you do not need the host any more and have DELETED it.
|
||||
|
||||
Feel free to re-create it on our service in case you need it again at some
|
||||
time.
|
||||
"""
|
||||
""")
|
||||
|
||||
EMAIL_MSG_STALE = EMAIL_MSG_START + LOG_MSG_STALE + EMAIL_MSG_END
|
||||
EMAIL_MSG_UNAVAILABLE = EMAIL_MSG_START + LOG_MSG_UNAVAILABLE + EMAIL_MSG_END
|
||||
@ -160,7 +161,7 @@ class Command(BaseCommand):
|
||||
if email_msg and notify_user:
|
||||
from_addr = None # will use DEFAULT_FROM_EMAIL
|
||||
to_addr = creator.email
|
||||
subject = "issue with your host %(host)s" % dict(host=host)
|
||||
subject = _("issue with your host %(host)s") % dict(host=host)
|
||||
email_msg = email_msg % dict(host=host, staleness=staleness, comment=comment)
|
||||
send_mail(subject, email_msg, from_addr, [to_addr], fail_silently=True)
|
||||
if log_msg:
|
||||
|
Loading…
x
Reference in New Issue
Block a user