Exemplo n.º 1
0
def construct_summary(supply_point, status_type, values, cutoff):
    children = supply_point.location.children
    children = filter(lambda sp: get_current_group() in sp.metadata.get('groups', []), children)

    return _construct_status_dict(status_type,
                                 values,
                                  children, DateSpan(cutoff, datetime.utcnow()))
Exemplo n.º 2
0
def construct_summary(supply_point, status_type, values, cutoff):
    children = supply_point.location.children
    children = filter(
        lambda sp: get_current_group() in sp.metadata.get('groups', []),
        children)

    return _construct_status_dict(status_type, values, children,
                                  DateSpan(cutoff, datetime.utcnow()))
Exemplo n.º 3
0
def send_ror_reminder(domain, date, loc_type='FACILITY'):
    if loc_type == 'FACILITY':
        status_type = SupplyPointStatusTypes.R_AND_R_FACILITY
        sms_text = REMINDER_R_AND_R_FACILITY
    elif loc_type == 'DISTRICT':
        status_type = SupplyPointStatusTypes.R_AND_R_DISTRICT
        sms_text = REMINDER_R_AND_R_DISTRICT
    else:
        return
    current_group = get_current_group()
    sp_ids = set()
    for user in CommTrackUser.by_domain(domain):
        if user.is_active and user.location and user.location.location_type == loc_type:
            sp = SupplyPointCase.get_by_location(user.location)
            if current_group in get_groups(sp.location.metadata.get('groups', None)) \
                    and not SupplyPointStatus.objects.filter(supply_point=sp._id, status_type=status_type,
                                                             status_date__gte=date).exists():
                if user.get_verified_number():
                    send_sms_to_verified_number(user.get_verified_number(), sms_text)
                    sp_ids.add(sp._id)
    update_statuses(sp_ids, status_type, SupplyPointStatusValues.REMINDER_SENT)