Shift Notes

Models

class pytm4srv.models.ShiftNotesSubmission

A record of shift notes being submitted by a user.

date: Mapped[date]

Date of the shift this submission is for (local time zone).

id: MappedColumn object at 0x7ec1c1979d80>]]

Unique, numeric ID of this shift notes submission.

machine_id: Mapped[int]

ID of the machine shift notes were submitted for.

shift_id: Mapped[int]

ID of the shift that notes were submitted for.

timestamp: Mapped[datetime]

Timestamp of the submission.

user_id: Mapped[int]

ID of the user who submitted shift notes.

class pytm4srv.models.ShiftNotesField

A custom form field to show during shift notes entry.

archived: Mapped[bool]

Whether this field is archived.

This allows a field to be hidden when entering shift notes, but kept around to access historical data.

hint: Mapped[str]

Optional help text to display near this field.

id: MappedColumn object at 0x7ec1c1979d80>]]

Unique, numeric ID of this field.

input_type: Mapped[str]

The type of input control to use for data entry.

Only the following values are supported:

Value

Description

text

A single line of text

textarea

Multiple lines of text

number

Numeric (integer or decimal) value

checkbox

Single checkbox, with the field’s name as the label

checklist

List of checkboxes (multi-selection allowed), one for each entry in options

radio

List of radio buttons (single selection only), one for each entry in options

machines

The list of machines that will display this field in their shift notes.

Clients can link or unlink this field to/from machines by setting a new list of machine IDs.

name: Mapped[str]

User-specified name for this field.

options: Mapped[List[str]]

List of available options. Only used for the checklist and radio input types.

required: Mapped[bool]

Whether this field is required (meaning submission is not allowed if the field is blank).

Input type

Validation logic

text

Any non-whitespace characters are entered

textarea

number

Any numeric value is entered

checkbox

The checkbox is checked

checklist

At least one option is selected

radio

shifts

The list of shifts that will display this field in their shift notes.

Clients can link or unlink this field to/from shifts by setting a new list of shift IDs.

class pytm4srv.models.ShiftNotesValue

A single value that was entered for a custom shift notes field.

field_id: Mapped[int]

The ID of the field this value is for.

id: MappedColumn object at 0x7ec1c1979d80>]]

Unique, numeric ID of this value.

submission_id: Mapped[int]

The ID of the submission during which this value was entered.

value: Mapped[Any]

The value entered for this field.

May be any valid JSON, but will usually be: - a string for text, textarea, and radio fields - a number for number fields - a boolean for checkbox fields - an object mapping each option (at the time of submission) to a boolean for checklist fields

Endpoints

GET /api/shiftNotes/list

Get the objects needing shift notes entry for the current shift on a machine.

Query Parameters:
  • machine_id (int) – the ID of the machine to get objects relating to (required)

  • shift_id (int) – the ID of the shift to get data for (required)

  • date (string) – get objects created on this date (format: YYYY-MM-DD) in local time (required)

Status Codes:
POST /api/shiftNotes/submit

Set the notes fields of many objects at once.

Query Parameters:
  • machine_id (int) – the ID of the machine to send a notification to (required)

  • shift_id (int) – the ID of the shift to submit notes for (required)

  • date (string) – the date (format: YYYY-MM-DD) in local time to submit notes for (required)

Status Codes:
GET /api/shiftNotes/submissions

Get shift notes submission history.

Query Parameters:
  • machine (int) – if set to the ID of a machine, only submissions for that machine will be returned.

  • shift (int) – if set to the ID of a shift, only submissions for that machine will be returned.

  • user (int) – if set to the ID of a user, only submissions for that machine will be returned.

  • start (float) – only submissions on or after this UNIX timestamp will be returned.

  • end (float) – only submissions on or before this UNIX timestamp will be returned.

Returns:

an object mapping submission ID to ShiftNotesSubmission object

GET /api/shiftNotes/fields

Get all custom shift notes fields.

Returns:

an object mapping shift notes field ID to ShiftNotesField object

PUT /api/shiftNotes/fields

Create a new custom shift notes field.

Reqjson:

a (partial) ShiftNotesField object (at least a name is required)

Status Codes:
Returns:

the new ShiftNotesField object

PATCH /api/shiftNotes/fields/(int: field_id)

Edit an existing custom shift notes field.

Parameters:
  • field_id – the ID of the field to edit

Status Codes:
Reqjson:

a (partial) ShiftNotesField object

Returns:

the modified ShiftNotesField object

DELETE /api/shiftNotes/fields/(int: field_id)

Delete an existing custom shift notes field.

Parameters:
  • field_id – the ID of the field to delete

Status Codes:
GET /api/shiftNotes/fields/(int: field_id)/values

Get entered values of a custom shift notes field.

Query Parameters:
  • machine_id (int) – get only values from the specified machine ID

  • limit (int) – maximum number of values to return

  • offset (int) – skip this many most recent values

Returns:

a list of ShiftNotesValue objects sorted by shift date (not submission date) with the newest first