def get_device(self): # If ID supplied, find and update that ID. input = web.input(id=None) devices = UserDevices.get_user_device_collection( users.get_current_user()) device = UserDevice(parent=devices) if input.id and long(input.id) > 0: # Load device from ID. device = UserDevice.get_by_id(long(input.id), devices) if not device: # Invalid ID. 404. raise web.notfound() # Check that the device belongs to the logged in user. if device.owner.user_id() != users.get_current_user().user_id(): # It's not theirs. 404. # TODO: Test this more and better. raise web.notfound() return device
def get_device(self): # If ID supplied, find and update that ID. input = web.input(id = None) devices = UserDevices.get_user_device_collection(users.get_current_user()) device = UserDevice(parent=devices) if input.id and long(input.id) > 0: # Load device from ID. device = UserDevice.get_by_id(long(input.id), devices) if not device: # Invalid ID. 404. raise web.notfound() # Check that the device belongs to the logged in user. if device.owner.user_id() != users.get_current_user().user_id(): # It's not theirs. 404. # TODO: Test this more and better. raise web.notfound() return device
def get_devices(self): return UserDevice.get_by_id(self.devices, self)