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 discussion_add_task(discussion, responsible, goal_description, target_date, max_inactivity_seconds=MAX_INACTIVITY_SECONDS): if not discussion.can_user_access_discussion(responsible): return None, "user cannot access discussion" if target_date <= timezone.now(): return None, "target date should be in the future" tasks_list = Task.objects.all().filter(responsible=responsible, goal_description= goal_description, parent=discussion) if tasks_list.count() != 0: return None, "task already exsist" task = discussion.task_set.create(parent=discussion, responsible=responsible, goal_description=goal_description, target_date=target_date) task.full_clean() task.save() discussion.unlock(max_inactivity_seconds) discussion.save() #verify that the entire discussion is considered updated start_discussion_following( discussion, responsible) t = Template(""" {{task.responsible.get_full_name|default:task.responsible.username}} הבטיח/ה ש :\n "{{task.goal_description}} "\n עד {{task.target_date | date:"d/n/Y H:i"}} """) success, error_string = start_discussion_following( discussion, responsible) if success == False: return None, error_string trunkated_subject_and_detailes = t.render(Context({"task": task})) discussion_task_email_updates(task, trunkated_subject_and_detailes, responsible, trunkated_subject_and_detailes) return task, None