def update_task_status_description( task , description, user, result_picture = None): if user is None: return None, 'no user provided' if description is None: return None, 'no description' if user != task.responsible: return None, 'only the responsible can update the description' poll_for_task_complition( task) if( task.final_state): return None, 'target date passed' task.status_description = description task.result_picture = result_picture task.save() task.parent.save()#verify that the entire disscusion is considered updated t = Template(""" {{task.responsible.get_full_name|default:task.responsible.username}} הודיע/ה ש :\n "{{task.get_status_description}} "\n """) trunkated_subject_and_detailes = t.render(Context({"task": task})) discussion_task_email_updates(task, trunkated_subject_and_detailes, user, trunkated_subject_and_detailes) return task, None
def update_task_state( task , new_state , user ): if new_state != Task.STARTED and new_state != Task.CLOSED and new_state != Task.ABORTED: return None, 'unknown task state ' + str(new_state) if not task.parent.can_user_access_discussion( user): return None, 'user cannot access discussion' if user == task.responsible: return None, 'responsible can not update task status' poll_for_task_complition( task) if task.final_state: return None, 'target date passed' if (task.status != new_state): task.status = new_state task.closed_at = timezone.now() task.closed_by = user task.save() task.parent.save() #verify that the entire discussion is considered updated success, error_string = start_discussion_following( task.parent, user) if success == False: return None, error_string if new_state == task.STARTED: task_state_change_update( task, u" עדיין לא השלים/ה את ") if new_state == task.ABORTED: task_state_change_update( task, u" ביטל/ה את ") if new_state == task.CLOSED: task_state_change_update( task, u" השלימ/ה את ") return task, None
def task_get_status( task): poll_for_task_complition( task) return task.status