10.6.15. Class cerebro.events.BeforeEventChangingOfTasksAllocated

class cerebro.events.BeforeEventChangingOfTasksAllocated(event_type, event_id)[source]

Bases: cerebro.events.BeforeEventChangingOfTasks

The class for the allocating/dismissing users/resources to/from a single or multiple task(s). It grants access to the data of the modified tasks before writing it into the database.


The class object is input into the functions before_event and error_event (in case of error) of the module event.

def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_TASKS_ALLOCATED:
Returns:True, if users/resources are being allocated to task(s). False, is being dismissed.
Return type:bool

In case of allocating users/resources the method new_value() returns a list of users/resources being allocated. Otherwise, it returns a list of users being dismissed.

In order to change the list of users being allocated/dismissed use the method set_new_value(). The input argument for this method - list(user_id,), the list of user/resource IDs

def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_TASKS_ALLOCATED: # the tasks allocated is being changed
                if event.is_added() == False: # the users are being dismissed                                   
                        # asking the user if he/she is sure to do it
                        q = 'Are you sure you want to dismiss the users from the task?'
                        if cerebro.gui.question_box('User list change',  q) == False: # if the user is not sure
                                raise Exception('') 
                        # The users will remain allocated to the task