def get_shared_task_details(task): shared = [] for user in task.shared_with.all(): shared.append(get_user_details(user)) log_obj = get_log_object(task) log = 'None' if log_obj == None else log_obj.log return { "owner": get_user_details(task.user), \ "shared_with": shared, "log": log }
def get_group_details(group, query_set, visited = []): members = [] if group == None: for i in query_set: if i.email not in visited: members.append(get_user_details(i)) return {"name": "Others", "color": "#F2F2F2", \ "members": members} return {"name": group.name, "color": group.color, \ "members": [get_user_details(i) for i in query_set]}
def get_task_tree_details(user, task, indent, visited_list, folder, \ main_list=[]): ''' Takes input an user object and a task object, and returns a dictionary of all the details for the task AND all of it's subtasks having the same status. This dictionary can then be appended to the JSON object. User object is needed to get the datetime in string format based on his preferences ''' start_date = get_datetime_str(user, task.start_date) due_date = get_datetime_str(user, task.due_date) closed_date = get_datetime_str(user, task.closed_date) last_modified_date = get_datetime_str(user, task.last_modified_date) shared = [get_user_details(i) for i in task.shared_with.all()] owner = '' if folder == -1: subtasks_list = task.subtasks.all() elif folder == YOUR_SHARED: subtasks_list = task.subtasks.annotate(num = Count('shared_with')) subtasks_list = subtasks_list.filter(num__gt = 0) print >>sys.stderr, "subtasks found = " + str(subtasks_list) owner = '' elif folder == THEY_SHARED: q = list(set(task.subtasks.all()).intersection(user.shared_set.all())) subtasks_list = q shared = [] owner = get_user_details(task.user) else: subtasks_list = task.subtasks.filter(status = task.status) details = {"id": task.id, "name": task.name, \ "description": task.description, \ "start_date": start_date, "due_date": due_date, \ "closed_date": closed_date, \ "last_modified_date": last_modified_date, \ "status": task.status, "tags": get_tags_by_task(task), \ "subtasks": get_task_tree(user, subtasks_list, \ indent+1, visited_list, folder, \ main_list = main_list), \ "shared_with": shared, "owner": owner, \ "indent": indent} return details