Example #1
0
def send_batch_weekly_opt_in_email(meeting_spec):
    """Sends an email for the week asking if members want a meeting"""
    create_url = 'https://yelp-beans.appspot.com/meeting_request/{}'.format(
        meeting_spec.key.urlsafe())
    logging.info('created url ' + create_url)

    users = get_users_from_spec(meeting_spec)
    users = [user for user in users if user]

    logging.info(len(users))
    logging.info(meeting_spec)
    meeting_datetime = get_meeting_datetime(meeting_spec)
    subscription = meeting_spec.meeting_subscription.get()
    logging.info(meeting_datetime.strftime('%I:%M %p %Z'))

    for user in users:
        if not user.terminated:
            logging.info(user)
            logging.info(meeting_datetime)
            send_single_email(
                user.email, "Want a yelp-beans meeting this week?",
                "weekly_opt_in_email.html", {
                    'first_name': user.first_name,
                    'office': subscription.office,
                    'location': subscription.location,
                    'meeting_day': meeting_datetime.strftime('%A'),
                    'meeting_time': meeting_datetime.strftime('%I:%M %p %Z'),
                    'meeting_url': create_url,
                    'link_to_change_pref': 'https://yelp-beans.appspot.com/'
                })
            logging.info('sent email')
        else:
            logging.info(user)
            logging.info('terminated')
Example #2
0
def get_current_week_participation():
    participation = defaultdict(dict)

    for spec in get_specs_for_current_week():
        participation[spec.meeting_subscription.urlsafe()][spec.key.urlsafe()] = [
            user.get_username() for user in filter(None, get_users_from_spec(spec))
        ]

    return participation
Example #3
0
def get_current_week_participation():
    participation = defaultdict(dict)

    for spec in get_specs_for_current_week():
        participation[spec.subscription_id][spec.id] = [
            user.get_username()
            for user in [_f for _f in get_users_from_spec(spec) if _f]
        ]

    return participation
Example #4
0
def test_get_users_from_spec(database, fake_user):
    users = get_users_from_spec(database.specs[0])
    assert len(users) == 1