Esempio n. 1
0
def bootstrap_user(
    setup,
    username=TEST_USER,
    domain=TEST_DOMAIN,
    phone_number=TEST_NUMBER,
    password=TEST_PASSWORD,
    backend=TEST_BACKEND,
    first_name='',
    last_name='',
    home_loc=None,
    user_data=None,
):
    user_data = user_data or {}
    user = CommTrackUser.create(domain,
                                username,
                                password,
                                phone_numbers=[TEST_NUMBER],
                                user_data=user_data,
                                first_name=first_name,
                                last_name=last_name)
    if home_loc == setup.loc.site_code:
        if not SupplyPointCase.get_by_location(setup.loc):
            make_supply_point(domain, setup.loc)

        user.add_location(setup.loc)
        user.save()

    user.save_verified_number(domain,
                              phone_number,
                              verified=True,
                              backend_id=backend)
    return CommTrackUser.wrap(user.to_json())
Esempio n. 2
0
def get_location(domain, user, site_code):
    location = None
    if user and CommTrackUser.wrap(user.to_json()).location:
        loc = CommTrackUser.wrap(user.to_json()).location
        location = get_supply_point(domain, loc=loc)
    elif site_code:
        location = get_supply_point(domain, site_code=site_code)
    return location
Esempio n. 3
0
 def save(self, user):
     commtrack_user = CommTrackUser.wrap(user.to_json())
     location_id = self.cleaned_data['supply_point']
     if location_id:
         loc = Location.get(location_id)
         commtrack_user.clear_locations()
         commtrack_user.add_location(loc, create_sp_if_missing=True)
Esempio n. 4
0
 def save(self, user):
     commtrack_user = CommTrackUser.wrap(user.to_json())
     location_id = self.cleaned_data["supply_point"]
     if location_id:
         loc = Location.get(location_id)
         commtrack_user.clear_locations()
         commtrack_user.add_location(loc, create_sp_if_missing=True)
Esempio n. 5
0
 def save(self, user):
     commtrack_user = CommTrackUser.wrap(user.to_json())
     location_id = self.cleaned_data['supply_point']
     if location_id:
         loc = Location.get(location_id)
         commtrack_user.clear_locations()
         commtrack_user.add_location(loc)
Esempio n. 6
0
def location_fixture_generator(user, version, last_sync):
    project = user.project
    if (not project or not project.commtrack_enabled
            or not project.commtrack_settings
            or not project.commtrack_settings.sync_location_fixtures):
        return []

    rewrapped_user = CommTrackUser.wrap(user.to_json())
    location_db = _location_footprint(rewrapped_user.locations)

    if not should_sync_locations(last_sync, location_db):
        return []

    root = ElementTree.Element('fixture', {
        'id': 'commtrack:locations',
        'user_id': user.user_id
    })

    loc_types = project.commtrack_settings.location_types
    type_to_slug_mapping = dict(
        (ltype.name, ltype.code) for ltype in loc_types)

    def location_type_lookup(location_type):
        return type_to_slug_mapping.get(location_type,
                                        unicode_slug(location_type))

    root_locations = filter(lambda loc: loc.parent_id is None,
                            location_db.by_id.values())
    _append_children(root, location_db, root_locations, location_type_lookup)
    return [root]
Esempio n. 7
0
 def update_commtrack_form(self):
     if self.request.method == "POST" and self.request.POST['form_type'] == "commtrack":
         return CommtrackUserForm(self.request.POST, domain=self.domain)
     # currently only support one location on the UI
     linked_loc = CommTrackUser.wrap(self.editable_user.to_json()).location
     initial_id = linked_loc._id if linked_loc else None
     return CommtrackUserForm(domain=self.domain, initial={'supply_point': initial_id})
Esempio n. 8
0
 def update_commtrack_form(self):
     if self.request.method == "POST" and self.request.POST['form_type'] == "commtrack":
         return CommtrackUserForm(self.request.POST, domain=self.domain)
     # currently only support one location on the UI
     linked_loc = CommTrackUser.wrap(self.editable_user.to_json()).location
     initial_id = linked_loc._id if linked_loc else None
     return CommtrackUserForm(domain=self.domain, initial={'supply_point': initial_id})
Esempio n. 9
0
def location_fixture_generator(user, version, last_sync):
    project = user.project
    if (not project or not project.commtrack_enabled
        or not project.commtrack_settings
        or not project.commtrack_settings.sync_location_fixtures):
            return []

    rewrapped_user = CommTrackUser.wrap(user.to_json())
    location_db = _location_footprint(rewrapped_user.locations)

    if not should_sync_locations(last_sync, location_db):
        return []

    root = ElementTree.Element('fixture',
                               {'id': 'commtrack:locations',
                                'user_id': user.user_id})

    loc_types = project.commtrack_settings.location_types
    type_to_slug_mapping = dict((ltype.name, ltype.code) for ltype in loc_types)

    def location_type_lookup(location_type):
        return type_to_slug_mapping.get(location_type, unicode_slug(location_type))

    root_locations = filter(lambda loc: loc.parent_id is None, location_db.by_id.values())
    _append_children(root, location_db, root_locations, location_type_lookup)
    return [root]
Esempio n. 10
0
def _get_location(form):
    if 'location_id' in form.form:
        loc_id = form.form['location_id']
        loc = Location.get(loc_id)
    else:
        user_id = form['auth_context']['user_id']
        user = CommTrackUser.get(user_id)
        loc = user.location
    return loc
Esempio n. 11
0
def send_soh_reminder(domain, date):
    sp_ids = set()
    for user in CommTrackUser.by_domain(domain):
        if user.is_active and user.location and user.location.location_type == 'FACILITY':
            sp = SupplyPointCase.get_by_location(user.location)
            if sp and not StockTransaction.objects.filter(case_id=sp._id, report__date__gte=date,
                                                          type='stockonhand').exists():
                if user.get_verified_number():
                        send_sms_to_verified_number(user.get_verified_number(), REMINDER_STOCKONHAND)
                        sp_ids.add(sp._id)
    update_statuses(sp_ids, SupplyPointStatusTypes.SOH_FACILITY, SupplyPointStatusValues.REMINDER_SENT)
Esempio n. 12
0
def send_soh_reminder(domain, date):
    sp_ids = set()
    for user in CommTrackUser.by_domain(domain):
        if user.is_active and user.location and user.location.location_type == 'FACILITY':
            sp = SupplyPointCase.get_by_location(user.location)
            if sp and not StockTransaction.objects.filter(case_id=sp._id, report__date__gte=date,
                                                          type='stockonhand').exists():
                if user.get_verified_number():
                        send_sms_to_verified_number(user.get_verified_number(), REMINDER_STOCKONHAND)
                        sp_ids.add(sp._id)
    update_statuses(sp_ids, SupplyPointStatusTypes.SOH_FACILITY, SupplyPointStatusValues.REMINDER_SENT)
Esempio n. 13
0
def get_location_rows(domain):
    users = CommTrackUser.by_domain(domain)

    mappings = []
    for user in users:
        locations = user.locations
        for location in locations:
            mappings.append(
                [user.raw_username, location.site_code, location.name])

    return mappings
Esempio n. 14
0
def send_supervision_reminder(domain, date):
    sp_ids = set()
    for user in CommTrackUser.by_domain(domain):
        if user.is_active and user.location and user.location.location_type == 'FACILITY':
            sp = SupplyPointCase.get_by_location(user.location)
            if sp and not SupplyPointStatus.objects.filter(supply_point=sp._id,
                                                           status_type=SupplyPointStatusTypes.SUPERVISION_FACILITY,
                                                           status_date__gte=date).exists():
                if user.get_verified_number():
                        send_sms_to_verified_number(user.get_verified_number(), REMINDER_SUPERVISION)
                        sp_ids.add(sp._id)
    update_statuses(sp_ids, SupplyPointStatusTypes.SUPERVISION_FACILITY, SupplyPointStatusValues.REMINDER_SENT)
Esempio n. 15
0
    def save(self):
        """
        Calculate which locations need added or removed, then submit
        one caseblock to handle this
        """
        user = CommTrackUser.get_by_username(self.username)
        if not user:
            raise UserUploadError(
                _('no username with {} found!'.format(self.username)))

        # have to rewrap since we need to force it to a commtrack user
        user = CommTrackUser.wrap(user.to_json())
        current_locations = user.locations
        current_location_codes = [loc.site_code for loc in current_locations]

        commit_list = {}
        messages = []

        def _add_loc(loc, clear=False):
            sp = self.get_supply_point_from_location(loc)
            if sp is None:
                messages.append(
                    _("No supply point found for location '{}'. "
                      "Make sure the location type is not set to administrative only "
                      "and that the location has a valid sms code.").format(
                          loc or ''))
            else:
                commit_list.update(user.supply_point_index_mapping(sp, clear))

        for loc in self.to_add:
            if loc not in current_location_codes:
                _add_loc(loc)
        for loc in self.to_remove:
            if loc in current_location_codes:
                _add_loc(loc, clear=True)

        if commit_list:
            submit_mapping_case_block(user, commit_list)

        return messages
Esempio n. 16
0
    def save(self):
        """
        Calculate which locations need added or removed, then submit
        one caseblock to handle this
        """
        user = CommTrackUser.wrap(CommTrackUser.get_by_username(self.username).to_json())
        current_locations = user.locations
        current_location_codes = [loc.site_code for loc in current_locations]

        commit_list = {}
        for loc in self.to_add:
            if loc not in current_location_codes:
                sp = self.get_supply_point_from_location(loc)
                commit_list.update(user.supply_point_index_mapping(sp))

        for loc in self.to_remove:
            if loc in current_location_codes:
                sp = self.get_supply_point_from_location(loc)
                commit_list.update(user.supply_point_index_mapping(sp, True))

        if commit_list:
            submit_mapping_case_block(user, commit_list)
Esempio n. 17
0
    def save(self, user):
        commtrack_user = CommTrackUser.wrap(user.to_json())
        location_id = self.cleaned_data['supply_point']
        if location_id:
            loc = Location.get(location_id)

            commtrack_user.clear_locations()
            commtrack_user.add_location(loc, create_sp_if_missing=True)

            # add the supply point case id to user data fields
            # so that the phone can auto select
            supply_point = SupplyPointCase.get_by_location(loc)
            user.user_data['commtrack-supply-point'] = supply_point._id
Esempio n. 18
0
    def save(self, user):
        commtrack_user = CommTrackUser.wrap(user.to_json())
        location_id = self.cleaned_data['supply_point']
        if location_id:
            loc = Location.get(location_id)

            commtrack_user.clear_locations()
            commtrack_user.add_location(loc, create_sp_if_missing=True)

            # add the supply point case id to user data fields
            # so that the phone can auto select
            supply_point = SupplyPointCase.get_by_location(loc)
            user.user_data['commtrack-supply-point'] = supply_point._id
Esempio n. 19
0
    def __init__(self, domain, v):
        self.domain = domain
        self.v = v

        self.location = None
        u = v.owner
        if domain.commtrack_enabled:
            # currently only support one location on the UI
            linked_loc = CommTrackUser.wrap(u.to_json()).location
            if linked_loc:
                self.location = get_supply_point(self.domain.name, loc=linked_loc)['case']

        self.C = domain.commtrack_settings
Esempio n. 20
0
def get_location_rows(domain):
    users = CommTrackUser.by_domain(domain)

    mappings = []
    for user in users:
        locations = user.locations
        for location in locations:
            mappings.append([
                user.raw_username,
                location.site_code,
                location.name
            ])

    return mappings
Esempio n. 21
0
    def save(self):
        """
        Calculate which locations need added or removed, then submit
        one caseblock to handle this
        """
        user = CommTrackUser.get_by_username(self.username)
        if not user:
            raise UserUploadError(_('no username with {} found!'.format(self.username)))

        # have to rewrap since we need to force it to a commtrack user
        user = CommTrackUser.wrap(user.to_json())
        current_locations = user.locations
        current_location_codes = [loc.site_code for loc in current_locations]

        commit_list = {}
        messages = []
        def _add_loc(loc, clear=False):
            sp = self.get_supply_point_from_location(loc)
            if sp is None:
                messages.append(_("No supply point found for location '{}'. "
                   "Make sure the location type is not set to administrative only "
                   "and that the location has a valid sms code."
                ).format(loc or ''))
            else:
                commit_list.update(user.supply_point_index_mapping(sp, clear))

        for loc in self.to_add:
            if loc not in current_location_codes:
                _add_loc(loc)
        for loc in self.to_remove:
            if loc in current_location_codes:
                _add_loc(loc, clear=True)

        if commit_list:
            submit_mapping_case_block(user, commit_list)

        return messages
Esempio n. 22
0
def send_supervision_reminder(domain, date):
    sp_ids = set()
    for user in CommTrackUser.by_domain(domain):
        if user.is_active and user.location and user.location.location_type == 'FACILITY':
            sp = SupplyPointCase.get_by_location(user.location)
            if sp and not SupplyPointStatus.objects.filter(
                    supply_point=sp._id,
                    status_type=SupplyPointStatusTypes.SUPERVISION_FACILITY,
                    status_date__gte=date).exists():
                if user.get_verified_number():
                    send_sms_to_verified_number(user.get_verified_number(),
                                                REMINDER_SUPERVISION)
                    sp_ids.add(sp._id)
    update_statuses(sp_ids, SupplyPointStatusTypes.SUPERVISION_FACILITY,
                    SupplyPointStatusValues.REMINDER_SENT)
Esempio n. 23
0
def bootstrap_user(setup, username=TEST_USER, domain=TEST_DOMAIN,
                   phone_number=TEST_NUMBER, password=TEST_PASSWORD,
                   backend=TEST_BACKEND, first_name='', last_name='',
                   home_loc=None, user_data=None,
                   ):
    user_data = user_data or {}
    user = CommTrackUser.create(
        domain,
        username,
        password,
        phone_numbers=[TEST_NUMBER],
        user_data=user_data,
        first_name=first_name,
        last_name=last_name
    )
    if home_loc == setup.loc.site_code:
        if not SupplyPointCase.get_by_location(setup.loc):
            make_supply_point(domain, setup.loc)

        user.add_location(setup.loc)
        user.save()

    user.save_verified_number(domain, phone_number, verified=True, backend_id=backend)
    return CommTrackUser.wrap(user.to_json())
Esempio n. 24
0
    def setUp(self):
        super(UserLocMapTest, self).setUp()

        self.user = CommCareUser.create(self.domain.name,
                                        'commcareuser',
                                        'password',
                                        phone_numbers=['123123'],
                                        user_data={},
                                        first_name='test',
                                        last_name='user')
        self.ct_user = CommTrackUser.wrap(self.user.to_json())

        self.loc = make_loc('secondloc')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.cache = LocationCache()
        self.mapping = UserLocMapping(self.user.username, self.user.domain,
                                      self.cache)
Esempio n. 25
0
    def __init__(self, domain, v):
        self.domain = domain
        self.v = v

        self.location = None
        u = v.owner

        if domain.commtrack_enabled:
            # if user is not actually a user, we let someone else process
            if not isinstance(u, CouchUser):
                raise NotAUserClassError

            # currently only support one location on the UI
            linked_loc = CommTrackUser.wrap(u.to_json()).location
            if linked_loc:
                self.location = get_supply_point(self.domain.name, loc=linked_loc)

        self.C = domain.commtrack_settings
Esempio n. 26
0
    def setUp(self):
        super(UserLocMapTest, self).setUp()

        self.user = CommCareUser.create(
            self.domain.name,
            'commcareuser',
            'password',
            phone_numbers=['123123'],
            user_data={},
            first_name='test',
            last_name='user'
        )
        self.ct_user = CommTrackUser.wrap(self.user.to_json())

        self.loc = make_loc('secondloc')
        self.sp = make_supply_point(self.domain, self.loc)
        self.cache = LocationCache()
        self.mapping = UserLocMapping(self.user.username, self.user.domain, self.cache)
Esempio n. 27
0
 def owner(self):
     if self.owner_doc_type == "CommCareCase":
         # Circular import
         from corehq.apps.sms.models import CommConnectCase
         return CommConnectCase.get(self.owner_id)
     elif self.owner_doc_type == "CommCareUser":
         # Circular import
         from corehq.apps.users.models import CommCareUser
         return CommCareUser.get(self.owner_id)
     elif self.owner_doc_type == "CommTrackUser":
         # Circular import
         from corehq.apps.commtrack.models import CommTrackUser
         return CommTrackUser.get(self.owner_id)
     elif self.owner_doc_type == 'WebUser':
         # Circular importsms
         from corehq.apps.users.models import WebUser
         return WebUser.get(self.owner_id)
     else:
         return None
Esempio n. 28
0
 def owner(self):
     if self.owner_doc_type == "CommCareCase":
         # Circular import
         from corehq.apps.sms.models import CommConnectCase
         return CommConnectCase.get(self.owner_id)
     elif self.owner_doc_type == "CommCareUser":
         # Circular import
         from corehq.apps.users.models import CommCareUser
         return CommCareUser.get(self.owner_id)
     elif self.owner_doc_type == "CommTrackUser":
         # Circular import
         from corehq.apps.commtrack.models import CommTrackUser
         return CommTrackUser.get(self.owner_id)
     elif self.owner_doc_type == 'WebUser':
         # Circular importsms
         from corehq.apps.users.models import WebUser
         return WebUser.get(self.owner_id)
     else:
         return None
Esempio n. 29
0
    def __init__(self, domain, v):
        self.domain = domain
        self.v = v

        self.location = None
        u = v.owner

        if domain.commtrack_enabled:
            # if user is not actually a user, we let someone else process
            if not isinstance(u, CouchUser):
                raise NotAUserClassError

            # currently only support one location on the UI
            linked_loc = CommTrackUser.wrap(u.to_json()).location
            if linked_loc:
                self.location = get_supply_point(self.domain.name,
                                                 loc=linked_loc)

        self.C = domain.commtrack_settings
Esempio n. 30
0
def _get_location(form):
    loc = None
    if 'location_id' in form.form:
        loc_id = form.form['location_id']
        try:
            loc = Location.get(loc_id)
        except ResourceNotFound:
            logging.info('Location %s Not Found.' % loc_id)
    else:
        user_id = form['auth_context']['user_id']
        if not user_id:
            return None
        user = CommTrackUser.get(user_id)
        try:
            loc = user.location
        except ResourceNotFound:
            logging.info('Location %s Not Found.' % loc)

    return loc
Esempio n. 31
0
    def test_location_migration(self):
        user = CommCareUser.create(
            self.domain.name,
            'commcareuser',
            'password',
            phone_numbers=['123123'],
            user_data={},
            first_name='test',
            last_name='user'
        )

        loc = make_loc('someloc')
        make_supply_point(self.domain.name, loc)

        user.commtrack_location = loc._id
        ct_user = CommTrackUser.wrap(user.to_json())

        self.assertEqual(1, len(ct_user.locations))
        self.assertEqual('someloc', ct_user.locations[0].name)
        self.assertFalse(hasattr(ct_user, 'commtrack_location'))
Esempio n. 32
0
    def test_location_migration(self):
        user = CommCareUser.create(
            self.domain.name,
            'commcareuser',
            'password',
            phone_numbers=['123123'],
            user_data={},
            first_name='test',
            last_name='user'
        )

        loc = make_loc('someloc')
        make_supply_point(self.domain.name, loc)

        user.commtrack_location = loc._id
        ct_user = CommTrackUser.wrap(user.to_json())

        self.assertEqual(1, len(ct_user.locations))
        self.assertEqual('someloc', ct_user.locations[0].name)
        self.assertFalse(hasattr(ct_user, 'commtrack_location'))
Esempio n. 33
0
def location_fixture_generator(user, version, case_sync_op=None, last_sync=None):
    """
    By default this will generate a fixture for the users
    location and it's "footprint", meaning the path
    to a root location through parent hierarchies.

    There is an admin feature flag that will make this generate
    a fixture with ALL locations for the domain.
    """
    project = user.project
    if (not project or not project.commtrack_enabled
        or not project.commtrack_settings
        or not project.commtrack_settings.sync_location_fixtures):
            return []

    rewrapped_user = CommTrackUser.wrap(user.to_json())
    if toggles.SYNC_ALL_LOCATIONS.enabled(user.domain):
        location_db = _location_footprint(Location.by_domain(user.domain))
    else:
        location_db = _location_footprint(rewrapped_user.locations)

    if not should_sync_locations(last_sync, location_db):
        return []

    root = ElementTree.Element('fixture',
                               {'id': 'commtrack:locations',
                                'user_id': user.user_id})

    loc_types = project.commtrack_settings.location_types
    type_to_slug_mapping = dict((ltype.name, ltype.code) for ltype in loc_types)

    def location_type_lookup(location_type):
        return type_to_slug_mapping.get(location_type, unicode_slug(location_type))

    if toggles.SYNC_ALL_LOCATIONS.enabled(user.domain):
        root_locations = Location.root_locations(user.domain)
    else:
        root_locations = filter(lambda loc: loc.parent_id is None, location_db.by_id.values())

    _append_children(root, location_db, root_locations, location_type_lookup)
    return [root]
Esempio n. 34
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)
Esempio n. 35
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 = DeliveryGroups().current_submitting_group(date.month)
    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)
Esempio n. 36
0
def add_location(user, location_id):
    commtrack_user = CommTrackUser.wrap(user.to_json())
    if location_id:
        loc = Location.get(location_id)
        commtrack_user.clear_locations()
        commtrack_user.add_location(loc, create_sp_if_missing=True)
Esempio n. 37
0
 def send_message(self, location, message, **kwargs):
     for user in CommTrackUser.by_domain(self.domain):
         dm = user.get_domain_membership(self.domain)
         if dm.location_id == location._id and user.get_verified_number():
             send_sms_to_verified_number(user.get_verified_number(),
                                         message % kwargs)
Esempio n. 38
0
 def _send_delivery_alert_to_facilities(self, sp_name, location):
     locs = [c._id for c in location.children]
     users = filter(lambda u: u.domain_membership["location_id"] in locs, CommTrackUser.by_domain(self.domain))
     for user in users:
         if user.get_verified_number():
             send_sms_to_verified_number(user.get_verified_number(), DELIVERY_CONFIRM_CHILDREN % {"district_name": sp_name})
Esempio n. 39
0
def add_location(user, location_id):
    commtrack_user = CommTrackUser.wrap(user.to_json())
    if location_id:
        loc = Location.get(location_id)
        commtrack_user.clear_locations()
        commtrack_user.add_location(loc, create_sp_if_missing=True)
Esempio n. 40
0
 def send_message(self, location, message, **kwargs):
     for user in CommTrackUser.by_domain(self.domain):
         dm = user.get_domain_membership(self.domain)
         if dm.location_id == location._id and user.get_verified_number():
             send_sms_to_verified_number(user.get_verified_number(), message % kwargs)
Esempio n. 41
0
 def _send_submission_alert_to_msd(self, params):
     users = filter(lambda u: u.user_data.get('role', None) == 'MSD', CommTrackUser.by_domain(self.domain))
     for user in users:
         if user.get_verified_number():
             send_sms_to_verified_number(user.get_verified_number(), SUBMITTED_NOTIFICATION_MSD % params)