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, is_home_office: bool = 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) (default
None
) - is_home_office (bool) – Flag weather the user works from home (default
None
)
Returns: The created presence
Return type:
-
delete
(pres_id: int)¶ Deletes a presence.
Parameters: pres_id (int) – Id of the presence Returns: Empty response on success Return type: moco_wrapper.util.response.EmptyResponse
-
static
endpoints
() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]¶ Returns all endpoints associated with the model
Returns: List of Endpoint objects Return type: moco_wrapper.util.endpoint.Endpoint
-
get
(pres_id: int)¶ Retrieve a single presence.
Parameters: pres_id (int) – Id of the presence Returns: Single presence object Return type: moco_wrapper.util.response.ObjectResponse
-
getlist
(from_date: datetime.date = None, to_date: datetime.date = None, user_id: int = None, is_home_office: bool = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)¶ Retrieve all user presences.
Parameters: - from_date (datetime.date, str) – Start date (default
None
) - to_date (datetime.date, str) – End date (default
None
) - user_id (int) – Id of the user (default
None
) - is_home_office (bool) – Flag weather the users works from home (default
None
) - sort_by (str) – Field to sort results by (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default
1
)
Returns: List of presence objects
Return type: Note
from_date
andto_date
must be provided together.- from_date (datetime.date, str) – Start date (default
-
touch
(is_home_office: bool = None)¶ 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.
Parameters: is_home_office (bool) – Flag weather the user works from home (default None
)Returns: The created presence Return type: :class:`moco_wrapper.util.response.ObjectResponse
-
update
(pres_id: int, pres_date: datetime.date = None, from_time: str = None, to_time: str = None, is_home_office: bool = None)¶ Update a presence.
Parameters: - pres_id (int) – Id of the presence
- pres_date (datetime.date, str) – Date of the presence (default
None
) - from_time (str) – Starting time of the presence (format HH:MM) (default
None
) - to_time (str) – End time of the presence (format HH:MM) (default
None
) - is_home_office (bool) – Flag weather the user works from home (default
None
)
Returns: The updated presence
Return type:
-