Data Models#

class emhub.data.models.Resource(**kwargs)#

Representation of different type of Resources. (e.g Microscopes, other instruments or services.

property daily_cost#

Cost of one day session using this resource.

property is_active#

Return True if this instrument is “active”. If not “active” bookings can not be made for this instrument.

property max_booking#

Maximum amount of hours that can be used in a booking for booking this resource.

property min_booking#

Minimum amount of hours that should be used for booking this resource.

property requires_application#

True if the user must be in an Application to book this resource.

property requires_slot#

If True, users will need to have access to an slot or have some exceptions via the Application.

class emhub.data.models.User(**kwargs)#

Model for user accounts.

can_book_resource(resource)#

Return True if the user can book a given resource without an explicit SLOT for it.

can_book_slot(booking_slot)#

Return True if the user can book in the given SLOT.

can_delete_project(p)#

Return True if this user can delete a project.

can_edit_project(p)#

Return True if this user can edit a project.

check_password(password)#

Check hashed password.

get_applications(status='active')#

Return the applications of this user.

get_lab_members(onlyActive=True)#

Return lab members, filtering or not by active status.

get_pi()#

Return the PI of this user. PI are consider PI of themselves.

has_any_role(roles)#

Return True if the user has any role from the roles list or if it is empty. (this method will be used for permissions)

has_application(applicationCode)#

Return True if the user has the given application.

same_pi(other)#

Return if the same pi.

set_password(password)#

Create hashed password.

class emhub.data.models.Template(**kwargs)#

Classes used as template to create Applications. Template instances that are ‘active’ will allow to create new applications from it. Otherwise, templates can be closed and will not be visible when creating a new application.

property code_prefix#

Prefix for numbering Application Codes (e.g CEM, EXT, etc)

property codes#

Prefix for numbering Application Codes (e.g CEM, EXT, etc)

class emhub.data.models.Application(**kwargs)#

Application that applies for access to the facility. Usually many principal investigators are associated to a project.

property access_list#

Return a list of IDs with managers that can access this application.

allows_access(user)#

Return True if this user has access to the application.

property confidential#

Return extra costs associated with this Booking

property costs#

Return extra costs associated with this Booking

get_quota(key)#

Return the quota (in days) for this application. :param key: the key representing either a resource id or a tag (e.g 1 or ‘krios’)

Returns:

the number of days that this application can use a resource or a groups resources with the same tag. It will return None if there is no quota for such resource.

no_slot(resourceKey)#

Return True if this application is not forced to create bookings within a given slot for certain resource.

For example, some applications might be required to book Krios1 only on specific slots, while others will be able to book in free days.

property pi_list#

Return the list of PI.

property representative_id#

Return extra costs associated with this Booking

class emhub.data.models.Booking(**kwargs)#

Data Model for bookings in the system, mapped to table bookings.

id#

Unique identifier.

Type:

int

title#

Title of the booking.

Type:

str

description#

Description of the booking (Optional).

Type:

str

start#

Starting date/time of the booking.

Type:

datetime

end#

Ending date/time of the booking.

Type:

datetime

type#

Type of the booking. Possible values: booking, slot, downtime, maintenance or special

Type:

str

slot_auth#

JSON field storing slot authorization. This field only make sense when booking type is slot. The dict has the two keys and a list of authorizations:

{'applications': [], 'users': []}
Type:

dict

repeat_id#

Unique id representing a group of ‘repeating’ events. This id is used for modifying all events in the group.

Type:

str

resource_id#

Id of the Resource of this booking.

Type:

int

allows_user_in_slot(user)#

Return True if a given user is allowed to book in this Slot.

application_in_slot(application)#

Return True if this booking is slot and the application is within the authorized applications.

Parameters:

applicationApplication to check if it is in this slot

property costs#

Extra costs associated with this Booking.

property days#

Count how many days these bookings spans. (It is not strictly necessary the total amount of time in in units of 24h.

property duration#

Duration of this booking.

Returns:

end - start

Return type:

timedelta

property is_booking#

Returns True if type=='booking'.

property is_slot#

Returns True if type=='slot'.

property total_cost#

All costs associated with this Booking.

property total_size#

Compute all the data size of sessions related to this booking.

class emhub.data.models.Session(**kwargs)#

Model for sessions.

property actions#

True if the user of the project can edit it (add/modify/delete notes)

property project#

Get the project based on project_id or the booking’s project.

property project_id#

Get the project based on project_id or the booking’s project.

class emhub.data.models.Form(**kwargs)#

Class to store Forms definitions.

class emhub.data.models.InvoicePeriod(**kwargs)#

Period for which invoices will be generated.

class emhub.data.models.Transaction(**kwargs)#

Financial transactions.

class emhub.data.models.Project(**kwargs)#

Project entity to group shipments, grids preparation, data collections and data processing.

property collaborators_ids#

True if the user of the project can edit it (add/modify/delete notes)

property is_confidential#

True if this project is confidential and its information sensitive. Some of the project info will not be available to all users.

property user_can_edit#

True if the user of the project can edit it (add/modify/delete notes)

class emhub.data.models.Entry(**kwargs)#

Entry related to a given project.

class emhub.data.models.Puck(**kwargs)#

Puck entity for Grids Storage table.

class emhub.data.models.PuckStorage(pucks)#

Simple class to organize pucks access.

get_puck(id_or_loc)#

Retrieve puck by id or by location.