Exemplo n.º 1
0
    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
Exemplo n.º 2
0
	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
Exemplo n.º 3
0
	def get_devices(self):
		return UserDevice.get_by_id(self.devices, self)
Exemplo n.º 4
0
 def get_devices(self):
     return UserDevice.get_by_id(self.devices, self)