User Presence

class moco_wrapper.models.UserPresence(moco)

Class for handling presences.

With this model you can log the times your user start and finish the workday. For example if the users punch in to indicate they have arrived and punch out to leave, you can log the times with this model.

Also this can be used to log when you users are at work.

create(pres_date: str, from_time: str, to_time: str = None)

Create a presence.

Parameters:
  • pres_date (datetime.date, str) – Date of the presence
  • from_time (str) – Starting time of the presence (format HH:MM)
  • to_time (str) – End time of the presence (format HH:MM)
Returns:

The created presence

delete(pres_id: int)

Deletes a presence.

Parameters:pres_id (int) – Id of the presence
Returns:Empty response on success
get(pres_id: int)

Retrieve a single presence.

Parameters:pres_id (int) – Id of the presence
Returns:Single presence object
getlist(from_date: datetime.date = None, to_date: datetime.date = None, user_id: int = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Retrieve all user presences.

Parameters:
  • from_date (datetime.date, str) – Start date
  • to_date (datetime.date, str) – End date
  • user_id (int) – Id of the user
  • sort_by (str) – Field to sort results by
  • sort_order (str) – asc or desc (default asc)
  • page (int) – Page number (default 1)
Returns:

List of presence objets

Note

from_date and to_date must be provided together.

touch()

Creates a new presence for the user with the corresponding api key starting from the current time. Or it terminates an existing open presence at the current time. Can be used to implement a clock system (RFID).

If a presence is started and stopped within the same minute, it will be discarded.

update(pres_id: int, pres_date: datetime.date = None, from_time: str = None, to_time: str = None)

Update a presence.

Parameters:
  • pres_id (int) – Id of the presence
  • pres_date (datetime.date, str) – Date of the presence
  • from_time (str) – Starting time of the presence (format HH:MM)
  • to_time (str) – End time of the presence (format HH:MM)
Returns:

The created presence