14.2.67. camcops_server.cc_modules.cc_device


Copyright (C) 2012-2020 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) → Optional[camcops_server.cc_modules.cc_device.Device][source]

Returns a device by its integer ID.

classmethod get_device_by_name(dbsession: sqlalchemy.orm.session.Session, device_name: str) → Optional[camcops_server.cc_modules.cc_device.Device][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.

classmethod title(req: CamcopsRequest) → str[source]

Descriptive title for display purposes.

class camcops_server.cc_modules.cc_device.DeviceTests(*args, echo: bool = False, database_on_disk: bool = True, **kwargs)[source]

Unit tests.

  • echo – Turn on SQL echo?

  • database_on_disk – Use on-disk (rather than in-memory) SQLite database? Allows dumping of contents.