(self, unretired_by_domain, unretired_by, unretired_via=None)
return True, None
This un-deletes a user, but does not fully restore the state to
        how it previously was. Using this has these caveats:
        - It will not restore Case Indexes that were removed
        - It will not restore the user's phone numbers
        - It will not restore reminders for cases
This un-deletes a user, but does not fully restore the state to
        how it previously was. Using this has these caveats:
        - It will not restore Case Indexes that were removed
        - It will not restore the user's phone numbers
        - It will not restore reminders for cases
This un - deletes a user but does not fully restore the state to how it previously was . Using this has these caveats : - It will not restore Case Indexes that were removed - It will not restore the user s phone numbers - It will not restore reminders for cases
def unretire(self, unretired_by_domain, unretired_by, unretired_via=None):
        """
        This un-deletes a user, but does not fully restore the state to
        how it previously was. Using this has these caveats:
        - It will not restore Case Indexes that were removed
        - It will not restore the user's phone numbers
        - It will not restore reminders for cases
        """
        from corehq.apps.users.model_log import UserModelAction

        if not unretired_by and not settings.UNIT_TESTING:
            raise ValueError("Missing unretired_by")

        by_username = self.get_db().view('users/by_username', key=self.username, reduce=False).first()
        if by_username and by_username['id'] != self._id:
            return False, "A user with the same username already exists in the system"
        if self.base_doc.endswith(DELETED_SUFFIX):
            self.base_doc = self.base_doc[:-len(DELETED_SUFFIX)]

        deleted_form_ids = self._get_deleted_form_ids()
        FormAccessors(self.domain).soft_undelete_forms(deleted_form_ids)

        deleted_case_ids = self._get_deleted_case_ids()
        CaseAccessors(self.domain).soft_undelete_cases(deleted_case_ids)

        undelete_system_forms.delay(self.domain, set(deleted_form_ids), set(deleted_case_ids))
        self.save()
        if unretired_by:
            log_user_change(
                by_domain=unretired_by_domain,
                for_domain=self.domain,
                couch_user=self,
                changed_by_user=unretired_by,
                changed_via=unretired_via,
                action=UserModelAction.CREATE,
            )
        return True, None
def unretire ( self , unretired_by_domain , unretired_by , unretired_via = None ) : from corehq . apps . users . model_log import UserModelAction if not unretired_by and not settings . UNIT_TESTING : raise ValueError ( "Missing unretired_by" ) by_username = self . get_db ( ) . view ( 'users/by_username' , key = self . username , reduce = False ) . first ( ) if by_username and by_username [ 'id' ] != self . _id : return False , "A user with the same username already exists in the system" if self . base_doc . endswith ( DELETED_SUFFIX ) : self . base_doc = self . base_doc [ : - len ( DELETED_SUFFIX ) ] deleted_form_ids = self . _get_deleted_form_ids ( ) FormAccessors ( self . domain ) . soft_undelete_forms ( deleted_form_ids ) deleted_case_ids = self . _get_deleted_case_ids ( ) CaseAccessors ( self . domain ) . soft_undelete_cases ( deleted_case_ids ) undelete_system_forms . delay ( self . domain , set ( deleted_form_ids ) , set ( deleted_case_ids ) ) self . save ( ) if unretired_by : log_user_change ( by_domain = unretired_by_domain , for_domain = self . domain , couch_user = self , changed_by_user = unretired_by , changed_via = unretired_via , action = UserModelAction . CREATE , ) return True , None