14.2.38. camcops_server.cc_modules.cc_device

camcops_server/cc_modules/cc_device.py


Copyright (C) 2012-2019 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.


Representation of the client devices.

class camcops_server.cc_modules.cc_device.Device(**kwargs)[source]

Represents a tablet (client) device.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

classmethod get_device_by_id(dbsession: sqlalchemy.orm.session.Session, device_id: int) → Union[_ForwardRef('Device'), NoneType][source]

Returns a device by its integer ID.

classmethod get_device_by_name(dbsession: sqlalchemy.orm.session.Session, device_name: str) → Union[_ForwardRef('Device'), NoneType][source]

Returns a device by its name.

get_friendly_name() → str[source]

Get the device’s friendly name (or failing that, its name).

get_friendly_name_and_id() → str[source]

Get a formatted representation of the device (name, ID, friendly name).

get_id() → int[source]

Get the device’s integer ID.

classmethod get_server_device(dbsession: sqlalchemy.orm.session.Session) → camcops_server.cc_modules.cc_device.Device[source]

Return the special device meaning “the server”, creating it if it doesn’t already exist.

is_valid() → bool[source]

Having instantiated an instance with Device(device_id), this function reports whether it is a valid device, i.e. is it in the database?

class camcops_server.cc_modules.cc_device.DeviceReport[source]

Report to show registered devices. This is a superuser-only report, so we do not override superuser_only.

get_query(req: CamcopsRequest) → sqlalchemy.orm.query.Query[source]

Overriding this function is one way of providing a report. (The other is get_rows_colnames().)

To override this function, return the SQLAlchemy Base Select statement or the SQLAlchemy ORM Query to execute the report.

Parameters are passed in via the request.

class camcops_server.cc_modules.cc_device.DeviceTests(methodName='runTest')[source]

Unit tests.

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.