Пример #1
0
def send_renew_mail(host):
    url = settings.FWADMIN_HOST_URL_TEMPLATE % {
        'url': reverse("fwadmin:edit_host", args=(host.pk,)),
        }
    # the text
    subject = _("Firewall config for '%s'") % host.name
    body = _("""Dear %(user)s,

The firewall config for machine: '%(host)s' (%(ip)s) will expire at
'%(expire_date)s'.

Please click on %(url)s to renew.
""") % {'user': host.owner.username,
        'host': host.name,
        'ip': host.ip,
        'expire_date': host.active_until,
        'url': url,
       }
    if "FWADMIN_DRY_RUN" in os.environ:
        print "From:", settings.FWADMIN_EMAIL_FROM
        print "To:", host.owner.email
        print "Subject: ", subject
        print body
        print
    else:
        send_mail(subject, body, settings.FWADMIN_EMAIL_FROM,
                  [host.owner.email])
Пример #2
0
def send_renew_mail(host):
    url = settings.FWADMIN_HOST_URL_TEMPLATE % {
        'url': reverse("fwadmin:edit_host", args=(host.pk, )),
    }
    # the text
    subject = _("Firewall config for '%s'") % host.name
    body = _("""Dear %(user)s,

The firewall config for machine: '%(host)s' (%(ip)s) will expire at
'%(expire_date)s'.

Please click on %(url)s to renew.
""") % {
        'user': host.owner.username,
        'host': host.name,
        'ip': host.ip,
        'expire_date': host.active_until,
        'url': url,
    }
    if "FWADMIN_DRY_RUN" in os.environ:
        print "From:", settings.FWADMIN_EMAIL_FROM
        print "To:", host.owner.email
        print "Subject: ", subject
        print body
        print
    else:
        send_mail(subject, body, settings.FWADMIN_EMAIL_FROM,
                  [host.owner.email])
Пример #3
0
def send_moderation_nag_mail():
    path = reverse("fwadmin:moderator_list_unapproved")
    url = settings.FWADMIN_HOST_URL_TEMPLATE % {'url': path}
    subject = _("fwadmin hosts waiting for moderation")
    hosts_from_db = Host.objects.filter(approved=False)
    if hosts_from_db:
        hosts = ["%s (%s)" % (host.name, host.ip) for host in hosts_from_db]
        body = _("""The hosts below need moderation. You can approve via:
%(url)s

Hosts waiting for moderation:
%(hosts)s""") % {'hosts': "\n".join(hosts),
                 'url': url,
                 }
        send_mail(subject, body, settings.FWADMIN_EMAIL_FROM,
                  [settings.FWADMIN_MODERATION_WAITING_MAIL_NAG])