def is_mobile_number_unique_for_paid_account(org,mobile_number): manager = get_database_manager_for_org(org) try: find_reporters_by_from_number(manager, mobile_number) return False except NumberNotRegisteredException: return True
def safe_delete_reporter_by_phone(manager, mobile_number): try : users = find_reporters_by_from_number(manager, mobile_number) for user in users: user.delete() except NumberNotRegisteredException: pass
def _is_phone_number_unique(self, dbm, phone_number, reporter_id): from mangrove.transport.repository.reporters import find_reporters_by_from_number try: registered_reporters = find_reporters_by_from_number(dbm, self._clean(phone_number)) except NumberNotRegisteredException: return True if len(registered_reporters) == 1 and registered_reporters[0].short_code == reporter_id: return True return False
def is_mobile_number_unique_for_paid_account(org, mobile_number, reporter_id=None): manager = get_database_manager_for_org(org) from mangrove.transport.repository.reporters import find_reporters_by_from_number try: registered_reporters = find_reporters_by_from_number(manager, mobile_number) except NumberNotRegisteredException: return True if len(registered_reporters) == 1 and registered_reporters[0].short_code == reporter_id: return True return False
def is_mobile_number_unique_for_paid_account(self): manager = get_database_manager_for_org(self.organization) try: registered_reporters = find_reporters_by_from_number( manager, self.mobile_number) except NumberNotRegisteredException: return True, '' if len(registered_reporters) == 1 and registered_reporters[ 0].short_code == self.reporter_id: return True, '' return False, validation_message_dict['paid_account_duplicate']