kepler.scripts.db_util module¶
The module contains utility functionality for inserting the initial and test data into the database.
- 
kepler.scripts.db_util.add_reservation(time_slot, unit, unit_group, user_group, creator)¶ The function adds a new reservation to the database. No checks for the validity of the reservation are made.
Parameters: - time_slot – The 
TimeSloton which the reservation will be added. - unit – The 
Unitfor which the reservation is made. - unit_group – The 
UnitGroupfor which the reservation is made. - user_group – The 
UserGroupfor which the reservation is made. - creator – The user who is set as the creator of the reservation.
 
- time_slot – The 
 
- 
kepler.scripts.db_util.add_role(role_name_tr, unit_type=None)¶ The function adds a new role to the database.
Parameters: - role_name_tr – The name translation ID token used to determine the translation ID of the name of the role.
 - unit_type – Optional unit_type of the new role.
 
Returns: The new role.
- 
kepler.scripts.db_util.add_roles_to_user(user, roles)¶ The function adds roles for the specified user.
Parameters: - user – The user for whom the roles will be added.
 - roles – List of roles that the user will have.
 
- 
kepler.scripts.db_util.add_time_slot(start, end, max_reservations, creator, unit_type, supervisor)¶ The function adds a new time slot to the database.
Parameters: - start – The start time of the time slot.
 - end – The end time of the time slot.
 - max_reservations – The limit of reservations that can be made to the time slot.
 - creator – The user who will be set as the creator of the time slot.
 - supervisor – The user that will be added as a supervisor on the time slot.
 
- 
kepler.scripts.db_util.add_user(user, user_info_list=None)¶ The function adds a new user to the database.
Parameters: - user – The user to be added to the database.
 - user_info_list – Optional list of user infos for the user.
 
- 
kepler.scripts.db_util.add_user_group(name, group_type_id, users)¶ The function adds a new user group to the database.
Parameters: - name – The name of the user group.
 - group_type_id – The ID of the user group type.
 - users – List of user that are added as the members to the user group.
 
Returns: The new user group.
- 
kepler.scripts.db_util.add_user_info(user, info_type_id, value)¶ The function adds user info for the specified user to database.
Parameters: - user – The user for whom the info is to be added.
 - info_type_id – The ID of the user info type of the info added.
 - value – The value of the user info.
 
- 
kepler.scripts.db_util.safe_add(session, x)¶ The function adds an item to the database.
Parameters: - session – The database session.
 - x – The item added to the database.