equal
deleted
inserted
replaced
14 ## do not create su user thro syncdb |
14 ## do not create su user thro syncdb |
15 |
15 |
16 def browse_tasks(request): |
16 def browse_tasks(request): |
17 """ display all the tasks """ |
17 """ display all the tasks """ |
18 |
18 |
19 user = get_user(request.user) |
19 user = get_user(request.user) if request.user.is_authenticated() else request.user |
20 task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse() |
20 task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse() |
21 |
21 |
22 context = {'user':user, |
22 context = {'user':user, |
23 'task_list':task_list, |
23 'task_list':task_list, |
24 } |
24 } |
28 """ check if user is the mentor and also if the task status is UP. |
28 """ check if user is the mentor and also if the task status is UP. |
29 """ |
29 """ |
30 |
30 |
31 task_url = "/task/view/tid=%s"%tid |
31 task_url = "/task/view/tid=%s"%tid |
32 |
32 |
33 user = get_user(request.user) |
33 user = get_user(request.user) if request.user.is_authenticated() else request.user |
34 task = getTask(tid) |
34 task = getTask(tid) |
35 |
35 |
36 is_guest = True if not user.is_authenticated() else False |
36 is_guest = True if not user.is_authenticated() else False |
37 is_mentor = True if user in task.mentors.all() else False |
37 is_mentor = True if user in task.mentors.all() else False |
38 |
38 |
56 check for authentication and add a comment if it is a post request. |
56 check for authentication and add a comment if it is a post request. |
57 """ |
57 """ |
58 |
58 |
59 task_url = "/task/view/tid=%s"%tid |
59 task_url = "/task/view/tid=%s"%tid |
60 |
60 |
61 user = get_user(request.user) |
61 user = get_user(request.user) if request.user.is_authenticated() else request.user |
62 task = getTask(tid) |
62 task = getTask(tid) |
63 |
63 |
64 if task.status == "DL": |
64 if task.status == "DL": |
65 return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks') |
65 return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks') |
66 comments = task.comment_set.filter(is_deleted=False) |
66 comments = task.comment_set.filter(is_deleted=False) |
108 def create_task(request): |
108 def create_task(request): |
109 """ check for rights and create a task if applicable. |
109 """ check for rights and create a task if applicable. |
110 if user cannot create a task, redirect to homepage. |
110 if user cannot create a task, redirect to homepage. |
111 """ |
111 """ |
112 |
112 |
113 user = get_user(request.user) |
113 user = get_user(request.user) if request.user.is_authenticated() else request.user |
114 is_guest = True if not user.is_authenticated() else False |
114 is_guest = True if not user.is_authenticated() else False |
115 |
115 |
116 if not is_guest: |
116 if not is_guest: |
117 user_profile = user.get_profile() |
117 user_profile = user.get_profile() |
118 can_create_task = False if user_profile.rights == "CT" else True |
118 can_create_task = False if user_profile.rights == "CT" else True |
150 """ check if the current user has the rights to edit the task and add him. |
150 """ check if the current user has the rights to edit the task and add him. |
151 if user is not authenticated, redirect him to concerned page. """ |
151 if user is not authenticated, redirect him to concerned page. """ |
152 |
152 |
153 task_url = "/task/view/tid=%s"%tid |
153 task_url = "/task/view/tid=%s"%tid |
154 |
154 |
155 user = get_user(request.user) |
155 user = get_user(request.user) if request.user.is_authenticated() else request.user |
156 task = getTask(tid) |
156 task = getTask(tid) |
157 errors = [] |
157 errors = [] |
158 |
158 |
159 is_guest = True if not user.is_authenticated() else False |
159 is_guest = True if not user.is_authenticated() else False |
160 |
160 |
190 """ first display tasks which can be subtasks for the task and do the rest. |
190 """ first display tasks which can be subtasks for the task and do the rest. |
191 """ |
191 """ |
192 |
192 |
193 task_url = "/task/view/tid=%s"%tid |
193 task_url = "/task/view/tid=%s"%tid |
194 |
194 |
195 user = get_user(request.user) |
195 user = get_user(request.user) if request.user.is_authenticated() else request.user |
196 task = getTask(tid) |
196 task = getTask(tid) |
197 |
197 |
198 deps, subs = task.deps, task.subs |
198 deps, subs = task.deps, task.subs |
199 is_plain = False if deps or subs else True |
199 is_plain = False if deps or subs else True |
200 |
200 |
250 """ display a list of tasks and remove the selectes ones. |
250 """ display a list of tasks and remove the selectes ones. |
251 """ |
251 """ |
252 |
252 |
253 task_url = "/task/view/tid=%s"%tid |
253 task_url = "/task/view/tid=%s"%tid |
254 |
254 |
255 user = get_user(request.user) |
255 user = get_user(request.user) if request.user.is_authenticated() else request.user |
256 task = getTask(tid) |
256 task = getTask(tid) |
257 |
257 |
258 is_guest = True if not user.is_authenticated() else False |
258 is_guest = True if not user.is_authenticated() else False |
259 if (not is_guest) and user in task.mentors.all(): |
259 if (not is_guest) and user in task.mentors.all(): |
260 |
260 |
293 task_url = "/task/view/tid=%s"%tid |
293 task_url = "/task/view/tid=%s"%tid |
294 claim_url = "/task/claim/tid=%s"%tid |
294 claim_url = "/task/claim/tid=%s"%tid |
295 |
295 |
296 errors = [] |
296 errors = [] |
297 |
297 |
298 user = get_user(request.user) |
298 user = get_user(request.user) if request.user.is_authenticated() else request.user |
299 task = getTask(tid) |
299 task = getTask(tid) |
300 claims = Claim.objects.filter(task=task) |
300 claims = Claim.objects.filter(task=task) |
301 |
301 |
302 mentors = task.mentors.all() |
302 mentors = task.mentors.all() |
303 claimed_users = task.claimed_users.all() |
303 claimed_users = task.claimed_users.all() |
337 """ show a list of working users and ask for a message/reason for removing user. |
337 """ show a list of working users and ask for a message/reason for removing user. |
338 """ |
338 """ |
339 |
339 |
340 task_url = "/task/view/tid=%s"%tid |
340 task_url = "/task/view/tid=%s"%tid |
341 |
341 |
342 user = get_user(request.user) |
342 user = get_user(request.user) if request.user.is_authenticated() else request.user |
343 task = getTask(tid) |
343 task = getTask(tid) |
344 |
344 |
345 is_guest = True if not user.is_authenticated() else False |
345 is_guest = True if not user.is_authenticated() else False |
346 is_mentor = True if user in task.mentors.all() else False |
346 is_mentor = True if user in task.mentors.all() else False |
347 |
347 |
382 generate list of claimed users by passing it as an argument to a function. |
382 generate list of claimed users by passing it as an argument to a function. |
383 """ |
383 """ |
384 |
384 |
385 task_url = "/task/view/tid=%s"%tid |
385 task_url = "/task/view/tid=%s"%tid |
386 |
386 |
387 user = get_user(request.user) |
387 user = get_user(request.user) if request.user.is_authenticated() else request.user |
388 task = getTask(tid) |
388 task = getTask(tid) |
389 |
389 |
390 is_guest = True if not user.is_authenticated() else False |
390 is_guest = True if not user.is_authenticated() else False |
391 is_mentor = True if user in task.mentors.all() else False |
391 is_mentor = True if user in task.mentors.all() else False |
392 |
392 |
421 Then put up a form for mentor to assign credits accordingly. |
421 Then put up a form for mentor to assign credits accordingly. |
422 """ |
422 """ |
423 |
423 |
424 task_url = "/task/view/tid=%s"%tid |
424 task_url = "/task/view/tid=%s"%tid |
425 |
425 |
426 user = get_user(request.user) |
426 user = get_user(request.user) if request.user.is_authenticated() else request.user |
427 task = getTask(tid) |
427 task = getTask(tid) |
428 |
428 |
429 is_guest = True if not user.is_authenticated() else False |
429 is_guest = True if not user.is_authenticated() else False |
430 is_mentor = True if (not is_guest) and user in task.mentors.all() else False |
430 is_mentor = True if (not is_guest) and user in task.mentors.all() else False |
431 |
431 |
470 """ see what are the attributes that can be edited depending on the current status |
470 """ see what are the attributes that can be edited depending on the current status |
471 and then give the user fields accordingly. |
471 and then give the user fields accordingly. |
472 """ |
472 """ |
473 |
473 |
474 task = Task.objects.get(id=tid) |
474 task = Task.objects.get(id=tid) |
|
475 user = get_user(request.user) if request.user.is_authenticated() else request.user |
|
476 |
475 |
477 |
476 def complete_task(request, tid): |
478 def complete_task(request, tid): |
477 |
479 |
478 """ call the event called complete task. |
480 """ call the event called complete task. |
479 and also pass it the current user to know who marked it as complete. |
481 and also pass it the current user to know who marked it as complete. |
480 """ |
482 """ |
481 |
483 |
482 task_url = "/task/view/tid=%s"%tid |
484 task_url = "/task/view/tid=%s"%tid |
483 |
485 |
484 user = get_user(request.user) |
486 user = get_user(request.user) if request.user.is_authenticated() else request.user |
485 task = getTask(tid) |
487 task = getTask(tid) |
486 |
488 |
487 is_guest = True if not user.is_authenticated() else False |
489 is_guest = True if not user.is_authenticated() else False |
488 is_mentor = True if user in task.mentors.all() else False |
490 is_mentor = True if user in task.mentors.all() else False |
489 |
491 |
520 call the event close task if everything is fine. |
522 call the event close task if everything is fine. |
521 """ |
523 """ |
522 |
524 |
523 task_url = "/task/view/tid=%s"%tid |
525 task_url = "/task/view/tid=%s"%tid |
524 |
526 |
525 user = get_user(request.user) |
527 user = get_user(request.user) if request.user.is_authenticated() else request.user |
526 task = getTask(tid) |
528 task = getTask(tid) |
527 |
529 |
528 is_guest = True if not user.is_authenticated() else False |
530 is_guest = True if not user.is_authenticated() else False |
529 is_mentor = True if user in task.mentors.all() else False |
531 is_mentor = True if user in task.mentors.all() else False |
530 |
532 |