15.2.184. camcops_server.cc_modules.webview

camcops_server/cc_modules/webview.py


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 <https://www.gnu.org/licenses/>.


Implements the CamCOPS web front end.

Quick tutorial on Pyramid views:

  • The configurator registers routes, and routes have URLs associated with them. Those URLs can be templatized, e.g. to accept numerical parameters. The configurator associates view callables (“views” for short) with routes, and one method for doing that is an automatic scan via Venusian for views decorated with @view_config().

  • All views take a Request object and return a Response or raise an exception that Pyramid will translate into a Response.

  • Having matched a route, Pyramid uses its “view lookup” process to choose one from potentially several views. For example, a single route might be associated with:

    @view_config(route_name="myroute")
    def myroute_default(req: Request) -> Response:
        pass
    
    @view_config(route_name="myroute", request_method="POST")
    def myroute_post(req: Request) -> Response:
        pass
    

    In this example, POST requests will go to the second; everything else will go to the first. Pyramid’s view lookup rule is essentially: if multiple views match, choose the one with the most specifiers.

  • Specifiers include:

    route_name=ROUTENAME
    
        the route
    
    request_method="POST"
    
        requires HTTP GET, POST, etc.
    
    request_param="XXX"
    
        ... requires the presence of a GET/POST variable with this name in
        the request.params dictionary
    
    request_param="XXX=YYY"
    
        ... requires the presence of a GET/POST variable called XXX whose
        value is YYY, in the request.params dictionary
    
    match_param="XXX=YYY"
    
        .. requires the presence of this key/value pair in
        request.matchdict, which contains parameters from the URL
    

    https://docs.pylonsproject.org/projects/pyramid/en/latest/api/config.html#pyramid.config.Configurator.add_view # noqa

  • Getting parameters

    request.params
    
        ... parameters from HTTP GET or POST, including both the query
        string (as in https://somewhere/path?key=value) and the body (e.g.
        POST).
    
    request.matchdict
    
        ... parameters from the URL, via URL dispatch; see
        https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#urldispatch-chapter  # noqa
    
  • Regarding rendering:

    There might be some simplicity benefits from converting to a template system like Mako. On the downside, that would entail a bit more work; likely a minor performance hit (relative to plain Python string rendering); and a loss of type checking. The type checking is also why we prefer:

    html = " ... {param_blah} ...".format(param_blah=PARAM.BLAH)
    

    to

    html = " ... {PARAM.BLAH} ...".format(PARAM=PARAM)
    

    as in the first situation, PyCharm will check that “BLAH” is present in “PARAM”, and in the second it won’t. Automatic checking is worth a lot.

class camcops_server.cc_modules.webview.AddPatientView(request: CamcopsRequest)[source]

View to add a patient (for task scheduling).

dispatch() → pyramid.response.Response[source]

Try to dispatch to the right HTTP method (e.g. GET, POST). If a method doesn’t exist, defer to the error handler. Also defer to the error handler if the request method isn’t on the approved list.

form_class

alias of camcops_server.cc_modules.cc_forms.EditServerCreatedPatientForm

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

save_object(appstruct: Dict[str, Any]) → None[source]

Saves the object in the database, from data provided via the form.

class camcops_server.cc_modules.webview.AddTaskScheduleItemView(request: CamcopsRequest)[source]

Django-style view class to add a task schedule item.

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

get_form_values() → Dict[source]

Reads form values from the object (or provides an empty dictionary if there is no object yet).

class camcops_server.cc_modules.webview.AddTaskScheduleView(request: CamcopsRequest)[source]

Django-style view class to add a task schedule.

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

class camcops_server.cc_modules.webview.DeleteServerCreatedPatientView(request: CamcopsRequest)[source]

View to delete a patient that had been created on the server.

delete() → None[source]

Delete the fetched object

form_class

alias of camcops_server.cc_modules.cc_forms.DeleteServerCreatedPatientForm

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

object_class

alias of camcops_server.cc_modules.cc_patient.Patient

class camcops_server.cc_modules.webview.DeleteTaskScheduleItemView(request: CamcopsRequest)[source]

Django-style view class to delete a task schedule item.

form_class

alias of camcops_server.cc_modules.cc_forms.DeleteTaskScheduleItemForm

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

class camcops_server.cc_modules.webview.DeleteTaskScheduleView(request: CamcopsRequest)[source]

Django-style view class to delete a task schedule.

form_class

alias of camcops_server.cc_modules.cc_forms.DeleteTaskScheduleForm

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

class camcops_server.cc_modules.webview.EditFinalizedPatientView(request: CamcopsRequest)[source]

View to edit a finalized patient.

form_class

alias of camcops_server.cc_modules.cc_forms.EditFinalizedPatientForm

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.EditGroupView(request: CamcopsRequest)[source]

Django-style view to edit a CamCOPS group.

form_class

alias of camcops_server.cc_modules.cc_forms.EditGroupForm

get_form_kwargs() → Dict[str, Any][source]

Return the keyword arguments for instantiating the form.

get_form_values() → Dict[source]

Reads form values from the object (or provides an empty dictionary if there is no object yet).

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

object_class

alias of camcops_server.cc_modules.cc_group.Group

save_object(appstruct: Dict[str, Any]) → None[source]

Saves the object in the database, from data provided via the form.

class camcops_server.cc_modules.webview.EditPatientBaseView(request: CamcopsRequest)[source]

View to edit details for a patient.

get_context_data(**kwargs: Any) → Any[source]

Insert the rendered form (as HTML) into the context dict.

save_object(appstruct: Dict[str, Any]) → None[source]

Saves the object in the database, from data provided via the form.

class camcops_server.cc_modules.webview.EditServerCreatedPatientView(request: CamcopsRequest)[source]

View to edit a patient created on the server (as part of task scheduling).

form_class

alias of camcops_server.cc_modules.cc_forms.EditServerCreatedPatientForm

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.EditTaskScheduleItemMixin[source]

Django-style view class to edit a task schedule item.

class camcops_server.cc_modules.webview.EditTaskScheduleItemView(request: CamcopsRequest)[source]

Django-style view class to edit a task schedule item.

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

get_form_values() → Dict[source]

Reads form values from the object (or provides an empty dictionary if there is no object yet).

class camcops_server.cc_modules.webview.EditTaskScheduleView(request: CamcopsRequest)[source]

Django-style view class to edit a task schedule.

get_extra_context() → Dict[str, Any][source]

Override to provide extra context, merged in by get_context_data().

class camcops_server.cc_modules.webview.EditUserGroupMembershipBaseView(request: CamcopsRequest)[source]

Django-style view to edit a user’s group membership.

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

object_class

alias of camcops_server.cc_modules.cc_membership.UserGroupMembership

class camcops_server.cc_modules.webview.EditUserGroupMembershipGroupAdminView(request: CamcopsRequest)[source]
form_class

alias of camcops_server.cc_modules.cc_forms.EditUserGroupMembershipGroupAdminForm

class camcops_server.cc_modules.webview.EditUserGroupMembershipSuperUserView(request: CamcopsRequest)[source]
form_class

alias of camcops_server.cc_modules.cc_forms.EditUserGroupPermissionsFullForm

class camcops_server.cc_modules.webview.EraseTaskBaseView(request: CamcopsRequest)[source]

Django-style view to erase a task.

form_class

alias of camcops_server.cc_modules.cc_forms.EraseTaskForm

get_cancel_url() → str[source]

Return the URL to redirect to when cancelling a form.

class camcops_server.cc_modules.webview.EraseTaskEntirelyView(request: CamcopsRequest)[source]

Django-style view to erase (delete) a task entirely.

delete() → None[source]

Delete the fetched object

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.EraseTaskLeavingPlaceholderView(request: CamcopsRequest)[source]

Django-style view to erase data from a task, leaving an empty “placeholder”.

delete() → None[source]

Delete the fetched object

get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.PatientMixin[source]

Mixin for views involving a patient.

object_class

alias of camcops_server.cc_modules.cc_patient.Patient

class camcops_server.cc_modules.webview.SendEmailFromPatientListView(*args, **kwargs)[source]
get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.SendEmailFromPatientTaskScheduleView(*args, **kwargs)[source]
get_success_url() → str[source]

Return the URL to redirect to after processing a valid form.

class camcops_server.cc_modules.webview.SendPatientEmailBaseView(*args, **kwargs)[source]
__init__(*args, **kwargs) → None[source]

Args: request:

dispatch() → pyramid.response.Response[source]

Try to dispatch to the right HTTP method (e.g. GET, POST). If a method doesn’t exist, defer to the error handler. Also defer to the error handler if the request method isn’t on the approved list.

form_class

alias of camcops_server.cc_modules.cc_forms.SendEmailForm

form_valid(form: Form, appstruct: Dict[str, Any]) → pyramid.response.Response[source]

Called when the form is valid. Redirects to the supplied “success” URL.

get_context_data(**kwargs: Any) → Dict[str, Any][source]

Insert the rendered form (as HTML) into the context dict.

class camcops_server.cc_modules.webview.TaskScheduleItemMixin[source]

Mixin for viewing/editing a task schedule items.

form_class

alias of camcops_server.cc_modules.cc_forms.EditTaskScheduleItemForm

object_class

alias of camcops_server.cc_modules.cc_taskschedule.TaskScheduleItem

class camcops_server.cc_modules.webview.TaskScheduleMixin[source]

Mixin for viewing/editing a task schedule.

form_class

alias of camcops_server.cc_modules.cc_forms.EditTaskScheduleForm

object_class

alias of camcops_server.cc_modules.cc_taskschedule.TaskSchedule

camcops_server.cc_modules.webview.account_locked(req: camcops_server.cc_modules.cc_request.CamcopsRequest, locked_until: pendulum.datetime.DateTime) → pyramid.response.Response[source]

Response given when account locked out. Returned by login_view() only.

camcops_server.cc_modules.webview.add_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to add a group. Superusers only.

camcops_server.cc_modules.webview.add_id_definition(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to add an ID number definition. Superusers only.

camcops_server.cc_modules.webview.add_patient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to add a patient.

camcops_server.cc_modules.webview.add_special_note(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to add a special note to a task (after confirmation).

camcops_server.cc_modules.webview.add_task_schedule(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to add a task schedule.

camcops_server.cc_modules.webview.add_task_schedule_item(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to add a task schedule item.

camcops_server.cc_modules.webview.add_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to add a user.

camcops_server.cc_modules.webview.any_records_use_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest, group: camcops_server.cc_modules.cc_group.Group) → bool[source]

Do any records in the database refer to the specified group?

(Used when we’re thinking about deleting a group; would it leave broken references? If so, we will prevent deletion; see delete_group().)

camcops_server.cc_modules.webview.any_records_use_iddef(req: camcops_server.cc_modules.cc_request.CamcopsRequest, iddef: camcops_server.cc_modules.cc_idnumdef.IdNumDefinition) → bool[source]

Do any records in the database refer to the specified ID number definition?

(Used when we’re thinking about deleting one; would it leave broken references? If so, we will prevent deletion; see delete_id_definition().)

camcops_server.cc_modules.webview.any_records_use_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest, user: camcops_server.cc_modules.cc_user.User) → bool[source]

Do any records in the database refer to the specified user?

(Used when we’re thinking about deleting a user; would it leave broken references? If so, we will prevent deletion; see delete_user().)

camcops_server.cc_modules.webview.assert_may_administer_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest, group_id: int) → None[source]

Checks that the requesting user (req.user) is allowed to adminster the specified group (specified by group_id). Raises HTTPBadRequest otherwise.

camcops_server.cc_modules.webview.assert_may_edit_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest, user: camcops_server.cc_modules.cc_user.User) → None[source]

Checks that the requesting user (req.user) is allowed to edit the other user (user). Raises HTTPBadRequest otherwise.

camcops_server.cc_modules.webview.audit_menu(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Shows the auditing menu.

camcops_server.cc_modules.webview.bad_request(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

“Bad request” view.

NOTE that this view only gets used from

raise HTTPBadRequest("message")

and not

return HTTPBadRequest("message")

… so always raise it.

camcops_server.cc_modules.webview.change_other_password(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

For administrators, to change another’s password.

  • GET: offer “change another’s password” view (except that if you’re changing your own password, return change_own_password().

  • POST/submit: change the password and return password_changed().

camcops_server.cc_modules.webview.change_own_password(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

For any user: to change their own password.

  • GET: offer “change own password” view

  • POST/submit: change the password and return password_changed().

camcops_server.cc_modules.webview.choose_ctv(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to choose/configure a camcops_server.cc_modules.cc_tracker.ClinicalTextView.

camcops_server.cc_modules.webview.choose_tracker(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to choose/configure a camcops_server.cc_modules.cc_tracker.Tracker.

camcops_server.cc_modules.webview.choose_tracker_or_ctv(req: camcops_server.cc_modules.cc_request.CamcopsRequest, as_ctv: bool) → Dict[str, Any][source]

Returns a dictionary for a Mako template to configure a camcops_server.cc_modules.cc_tracker.Tracker or camcops_server.cc_modules.cc_tracker.ClinicalTextView.

Upon success, it redirects to the tracker or CTV view itself, with the tracker’s parameters embedded as URL parameters.

Parameters
camcops_server.cc_modules.webview.client_api_signposting(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Patients are likely to enter the /api address into a web browser, especially if it appears as a hyperlink in an email. If so, that will arrive as a GET request. This page will direct them to download the app.

camcops_server.cc_modules.webview.crash(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

A view that deliberately raises an exception.

camcops_server.cc_modules.webview.debug_form_rendering() → None[source]

Test code for form rendering.

From the command line:

# Start in the CamCOPS source root directory.
# - Needs the "-f" option to follow forks.
# - "open" doesn't show all files opened. To see what you need, try
#   strace cat /proc/version
# - ... which shows that "openat" is most useful.

strace -f --trace=openat \
    python -c 'from camcops_server.cc_modules.webview import debug_form_rendering; debug_form_rendering()' \
    | grep site-packages \
    | grep -v "\.pyc"

This tells us that the templates are files like:

site-packages/deform/templates/form.pt
site-packages/deform/templates/select.pt
site-packages/deform/templates/textinput.pt

On 2020-06-29 we are interested in why a newer (Docker) installation renders buggy HTML like:

<select name="which_idnum" id="deformField2" class=" form-control " multiple="False">
    <option value="1">CPFT RiO number</option>
    <option value="2">NHS number</option>
    <option value="1000">MyHospital number</option>
</select>

… the bug being that multiple="False" is wrong; an HTML boolean attribute is false when absent, not when set to a certain value (see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#Boolean_Attributes). The multiple attribute of <select> is a boolean attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select).

The select.pt file indicates that this is controlled by tal:attributes syntax. TAL is Template Attribution Language (https://sharptal.readthedocs.io/en/latest/tal.html).

TAL is either provided by Zope (given ZPT files) or Chameleon or both. The tracing suggests Chameleon. So the TAL language reference is https://chameleon.readthedocs.io/en/latest/reference.html.

Chameleon changelog is https://github.com/malthe/chameleon/blob/master/CHANGES.rst.

Multiple sources for tal:attributes syntax say that a null value (presumably: None) is required to omit the attribute, not a false value.

camcops_server.cc_modules.webview.delete_file(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Deletes a file.

camcops_server.cc_modules.webview.delete_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to delete a group. Superusers only.

camcops_server.cc_modules.webview.delete_id_definition(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to delete an ID number definition. Superusers only.

camcops_server.cc_modules.webview.delete_patient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to delete completely all data for a patient (after confirmation), within a specific group.

camcops_server.cc_modules.webview.delete_server_created_patient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Page to delete a patient created on the server (as part of task scheduling).

camcops_server.cc_modules.webview.delete_special_note(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to delete a special note (after confirmation).

camcops_server.cc_modules.webview.delete_task_schedule(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to delete a task schedule.

camcops_server.cc_modules.webview.delete_task_schedule_item(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to delete a task schedule item.

camcops_server.cc_modules.webview.delete_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to delete a user (and make it hard work).

camcops_server.cc_modules.webview.developer_page(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Shows the developer menu.

camcops_server.cc_modules.webview.download_area(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Shows the user download area.

camcops_server.cc_modules.webview.download_file(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Downloads a file.

camcops_server.cc_modules.webview.edit_filter(req: camcops_server.cc_modules.cc_request.CamcopsRequest, task_filter: camcops_server.cc_modules.cc_taskfilter.TaskFilter, redirect_url: str) → pyramid.response.Response[source]

Edit the task filter for the current user.

Parameters
camcops_server.cc_modules.webview.edit_finalized_patient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to edit details for a patient.

camcops_server.cc_modules.webview.edit_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to edit a group. Superusers only.

camcops_server.cc_modules.webview.edit_id_definition(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to edit an ID number definition. Superusers only.

camcops_server.cc_modules.webview.edit_server_created_patient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to edit details for a patient created on the server (for scheduling tasks).

camcops_server.cc_modules.webview.edit_server_settings(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to edit server settings (like the database title).

camcops_server.cc_modules.webview.edit_task_schedule(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to edit a task schedule.

camcops_server.cc_modules.webview.edit_task_schedule_item(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to edit a task schedule item.

camcops_server.cc_modules.webview.edit_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to edit a user (for administrators).

camcops_server.cc_modules.webview.edit_user_group_membership(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to edit the group memberships of a user (for administrators).

camcops_server.cc_modules.webview.erase_task_entirely(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to erase a task from the database entirely (after confirmation).

camcops_server.cc_modules.webview.erase_task_leaving_placeholder(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to wipe all data from a task (after confirmation).

Leaves the task record as a placeholder.

camcops_server.cc_modules.webview.forbidden(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Generic place that Pyramid comes when permission is denied for a view.

We will offer one of these:

  • Must change password? Redirect to “change own password” view.

  • Must agree terms? Redirect to “offer terms” view.

  • Otherwise: a generic “forbidden” view.

camcops_server.cc_modules.webview.forcibly_finalize(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to force-finalize all live (_era == ERA_NOW) records from a device. Available to group administrators if all those records are within their groups (otherwise, it’s a superuser operation).

camcops_server.cc_modules.webview.get_dump_collection(req: camcops_server.cc_modules.cc_request.CamcopsRequest)camcops_server.cc_modules.cc_taskcollection.TaskCollection[source]

Returns the collection of tasks being requested for a dump operation. Raises an error if the request is bad.

camcops_server.cc_modules.webview.get_group_from_request_group_id_or_raise(req: camcops_server.cc_modules.cc_request.CamcopsRequest)camcops_server.cc_modules.cc_group.Group[source]

Returns the camcops_server.cc_modules.cc_group.Group represented by the request’s ViewParam.GROUP_ID parameter, or raise HTTPBadRequest.

camcops_server.cc_modules.webview.get_iddef_from_request_which_idnum_or_raise(req: camcops_server.cc_modules.cc_request.CamcopsRequest)camcops_server.cc_modules.cc_idnumdef.IdNumDefinition[source]

Returns the camcops_server.cc_modules.cc_idnumdef.IdNumDefinition represented by the request’s ViewParam.WHICH_IDNUM parameter, or raise HTTPBadRequest.

camcops_server.cc_modules.webview.get_user_from_request_user_id_or_raise(req: camcops_server.cc_modules.cc_request.CamcopsRequest)camcops_server.cc_modules.cc_user.User[source]

Returns the camcops_server.cc_modules.cc_user.User represented by the request’s ViewParam.USER_ID parameter, or raise HTTPBadRequest.

camcops_server.cc_modules.webview.login_failed(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Response given after login failure. Returned by login_view() only.

camcops_server.cc_modules.webview.login_view(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Login view.

  • GET: presents the login screen

  • POST/submit: attempts to log in;

    • failure: returns a login failure view or an account lockout view

    • success:

      • redirects to the redirection view if one was specified;

      • redirects to the home view if not.

camcops_server.cc_modules.webview.logout(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Logs a session out, and returns the “logged out” view.

camcops_server.cc_modules.webview.main_menu(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Main CamCOPS menu view.

camcops_server.cc_modules.webview.not_found(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

“Page not found” view.

camcops_server.cc_modules.webview.offer_audit_trail(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to configure how we’ll view the audit trail. Once configured, it redirects to a view that shows the audit trail (with query parameters in the URL).

camcops_server.cc_modules.webview.offer_basic_dump(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to configure a basic research dump. Following submission success, it redirects to a view serving a TSV/ZIP dump.

camcops_server.cc_modules.webview.offer_exported_task_list(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to choose how we’ll view the exported task log.

camcops_server.cc_modules.webview.offer_report(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Offer configuration options for a single report, or (following submission) redirect to serve that report (with configuration parameters in the URL).

camcops_server.cc_modules.webview.offer_sql_dump(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to configure a SQL research dump. Following submission success, it redirects to a view serving the SQL dump.

camcops_server.cc_modules.webview.offer_terms(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]
  • GET: show terms/conditions and request acknowledgement

  • POST/submit: note the user’s agreement; redirect to the home view.

camcops_server.cc_modules.webview.password_changed(req: camcops_server.cc_modules.cc_request.CamcopsRequest, username: str, own_password: bool) → pyramid.response.Response[source]

Generic “the password has been changed” view (whether changing your own or another’s password).

Parameters
camcops_server.cc_modules.webview.reports_menu(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Offer a menu of reports.

Note: Reports are not group-specific. If you’re authorized to see any, you’ll see the whole menu. (The data you get will be restricted to the group’s you’re authorized to run reports for.)

camcops_server.cc_modules.webview.send_email_from_patient_list(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to send an email to a patient from the list of patients.

camcops_server.cc_modules.webview.send_email_from_patient_task_schedule(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to send an email to a patient from their task schedule page.

camcops_server.cc_modules.webview.serve_basic_dump(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View serving a TSV/ZIP basic research dump.

camcops_server.cc_modules.webview.serve_ctv(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to serve a camcops_server.cc_modules.cc_tracker.ClinicalTextView; see serve_tracker_or_ctv().

camcops_server.cc_modules.webview.serve_report(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Serve a configured report.

camcops_server.cc_modules.webview.serve_task(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View that serves an individual task, in a variety of possible formats (e.g. HTML, PDF, XML).

camcops_server.cc_modules.webview.serve_tracker(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to serve a camcops_server.cc_modules.cc_tracker.Tracker; see serve_tracker_or_ctv().

camcops_server.cc_modules.webview.serve_tracker_or_ctv(req: camcops_server.cc_modules.cc_request.CamcopsRequest, as_ctv: bool) → pyramid.response.Response[source]

Returns a response to show a camcops_server.cc_modules.cc_tracker.Tracker or camcops_server.cc_modules.cc_tracker.ClinicalTextView, in a variety of formats (e.g. HTML, PDF, XML).

Parameters
camcops_server.cc_modules.webview.set_filters(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to set the task filters for the current user.

camcops_server.cc_modules.webview.set_other_user_upload_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to set the upload group for another user.

camcops_server.cc_modules.webview.set_own_user_upload_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to set the upload group for your own user.

camcops_server.cc_modules.webview.set_user_upload_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest, user: camcops_server.cc_modules.cc_user.User, by_another: bool) → pyramid.response.Response[source]

Provides a view to choose which group a user uploads into.

TRUSTS ITS CALLER that this is permitted.

Parameters
camcops_server.cc_modules.webview.sql_dump(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View serving an SQL dump in the chosen format (e.g. SQLite binary, SQL).

camcops_server.cc_modules.webview.test_page_1(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

A public test page with no content.

camcops_server.cc_modules.webview.test_page_2(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

A private test page containing POTENTIALLY SENSITIVE test information, including environment variables, that should only be accessible to superusers.

camcops_server.cc_modules.webview.test_page_3(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

A private test page that tests template inheritance.

camcops_server.cc_modules.webview.test_page_4(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

A private test page that tests Mako filtering.

camcops_server.cc_modules.webview.test_page_private_1(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

A private test page with no informative content, but which should only be accessible to authenticated users.

camcops_server.cc_modules.webview.unlock_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to unlock a locked user account.

camcops_server.cc_modules.webview.view_all_users(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View all users that the current user administers. The view has hyperlinks to edit those users too.

camcops_server.cc_modules.webview.view_audit_trail(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to serve the audit trail.

camcops_server.cc_modules.webview.view_ddl(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

Inspect table definitions (data definition language, DDL) with field comments.

2021-04-30: restricted to users with “dump” authority – not because this is a vulnerability, as the penetration testers suggested, but just to make it consistent with the menu item for this.

camcops_server.cc_modules.webview.view_email(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_email.Email.

camcops_server.cc_modules.webview.view_export_recipient(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_exportmodels.ExportedTask.

camcops_server.cc_modules.webview.view_exported_task(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_exportmodels.ExportedTask.

camcops_server.cc_modules.webview.view_exported_task_email(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_exportmodels.ExportedTaskEmail.

camcops_server.cc_modules.webview.view_exported_task_file_group(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_exportmodels.ExportedTaskFileGroup.

camcops_server.cc_modules.webview.view_exported_task_hl7_message(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View on an individual camcops_server.cc_modules.cc_exportmodels.ExportedTaskHL7Message.

camcops_server.cc_modules.webview.view_exported_task_list(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → pyramid.response.Response[source]

View to serve the exported task log.

camcops_server.cc_modules.webview.view_groups(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to show all groups (with hyperlinks to edit them). Superusers only.

camcops_server.cc_modules.webview.view_id_definitions(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to show all ID number definitions (with hyperlinks to edit them). Superusers only.

camcops_server.cc_modules.webview.view_own_user_info(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to provide information about your own user.

camcops_server.cc_modules.webview.view_patient_task_schedule(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View scheduled tasks for one patient’s specific task schedule.

camcops_server.cc_modules.webview.view_patient_task_schedules(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View all patients and their assigned schedules (as well as their access keys, etc.).

camcops_server.cc_modules.webview.view_server_info(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to show the server’s ID policies, etc.

camcops_server.cc_modules.webview.view_task_schedule_items(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View items within a task schedule.

camcops_server.cc_modules.webview.view_task_schedules(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View whole task schedules.

camcops_server.cc_modules.webview.view_tasks(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

Main view displaying tasks and applicable filters.

camcops_server.cc_modules.webview.view_user(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View to show details of another user, for administrators.

camcops_server.cc_modules.webview.view_user_email_addresses(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → Dict[str, Any][source]

View e-mail addresses of all users that the requesting user is authorized to manage.