14 |
14 |
15 def browse_tasks(request): |
15 def browse_tasks(request): |
16 """ display all the tasks """ |
16 """ display all the tasks """ |
17 |
17 |
18 user = request.user |
18 user = request.user |
19 task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('creation_datetime').reverse() |
19 task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse() |
20 |
20 |
21 context = {'user':user, |
21 context = {'user':user, |
22 'task_list':task_list, |
22 'task_list':task_list, |
23 } |
23 } |
24 return render_to_response('task/browse.html', context) |
24 return render_to_response('task/browse.html', context) |
33 task = getTask(tid) |
33 task = getTask(tid) |
34 |
34 |
35 is_guest = True if not user.is_authenticated() else False |
35 is_guest = True if not user.is_authenticated() else False |
36 is_mentor = True if user in task.mentors.all() else False |
36 is_mentor = True if user in task.mentors.all() else False |
37 |
37 |
38 if user==task.created_by: |
38 if user == task.created_by: |
39 context = { |
39 context = { |
40 'user':user, |
40 'user':user, |
41 } |
41 } |
42 |
42 if task.status == "UP": |
43 if request.method == "POST": |
43 if request.method == "POST": |
44 publishTask(task) |
44 publishTask(task) |
45 return show_msg(user, "The task has been published", task_url, "view the task") |
45 return show_msg(user, "The task has been published", task_url, "view the task") |
46 else: |
46 else: |
47 return render_to_response('task/publish.html', context) |
47 return render_to_response('task/publish.html', context) |
|
48 else: |
|
49 return show_msg(user, "The task is already published", task_url, "view the task") |
48 else: |
50 else: |
49 return show_msg(user, "You are not authorised to do this", '/task/browse/', "browse tasks") |
51 return show_msg(user, "You are not authorised to do this", '/task/browse/', "browse tasks") |
50 |
|
51 |
|
52 |
52 |
53 def view_task(request, tid): |
53 def view_task(request, tid): |
54 """ get the task depending on its tid and display accordingly if it is a get. |
54 """ get the task depending on its tid and display accordingly if it is a get. |
55 check for authentication and add a comment if it is a post request. |
55 check for authentication and add a comment if it is a post request. |
56 """ |
56 """ |
281 else: |
281 else: |
282 return show_msg(user, "The task has no subtasks/dependencies to be removed", task_url, "view the task") |
282 return show_msg(user, "The task has no subtasks/dependencies to be removed", task_url, "view the task") |
283 else: |
283 else: |
284 return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
284 return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
285 |
285 |
286 |
|
287 def claim_task(request, tid): |
286 def claim_task(request, tid): |
288 """ display a list of claims for get and display submit only if claimable """ |
287 """ display a list of claims for get and display submit only if claimable """ |
289 |
288 |
290 ## create claims model and create a new database with required tables for it |
289 ## create claims model and create a new database with required tables for it |
291 ## see if that "one to n" or "n to one" relationship has a special field |
290 ## see if that "one to n" or "n to one" relationship has a special field |