Пример #1
0
def user_added_to_league_messenger(user, league):
    if not league or not user or not user.messenger:
        return

    with app.app_context():
        send_message(
            user.messenger.id,
            "You've been added to the league {}.\n{}".format(
                league.name,
                url_for('view_league', league_id=league.id, _external=True)))
Пример #2
0
def user_submit_reminder_messenger(user, submission_period):
    if not submission_period or not user or not user.messenger:
        return

    with app.app_context():
        send_message(
            user.messenger.id, "It's time to submit for {}.\n{}".format(
                submission_period.name,
                url_for('view_submit',
                        league_id=submission_period.league.id,
                        submission_period_id=submission_period.id,
                        _external=True)))
Пример #3
0
def user_last_to_vote_messenger(user, submission_period):
    if not submission_period or not user or not user.messenger:
        return

    with app.app_context():
        send_message(
            user.messenger.id, "You're the last to vote for {}.\n{}".format(
                submission_period.name,
                url_for('view_vote',
                        league_id=submission_period.league.id,
                        submission_period_id=submission_period.id,
                        _external=True)))
Пример #4
0
def create_playlist(submission_period_id):
    if not submission_period_id:
        app.logger.error('No submission period id for playlist creation!')
        return

    try:
        with app.app_context():
            league_id = select_league_id_for_round(submission_period_id)
            league = select_league(
                league_id,
                exclude_properties=['votes', 'scoreboard', 'invited_users'])
            submission_period = next((r for r in league.submission_periods
                                      if r.id == submission_period_id), None)

            create_or_update_playlist(submission_period)
    except Exception as e:
        app.logger.exception('Error occurred while creating playlist!',
                             exc_info=e,
                             extra={'round': submission_period_id})
Пример #5
0
def notify_new_round(submission_period_id):
    if not submission_period_id:
        app.logger.error('No submission period id for new round notification!')
        return

    try:
        with app.app_context():
            league_id = select_league_id_for_round(submission_period_id)
            league = select_league(league_id,
                                   exclude_properties=[
                                       'submissions', 'votes', 'scoreboard',
                                       'invited_users'
                                   ])
            submission_period = next((r for r in league.submission_periods
                                      if r.id == submission_period_id), None)

            user_new_round_notification(submission_period)

    except Exception as e:
        app.logger.exception('Error occurred while notifying new round!',
                             exc_info=e,
                             extra={'round': submission_period_id})
Пример #6
0
def _html_email(template, **kwargs):
    with app.app_context():
        return render_template(HTML_PATH % template, **kwargs)
Пример #7
0
def _txt_email(template, **kwargs):
    with app.app_context():
        return render_template(TXT_PATH % template, **kwargs)