(self, device_id, when=None, commcare_version=None, device_app_meta=None)
return False
Sets the last_used date for the device to be the current time
        Does NOT save the user object.

        :returns: True if user was updated and needs to be saved
Sets the last_used date for the device to be the current time
        Does NOT save the user object.
Sets the last_used date for the device to be the current time Does NOT save the user object .
def update_device_id_last_used(self, device_id, when=None, commcare_version=None, device_app_meta=None):
        """
        Sets the last_used date for the device to be the current time
        Does NOT save the user object.

        :returns: True if user was updated and needs to be saved
        """
        when = when or datetime.utcnow()

        device = self.get_device(device_id)
        if device:
            do_update = False
            if when.date() > device.last_used.date():
                do_update = True
            elif device_app_meta:
                existing_app_meta = device.get_meta_for_app(device_app_meta.app_id)
                if not existing_app_meta:
                    do_update = True
                else:
                    last_request = device_app_meta.last_request
                    do_update = (
                        last_request
                        and existing_app_meta.last_request
                        and last_request > existing_app_meta.last_request.date()
                    )

            if do_update:
                device.last_used = when
                device.update_meta(commcare_version, device_app_meta)

                self.last_device = DeviceIdLastUsed.wrap(self.get_last_used_device().to_json())
                meta = self.last_device.get_last_used_app_meta()
                self.last_device.app_meta = [meta] if meta else []
                return True
        else:
            device = DeviceIdLastUsed(device_id=device_id, last_used=when)
            device.update_meta(commcare_version, device_app_meta)
            self.devices.append(device)
            self.last_device = device
            return True
        return False
def update_device_id_last_used ( self , device_id , when = None , commcare_version = None , device_app_meta = None ) : when = when or datetime . utcnow ( ) device = self . get_device ( device_id ) if device : do_update = False if when . date ( ) > device . last_used . date ( ) : do_update = True elif device_app_meta : existing_app_meta = device . get_meta_for_app ( device_app_meta . app_id ) if not existing_app_meta : do_update = True else : last_request = device_app_meta . last_request do_update = ( last_request and existing_app_meta . last_request and last_request > existing_app_meta . last_request . date ( ) ) if do_update : device . last_used = when device . update_meta ( commcare_version , device_app_meta ) self . last_device = DeviceIdLastUsed . wrap ( self . get_last_used_device ( ) . to_json ( ) ) meta = self . last_device . get_last_used_app_meta ( ) self . last_device . app_meta = [ meta ] if meta else [ ] return True else : device = DeviceIdLastUsed ( device_id = device_id , last_used = when ) device . update_meta ( commcare_version , device_app_meta ) self . devices . append ( device ) self . last_device = device return True return False