Exemplo n.º 1
0
def send_after_event_mail():
    from app import current_app as app
    with app.app_context():
        events = Event.query.all()
        upcoming_events = get_upcoming_events()
        upcoming_event_links = "<ul>"
        for upcoming_event in upcoming_events:
            frontend_url = get_settings()['frontend_url']
            upcoming_event_links += "<li><a href='{}/events/{}'>{}</a></li>" \
                .format(frontend_url, upcoming_event.id, upcoming_event.name)
        upcoming_event_links += "</ul>"
        for event in events:
            organizers = get_user_event_roles_by_role_name(
                event.id, 'organizer')
            speakers = Speaker.query.filter_by(event_id=event.id,
                                               deleted_at=None).all()
            current_time = datetime.datetime.now(pytz.timezone(event.timezone))
            time_difference = current_time - event.ends_at
            time_difference_minutes = (time_difference.days * 24 * 60) + \
                (time_difference.seconds / 60)
            if current_time > event.ends_at and time_difference_minutes < 1440:
                for speaker in speakers:
                    send_email_after_event(speaker.user.email, event.name,
                                           upcoming_event_links)
                    send_notif_after_event(speaker.user, event.name)
                for organizer in organizers:
                    send_email_after_event(organizer.user.email, event.name,
                                           upcoming_event_links)
                    send_notif_after_event(organizer.user, event.name)
Exemplo n.º 2
0
def send_after_event_mail():
    from app import current_app as app
    with app.app_context():
        events = Event.query.all()
        upcoming_events = get_upcoming_events()
        upcoming_event_links = "<ul>"
        for upcoming_event in upcoming_events:
            frontend_url = get_settings()['frontend_url']
            upcoming_event_links += "<li><a href='{}/events/{}'>{}</a></li>" \
                .format(frontend_url, upcoming_event.id, upcoming_event.name)
        upcoming_event_links += "</ul>"
        for event in events:
            organizers = get_user_event_roles_by_role_name(event.id, 'organizer')
            speakers = get_user_event_roles_by_role_name(event.id, 'speaker')
            current_time = datetime.datetime.now(pytz.timezone(event.timezone))
            time_difference = current_time - event.ends_at
            time_difference_minutes = (time_difference.days * 24 * 60) + \
                (time_difference.seconds / 60)
            if current_time > event.ends_at and time_difference_minutes < 1440:
                for speaker in speakers:
                    send_email_after_event(speaker.user.email, event.name, upcoming_event_links)
                    send_notif_after_event(speaker.user, event.name)
                for organizer in organizers:
                    send_email_after_event(organizer.user.email, event.name, upcoming_event_links)
                    send_notif_after_event(organizer.user.email, event.name)