Data Content#
- class emhub.data.content.DataContent#
This class acts as an intermediary between the DataManager and the Flask application.
Here information is retrieved from the DataManager (dealing with stored data structure) and prepare the “content” for required views.
- booking_active_today(b)#
Return True if booking is active today.
- booking_from_entry(entry, scopes)#
Create a booking instance from an existing entry of type ‘microscope_access’
- booking_to_event(booking, **kwargs)#
Return a dict that can be used as calendar Event object.
- get_booking_in_range(kwargs, asJson=True, filter=None, bookingFunc=None)#
Return the list of bookings in the given time range.
It will also attach PI information to each booking. This function is used from report functions. If ‘start’ and ‘end’ keys are not in kwargs, the current year quarter will be used for the range.
- Parameters:
kwargs (dict) – dict from where to read ‘start’ and ‘end’
asJson (bool) – if True return json entries for each booking
filter –
- function to filter bookings. If None, the non-slot bookings
with non-zero cost resource will be used.
- bookingFunc: if asJson is True, function used to convert
booking into a jsonDict. If it is none, booking_to_event is used.
- get_period(kwargs)#
Helper function to update period in kwargs if not present.
- get_pi_user(kwargs)#
Helper function to get pi user.
- load_form_content(form, data)#
Forms can define several ‘content’ to be loaded when rendering the form and its components.
- set_form_values(form, values)#
Load values to form parameters based on the ids.