def _create_cycle_task(task_group_task, cycle, cycle_task_group, current_user, base_date=None): """Create a cycle task along with relations to other objects""" # TaskGroupTasks for one_time workflows don't save relative start/end # month/day. They only saves start and end dates. # TaskGroupTasks for all other workflow frequencies save the relative # start/end days. if not base_date: base_date = date.today() description = models.CycleTaskGroupObjectTask.default_description if \ task_group_task.object_approval else task_group_task.description date_range = cycle.calculator.task_date_range( task_group_task, base_date=base_date) start_date, end_date = date_range cycle_task_group_object_task = models.CycleTaskGroupObjectTask( context=cycle.context, cycle=cycle, cycle_task_group=cycle_task_group, task_group_task=task_group_task, title=task_group_task.title, description=description, sort_index=task_group_task.sort_index, start_date=start_date, end_date=end_date, contact=task_group_task.contact, status="Assigned", modified_by=current_user, task_type=task_group_task.task_type, response_options=task_group_task.response_options, ) return cycle_task_group_object_task
def _create_cycle_task(task_group_task, cycle, cycle_task_group, current_user): """Create a cycle task along with relations to other objects""" description = models.CycleTaskGroupObjectTask.default_description if \ task_group_task.object_approval else task_group_task.description workflow = cycle.workflow start_date = workflow.calc_next_adjusted_date(task_group_task.start_date) end_date = workflow.calc_next_adjusted_date(task_group_task.end_date) access_control_list = [] for role_id, role_name in role.get_custom_roles_for( models.CycleTaskGroupObjectTask.__name__).iteritems(): for person_id in task_group_task.get_person_ids_for_rolename(role_name): access_control_list.append( {"ac_role_id": role_id, "person": {"id": person_id}} ) cycle_task_group_object_task = models.CycleTaskGroupObjectTask( context=cycle.context, cycle=cycle, cycle_task_group=cycle_task_group, task_group_task=task_group_task, title=task_group_task.title, description=description, sort_index=task_group_task.sort_index, start_date=start_date, end_date=end_date, access_control_list=access_control_list, status=models.CycleTaskGroupObjectTask.ASSIGNED, modified_by=current_user, task_type=task_group_task.task_type, response_options=task_group_task.response_options, ) return cycle_task_group_object_task
def _create_cycle_task(task_group_task, cycle, cycle_task_group, current_user): """Create a cycle task along with relations to other objects""" description = models.CycleTaskGroupObjectTask.default_description if \ task_group_task.object_approval else task_group_task.description workflow = cycle.workflow start_date = workflow.calc_next_adjusted_date(task_group_task.start_date) end_date = workflow.calc_next_adjusted_date(task_group_task.end_date) cycle_task_group_object_task = models.CycleTaskGroupObjectTask( context=cycle.context, cycle=cycle, cycle_task_group=cycle_task_group, task_group_task=task_group_task, title=task_group_task.title, description=description, sort_index=task_group_task.sort_index, start_date=start_date, end_date=end_date, contact=task_group_task.contact, status=models.CycleTaskGroupObjectTask.ASSIGNED, modified_by=current_user, task_type=task_group_task.task_type, response_options=task_group_task.response_options, ) return cycle_task_group_object_task