Exemplo n.º 1
0
Arquivo: tasks.py Projeto: seocam/remo
def send_first_report_notification():
    """Send inactivity notification after 4 weeks."""
    today = get_date()
    start = today - timedelta(weeks=4)
    end = today + timedelta(weeks=4)
    users = User.objects.filter(
        groups__name='Rep',
        userprofile__registration_complete=True,
        userprofile__first_report_notification__isnull=True)
    inactive_users = users.exclude(ng_reports__report_date__range=[start, end])

    send_report_notification(inactive_users, weeks=4)
    for user in inactive_users:
        user.userprofile.first_report_notification = today
        user.userprofile.save()
Exemplo n.º 2
0
def send_first_report_notification():
    """Send inactivity notification after 4 weeks."""
    today = get_date()
    start = today - timedelta(weeks=4)
    end = today + timedelta(weeks=4)
    users = User.objects.filter(
        groups__name='Rep',
        userprofile__registration_complete=True,
        userprofile__first_report_notification__isnull=True)
    # Exclude users with a report filed between start and end period
    # and users who joined the program less than one month
    inactive_users = users.exclude(
        ng_reports__report_date__range=[start, end],
        userprofile__date_joined_program__gt=start)

    send_report_notification(inactive_users, weeks=4)
    for user in inactive_users:
        user.userprofile.first_report_notification = today
        user.userprofile.save()
    statsd.incr('reports.send_first_report_notification')
Exemplo n.º 3
0
def send_first_report_notification():
    """Send inactivity notification after 4 weeks."""
    today = get_date()
    start = today - timedelta(weeks=4)
    end = today + timedelta(weeks=4)
    users = User.objects.filter(
        groups__name='Rep',
        userprofile__registration_complete=True,
        userprofile__first_report_notification__isnull=True,
        userprofile__is_unavailable=False)
    # Exclude users with a report filed between start and end period
    # and users who joined the program less than one month
    inactive_users = (users
                      .exclude(ng_reports__report_date__range=[start, end])
                      .exclude(userprofile__date_joined_program__gt=start))

    send_report_notification(inactive_users, weeks=4)
    for user in inactive_users:
        user.userprofile.first_report_notification = today
        user.userprofile.save()
    statsd.incr('reports.send_first_report_notification')