示例#1
0
def project_invite(project, email, is_registered=True):
    quoted_email = quote_plus(email)

    html = _render_email(
        "project_invite.html",
        base_url=BASE_URL,
        project=project,
        meta=meta,
        email=quoted_email,
        is_registered=is_registered,
    )

    text = _render_email(
        "project_invite.txt",
        base_url=BASE_URL,
        project=project,
        meta=meta,
        email=quoted_email,
        is_registered=is_registered,
    )

    subject = _render_email("project_invite.sub.txt", project=project, meta=meta)

    mailer = Mailer(**MAILER_PARAMS)
    mailer.send(from_addr=MAIL_FROM, to_addr=email, subject=subject, text=text, html=html)
示例#2
0
def _send_email(template_prefix, recipients, **kwargs):
    kwargs["meta"] = meta

    text = _render_email("%s.txt" % template_prefix, **kwargs)
    subject = _render_email("%s.sub.txt" % template_prefix, **kwargs)
    html = _render_email("%s.html" % template_prefix, **kwargs)
    mailer = Mailer(**MAILER_PARAMS)
    mailer.send(from_addr=MAIL_FROM, to_addr=recipients, subject=subject, text=text, html=html)
示例#3
0
def send_welcome_email(luser):
    text = _render_email("welcome.txt", luser=luser, meta=meta)
    html = _render_email("welcome.html", luser=luser, meta=meta)
    subject = _render_email("welcome.sub.txt", luser=luser, meta=meta)
    mailer = Mailer(**MAILER_PARAMS)
    mailer.send(from_addr=MAIL_FROM, to_addr=luser.email, subject=subject, text=text)
示例#4
0
def forgot_password(email, link):
    text = _render_email("forgot_password.txt", link=link, meta=meta)
    html = _render_email("forgot_password.html", link=link, meta=meta)
    mailer = Mailer(**MAILER_PARAMS)
    mailer.send(from_addr=MAIL_FROM, to_addr=email, subject="CodeColab password recovery.", text=text)
示例#5
0
def member_report(project, report, subject):
    recipients = project.recipients()
    html = _render_email("report.html", report=report, meta=meta)
    text = _render_email("report.txt", report=report, meta=meta)
    mailer = Mailer(**MAILER_PARAMS)
    mailer.send(from_addr=MAIL_FROM, to_addr=recipients, subject=subject, html=html, text=text)
示例#6
0
day_names = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
             "Saturday", "Sunday"]

print "Today's scheduled work"
print "----------------------"
print "user\tstart_time\tend_time"

# Iterate each user
for luser in models.Luser.query.all():
   
    # We need to use the time in the user's own timezone, because
    # we are storing naive times in the user's schedule.
    now = Delorean(timezone=luser.profile[0].timezone).datetime
    day = now.weekday()

    mailer = Mailer(**MAILER_PARAMS)

    # Users have multiple schedules. Check all of them.
    for schedule in luser.schedules:

        # Check each day until we hit the day that is today, in the
        # user's timezone.
        for range in schedule.ranges:
            if range.day is not None and range.day.name == day_names[day]:

                # Print out today's users who have hours, as an aid.
                print "%s\t%s\t%s" % (luser.profile[0].username,
                                      range.start_time,
                                      range.end_time)