Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (email@example.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 <https://www.gnu.org/licenses/>.
Representation of the client devices.
- class camcops_server.cc_modules.cc_device.Device(**kwargs)¶
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
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] ¶
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] ¶
Returns a device by its name.
- get_friendly_name() str ¶
Get the device’s friendly name (or failing that, its name).
- get_friendly_name_and_id() str ¶
Get a formatted representation of the device (name, ID, friendly name).
- get_id() int ¶
Get the device’s integer ID.
- classmethod get_server_device(dbsession: sqlalchemy.orm.session.Session) camcops_server.cc_modules.cc_device.Device ¶
Return the special device meaning “the server”, creating it if it doesn’t already exist.
- is_valid() bool ¶
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¶
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 ¶
Overriding this function is one way of providing a report. (The other is
To override this function, return the SQLAlchemy Base
Selectstatement or the SQLAlchemy ORM
Queryto execute the report.
Parameters are passed in via the request.