author | Nishanth Amuluru <nishanth@fossee.in> |
Thu, 06 Jan 2011 12:08:36 +0530 | |
changeset 226 | b4a3ec34c061 |
parent 224 | c41e38f36299 |
permissions | -rw-r--r-- |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
1 |
from datetime import datetime |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
2 |
|
151
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
3 |
from django.http import HttpResponse, Http404 |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
4 |
from django.shortcuts import render_to_response, redirect |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
5 |
|
223
b592ed0b12b1
added a form in the template, for users to submit work
Nishanth Amuluru <nishanth@fossee.in>
parents:
222
diff
changeset
|
6 |
from pytask.taskapp.models import User, Task, Comment, Request, Notification, WorkReport |
120 | 7 |
from pytask.taskapp.utilities.task import getTask |
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
8 |
from pytask.taskapp.forms.task import TaskCreateForm, AddReviewerForm, AddTaskForm, ChoiceForm, AssignPyntForm, RemoveUserForm, EditTaskForm, ClaimTaskForm, WorkReportForm |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
9 |
from pytask.taskapp.events.task import createTask, reqReviewer, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignPynts, completeTask, closeTask, addReviewer, deleteTask |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
10 |
from pytask.taskapp.views.user import show_msg |
138
c452c699a8af
now all the pages show number of unread beside requests and notifications link in sidebar.
nishanth
parents:
136
diff
changeset
|
11 |
from pytask.taskapp.utilities.user import get_user |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
12 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
13 |
## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add reviewer and all |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
14 |
## do not create su user thro syncdb |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
15 |
|
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
16 |
def browse_tasks(request): |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
17 |
""" display all the tasks """ |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
18 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
19 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
124
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
20 |
task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse() |
217
307f699e6102
Now browse tasks page does not display textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
215
diff
changeset
|
21 |
|
307f699e6102
Now browse tasks page does not display textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
215
diff
changeset
|
22 |
task_list = task_list.exclude(tags_field__icontains="textbook") |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
23 |
|
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
24 |
context = {'user':user, |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
25 |
'task_list':task_list, |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
26 |
} |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
27 |
return render_to_response('task/browse.html', context) |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
28 |
|
215
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
29 |
def show_textbooks(request): |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
30 |
""" display all the tasks """ |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
31 |
|
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
32 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
33 |
task_list = Task.objects.exclude(status="UP").exclude(status="DL").order_by('published_datetime').reverse() |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
34 |
|
217
307f699e6102
Now browse tasks page does not display textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
215
diff
changeset
|
35 |
task_list = task_list.filter(tags_field__icontains="textbook") |
215
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
36 |
|
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
37 |
context = {'user':user, |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
38 |
'task_list':task_list, |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
39 |
} |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
40 |
return render_to_response('task/browse.html', context) |
84ec0ca5bc68
Added a page for displaying all the textbooks
Nishanth Amuluru <nishanth@fossee.in>
parents:
205
diff
changeset
|
41 |
|
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
42 |
def upload_work(request, tid): |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
43 |
""" Check if the work is in WR state and the user is in assigned_users. |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
44 |
""" |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
45 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
46 |
task_url = "/task/view/tid=%s"%tid |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
47 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
48 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
49 |
task = getTask(tid) |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
50 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
51 |
if not task.status == "WR": |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
52 |
return show_msg(user, "The task is not in a stage to upload content", task_url, "view the task") |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
53 |
|
221
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
54 |
can_upload = True if user in task.assigned_users.all() else False |
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
55 |
|
223
b592ed0b12b1
added a form in the template, for users to submit work
Nishanth Amuluru <nishanth@fossee.in>
parents:
222
diff
changeset
|
56 |
old_reports = task.workreport_report.all() |
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
57 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
58 |
context = { |
221
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
59 |
'user': user, |
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
60 |
'task': task, |
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
61 |
'old_reports': old_reports, |
223
b592ed0b12b1
added a form in the template, for users to submit work
Nishanth Amuluru <nishanth@fossee.in>
parents:
222
diff
changeset
|
62 |
'can_upload': can_upload, |
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
63 |
} |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
64 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
65 |
if request.method == "POST": |
221
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
66 |
if not can_upload: |
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
67 |
return show_msg(user, "You are not authorised to upload data to this task", task_url, "view the task") |
a3de0d3c60a3
created form and created basic template for work report
Nishanth Amuluru <nishanth@fossee.in>
parents:
220
diff
changeset
|
68 |
|
224
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
69 |
form = WorkReportForm(request.POST, request.FILES) |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
70 |
|
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
71 |
if form.is_valid(): |
226
b4a3ec34c061
the upload of attachments works correctly now
Nishanth Amuluru <nishanth@fossee.in>
parents:
224
diff
changeset
|
72 |
r = WorkReport(attachment = form.cleaned_data['attachment'], |
224
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
73 |
remarks = form.cleaned_data['remarks'], |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
74 |
revision = old_reports.count(), |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
75 |
task = task, |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
76 |
submitted_by = user, |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
77 |
created_at = datetime.now(), |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
78 |
) |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
79 |
|
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
80 |
r.save() |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
81 |
return redirect(task_url) |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
82 |
|
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
83 |
else: |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
84 |
context.update({"form":form}) |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
85 |
return render_to_response('task/report.html', context) |
c41e38f36299
added saving of attachments
Nishanth Amuluru <nishanth@fossee.in>
parents:
223
diff
changeset
|
86 |
|
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
87 |
else: |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
88 |
form = WorkReportForm() |
222 | 89 |
context.update({"form":form}) |
220
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
90 |
return render_to_response('task/report.html', context) |
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
91 |
|
807e4b701a20
added a submit_report link for each task
Nishanth Amuluru <nishanth@fossee.in>
parents:
219
diff
changeset
|
92 |
|
111 | 93 |
def publish_task(request, tid): |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
94 |
""" check if user is the reviewer and also if the task status is UP. |
111 | 95 |
""" |
96 |
||
97 |
task_url = "/task/view/tid=%s"%tid |
|
98 |
||
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
99 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
111 | 100 |
task = getTask(tid) |
101 |
||
102 |
is_guest = True if not user.is_authenticated() else False |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
103 |
is_reviewer = True if user in task.reviewers.all() else False |
111 | 104 |
|
124
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
105 |
if user == task.created_by: |
111 | 106 |
context = { |
107 |
'user':user, |
|
108 |
} |
|
124
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
109 |
if task.status == "UP": |
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
110 |
if request.method == "POST": |
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
111 |
publishTask(task) |
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
112 |
return show_msg(user, "The task has been published", task_url, "view the task") |
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
113 |
else: |
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
114 |
return render_to_response('task/publish.html', context) |
111 | 115 |
else: |
124
6d92b7cd2a37
taking care if publish task post request is made again. added published_date field to task.
nishanth
parents:
120
diff
changeset
|
116 |
return show_msg(user, "The task is already published", task_url, "view the task") |
111 | 117 |
else: |
118 |
return show_msg(user, "You are not authorised to do this", '/task/browse/', "browse tasks") |
|
119 |
||
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
120 |
def view_task(request, tid): |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
121 |
""" get the task depending on its tid and display accordingly if it is a get. |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
122 |
check for authentication and add a comment if it is a post request. |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
123 |
""" |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
124 |
|
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
125 |
task_url = "/task/view/tid=%s"%tid |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
126 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
127 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
36
diff
changeset
|
128 |
task = getTask(tid) |
110 | 129 |
|
130 |
if task.status == "DL": |
|
131 |
return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks') |
|
155
52958289d81f
now if a task has subs, it will remain locked forever.
nishanth
parents:
154
diff
changeset
|
132 |
comments = task.comment_set.filter(is_deleted=False).order_by('creation_datetime') |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
133 |
reviewers = task.reviewers.all() |
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
134 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
135 |
deps, subs = task.deps, task.subs |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
136 |
|
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
137 |
is_guest = True if not user.is_authenticated() else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
138 |
is_reviewer = True if user in task.reviewers.all() else False |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
139 |
context = {'user':user, |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
140 |
'task':task, |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
141 |
'comments':comments, |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
142 |
'reviewers':reviewers, |
66
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
143 |
'subs':subs, |
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
144 |
'deps':deps, |
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
145 |
'is_guest':is_guest, |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
146 |
'is_reviewer':is_reviewer, |
66
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
147 |
} |
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
148 |
|
160
05157d35d66f
imposed a constraint that edit_task url is not displayed if task is OP and has claimed_users.
nishanth
parents:
159
diff
changeset
|
149 |
claimed_users = task.claimed_users.all() |
05157d35d66f
imposed a constraint that edit_task url is not displayed if task is OP and has claimed_users.
nishanth
parents:
159
diff
changeset
|
150 |
|
192 | 151 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
152 |
is_requested_reviewer = True if user.is_authenticated() and user.request_sent_to.filter(is_valid=True,is_replied=False,role="MT",task=task) else False |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
153 |
task_viewable = True if ( task.status != "UP" ) or is_reviewer or is_requested_reviewer else False |
191
3bfe70742aa8
now requested mentors can see unpublished task but not comment on it.
nishanth
parents:
181
diff
changeset
|
154 |
if not task_viewable: |
3bfe70742aa8
now requested mentors can see unpublished task but not comment on it.
nishanth
parents:
181
diff
changeset
|
155 |
return show_msg(user, "You are not authorised to view this task", "/task/browse/", "browse the tasks") |
156 | 156 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
157 |
context['is_requested_reviewer'] = is_requested_reviewer |
192 | 158 |
|
111 | 159 |
context['can_publish'] = True if task.status == "UP" and user == task.created_by else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
160 |
context['can_edit'] = True if task.status == "UP" and is_reviewer else False |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
161 |
context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_reviewer else False |
167 | 162 |
context['can_delete'] = True if task.status == "UP" and user == task.created_by else False |
66
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
163 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
164 |
context['can_mod_reviewers'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_reviewer else False |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
165 |
context['can_mod_tasks'] = True if task.status in ["UP", "OP", "LO"] and is_reviewer else False |
156 | 166 |
|
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
167 |
context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False |
156 | 168 |
context['task_claimable'] = True if task.status in ["OP", "WR"] and not is_guest else False |
169 |
||
170 |
if task.status == "CD": |
|
171 |
context['closing_notification'] = Notification.objects.filter(task=task,role="CD")[0] |
|
172 |
elif task.status == "CM": |
|
173 |
context['completed_notification'] = Notifications.objects.filter(task=task,role="CM")[0] |
|
174 |
elif task.status == "WR": |
|
175 |
context['assigned_users'] = task.assigned_users.all() |
|
64
e743fe1f0f99
updated view task in views to suit the new design .
nishanth
parents:
55
diff
changeset
|
176 |
|
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
177 |
if request.method == 'POST': |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
178 |
if not is_guest: |
176 | 179 |
data = request.POST.get("data", "").strip() |
180 |
if not data: |
|
181 |
context['error_msg'] = "Enter some message to comment" |
|
182 |
return render_to_response('task/view.html', context) |
|
17
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
183 |
new_comment = Comment(task=task, data=data, created_by=user, creation_datetime=datetime.now()) |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
184 |
new_comment.save() |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
185 |
return redirect(task_url) |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
186 |
else: |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
187 |
errors.append("You must be logged in to post a comment") |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
188 |
return render_to_response('task/view.html', context) |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
189 |
else: |
aa45fec40e7e
renamed users.py to user.py and tasks to task in views folder and updated urls.py accordingly .
nishanth
parents:
diff
changeset
|
190 |
return render_to_response('task/view.html', context) |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
191 |
|
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
192 |
def create_task(request): |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
193 |
""" check for rights and create a task if applicable. |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
194 |
if user cannot create a task, redirect to homepage. |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
195 |
""" |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
196 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
197 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
198 |
is_guest = True if not user.is_authenticated() else False |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
199 |
|
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
200 |
if not is_guest: |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
201 |
user_profile = user.get_profile() |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
202 |
can_create_task = False if user_profile.rights == "CT" else True |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
203 |
if can_create_task: |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
204 |
if request.method == "POST": |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
205 |
form = TaskCreateForm(request.POST) |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
206 |
if form.is_valid(): |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
207 |
data = form.cleaned_data |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
208 |
title = data['title'] |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
209 |
desc = data['desc'] |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
210 |
pynts = data['pynts'] |
166 | 211 |
#publish = data['publish'] # just in case if we have to show the option |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
212 |
task = createTask(title,desc,user,pynts) |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
213 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
214 |
addReviewer(task, user) |
66
f670de53402b
modified view task template and view to suit new design.
nishanth
parents:
64
diff
changeset
|
215 |
updateTask(task,tags_field=data['tags_field']) |
165 | 216 |
# if publish: publishTask(task) |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
217 |
task_url = '/task/view/tid=%s'%task.id |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
218 |
return redirect(task_url) |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
219 |
else: |
165 | 220 |
return render_to_response('task/create.html',{'user':user, 'form':form}) |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
221 |
else: |
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
222 |
form = TaskCreateForm() |
177 | 223 |
return render_to_response('task/create.html',{'user':user, 'form':form}) |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
224 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
225 |
return show_msg(user, 'You are not authorised to create a task.') |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
226 |
else: |
180 | 227 |
return show_msg(user, 'You are not authorised to create a task.', "/", "home page") |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
228 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
229 |
def add_reviewer(request, tid): |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
230 |
""" check if the current user has the rights to edit the task and add him. |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
231 |
if user is not authenticated, redirect him to concerned page. """ |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
232 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
233 |
task_url = "/task/view/tid=%s"%tid |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
234 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
235 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
36
diff
changeset
|
236 |
task = getTask(tid) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
237 |
errors = [] |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
238 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
239 |
is_guest = True if not user.is_authenticated() else False |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
240 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
241 |
if (not is_guest) and user in task.reviewers.all(): |
149
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
242 |
|
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
243 |
pending_requests = Request.objects.filter(is_replied=False,is_valid=True,role="MT",task=task).order_by('creation_date').reverse() |
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
244 |
user_pending_requests = pending_requests.filter(sent_by=user) |
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
245 |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
246 |
## now iam going for a brute force method |
76 | 247 |
user_list = list(User.objects.filter(is_active=True)) |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
248 |
for reviewer in task.reviewers.all(): |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
249 |
user_list.remove(reviewer) |
34 | 250 |
|
251 |
for a_user in task.claimed_users.all(): |
|
252 |
user_list.remove(a_user) |
|
76 | 253 |
|
254 |
for a_user in task.assigned_users.all(): |
|
255 |
user_list.remove(a_user) |
|
149
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
256 |
|
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
257 |
for req in user_pending_requests: |
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
258 |
user_list.remove(req.sent_to.all()[0]) |
34 | 259 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
260 |
non_reviewers = ((_.id, _.username) for _ in user_list) |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
261 |
non_reviewer_ids = [ str(a_user.id) for a_user in user_list ] |
34 | 262 |
## code till must be made elegant and not brute force like above |
149
3395960549e8
now a user cannot make two requests to another user for mentoring a task.
nishanth
parents:
141
diff
changeset
|
263 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
264 |
form = AddReviewerForm(non_reviewers) |
151
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
265 |
|
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
266 |
context = { |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
267 |
'user':user, |
156 | 268 |
'task':task, |
151
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
269 |
'pending_requests':pending_requests, |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
270 |
'form':form, |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
271 |
} |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
272 |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
273 |
if request.method == "POST": |
151
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
274 |
data = request.POST |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
275 |
uid = data.get('reviewer', None) |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
276 |
if uid in non_reviewer_ids: |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
277 |
new_reviewer = User.objects.get(id=int(uid)) |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
278 |
reqReviewer(task, new_reviewer, user) |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
279 |
return redirect('/task/addreviewer/tid=%s'%task.id) |
151
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
280 |
else: |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
281 |
## bogus post request |
d0cb85ba462a
no bogus post request can be made now in addmentor page.
nishanth
parents:
149
diff
changeset
|
282 |
raise Http404 |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
283 |
else: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
284 |
return render_to_response('task/addreviewer.html', context) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
285 |
else: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
286 |
return show_msg(user, 'You are not authorised to add reviewers for this task', task_url, 'view the task') |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
287 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
288 |
def add_tasks(request, tid): |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
289 |
""" first display tasks which can be subtasks for the task and do the rest. |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
290 |
""" |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
291 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
292 |
task_url = "/task/view/tid=%s"%tid |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
293 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
294 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
36
diff
changeset
|
295 |
task = getTask(tid) |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
296 |
|
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
297 |
deps, subs = task.deps, task.subs |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
298 |
is_plain = False if deps or subs else True |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
299 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
300 |
## again a brute force method |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
301 |
valid_tasks = [] |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
302 |
for a_task in Task.objects.all(): |
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
89
diff
changeset
|
303 |
if not ( a_task in deps or a_task in subs or a_task.status=="CD" or a_task==task ): |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
304 |
valid_tasks.append(a_task) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
305 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
306 |
task_choices = [ (_.id,_.title) for _ in valid_tasks ] |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
307 |
errors = [] |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
308 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
309 |
is_guest = True if not user.is_authenticated() else False |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
310 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
311 |
if (not is_guest) and user in task.reviewers.all(): |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
312 |
if task.status in ["UP", "OP", "LO"]: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
313 |
form = AddTaskForm(task_choices, is_plain) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
314 |
if request.method == "POST": |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
315 |
## first decide if adding subs and deps can be in same page |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
316 |
## only exclude tasks with status deleted |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
317 |
data = request.POST |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
318 |
if is_plain and not data.get('type', None): errors.append('Please choose which type of task(s) do you want to add.') |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
319 |
if not data.get('task', None): errors.append('Please choose a one task') |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
320 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
321 |
if not errors: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
322 |
if is_plain: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
323 |
update_method = addDep if data['type'] == "D" else addSubTask |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
324 |
elif deps: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
325 |
update_method = addDep |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
326 |
elif subs: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
327 |
update_method = addSubTask |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
328 |
else: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
329 |
print "Screw you" |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
330 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
331 |
## we might iterate over a task list later on |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
332 |
task_id = data['task'] |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
333 |
sub_or_dep = getTask(task_id) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
334 |
update_method(task, sub_or_dep) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
335 |
|
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
336 |
return redirect(task_url) |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
337 |
else: |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
338 |
return render_to_response('task/addtask.html', {'user':user, 'form':form, 'errors':errors}) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
339 |
else: |
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
340 |
return render_to_response('task/addtask.html', {'user':user, 'form':form, 'errors':errors}) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
341 |
else: |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
342 |
errors = ["The task cannot be added subtasks or dependencies in this state"] |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
343 |
# return render_to_response('task/add.html', {'form':form, 'errors':errors}) |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
344 |
return show_msg(user, 'The task cannot be added subtasks or dependencies now', task_url, 'view the task') |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
345 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
346 |
return show_msg(user, 'You are not authorised to add subtasks or dependencies for this task', task_url, 'view the task') |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
347 |
|
89
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
348 |
def remove_task(request, tid): |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
349 |
""" display a list of tasks and remove the selectes ones. |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
350 |
""" |
1cc03941ed5d
added the capability of adding subtasks/dependencies .
nishanth
parents:
76
diff
changeset
|
351 |
|
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
352 |
task_url = "/task/view/tid=%s"%tid |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
353 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
354 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
355 |
task = getTask(tid) |
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
356 |
|
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
357 |
is_guest = True if not user.is_authenticated() else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
358 |
if (not is_guest) and user in task.reviewers.all(): |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
359 |
|
159 | 360 |
if task.status in ["UP", "LO", "OP"]: |
361 |
||
362 |
deps, subs = task.deps, task.subs |
|
363 |
task_list = deps if task.sub_type == "D" else subs |
|
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
364 |
|
159 | 365 |
if task_list: |
366 |
choices = [(_.id,_.title) for _ in task_list ] |
|
367 |
form = ChoiceForm(choices) |
|
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
368 |
|
159 | 369 |
errors = [] |
370 |
||
371 |
context = { |
|
372 |
'user':user, |
|
373 |
'task':task, |
|
374 |
'form':form, |
|
375 |
} |
|
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
376 |
|
159 | 377 |
if request.method == "POST": |
378 |
data = request.POST |
|
379 |
if not data.get('choice', None): |
|
380 |
errors.append("Please choose a task to remove.") |
|
381 |
context['errors'] = errors |
|
382 |
if not errors: |
|
383 |
tid = data['choice'] |
|
384 |
sub_task = getTask(tid) |
|
385 |
removeTask(task, sub_task) |
|
386 |
return redirect(task_url) |
|
387 |
else: |
|
388 |
return render_to_response('task/removetask.html', context) |
|
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
389 |
else: |
159 | 390 |
return render_to_response('task/removetask.html', context) |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
391 |
else: |
159 | 392 |
return show_msg(user, "The task has no subtasks/dependencies to be removed", task_url, "view the task") |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
393 |
else: |
159 | 394 |
return show_msg(user, "subtasks/dependencies cannot be removed at this stage", task_url, "view the task") |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
395 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
396 |
return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
92
c99f09bebe56
added the capability to remove subtasks/dependencies .
nishanth
parents:
91
diff
changeset
|
397 |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
398 |
def claim_task(request, tid): |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
399 |
""" display a list of claims for get and display submit only if claimable """ |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
400 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
401 |
## create claims model and create a new database with required tables for it |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
402 |
## see if that "one to n" or "n to one" relationship has a special field |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
403 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
404 |
task_url = "/task/view/tid=%s"%tid |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
405 |
claim_url = "/task/claim/tid=%s"%tid |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
406 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
407 |
errors = [] |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
408 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
409 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
36
diff
changeset
|
410 |
task = getTask(tid) |
205 | 411 |
|
204
fa1da06d25c9
now claims are read from notifications. we can ditchax claims model now.
nishanth
parents:
193
diff
changeset
|
412 |
#claims = task.notifications_task.filter(role="CL",sent_to=task.created_by) |
fa1da06d25c9
now claims are read from notifications. we can ditchax claims model now.
nishanth
parents:
193
diff
changeset
|
413 |
# this is what the next line should be when i re sync the db |
fa1da06d25c9
now claims are read from notifications. we can ditchax claims model now.
nishanth
parents:
193
diff
changeset
|
414 |
claims = Notification.objects.filter(task=task, sent_to=task.created_by, role="CL") |
72 | 415 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
416 |
reviewers = task.reviewers.all() |
72 | 417 |
claimed_users = task.claimed_users.all() |
76 | 418 |
assigned_users = task.assigned_users.all() |
22 | 419 |
|
420 |
is_guest = True if not user.is_authenticated() else False |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
421 |
is_reviewer = True if user in reviewers else False |
22 | 422 |
|
72 | 423 |
task_claimable = True if task.status in ["OP", "WR"] else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
424 |
user_can_claim = True if task_claimable and not ( is_guest or is_reviewer ) and ( user not in claimed_users ) and ( user not in assigned_users ) else False |
72 | 425 |
task_claimed = True if claimed_users else False |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
426 |
|
72 | 427 |
context = {'user':user, |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
428 |
'is_reviewer':is_reviewer, |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
429 |
'task':task, |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
430 |
'claims':claims, |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
431 |
'user_can_claim':user_can_claim, |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
432 |
'task_claimable':task_claimable, |
33
0d0ea7b188d5
fixed a bug in templates/task/claim.html which required modification of views/task.py; also changed the no.of char limit on task title .
nishanth
parents:
25
diff
changeset
|
433 |
'task_claimed':task_claimed, |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
434 |
'errors':errors} |
22 | 435 |
|
436 |
if not is_guest: |
|
205 | 437 |
form = ClaimTaskForm() |
438 |
context['form'] = form |
|
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
439 |
if request.method == "POST": |
205 | 440 |
form = ClaimTaskForm(request.POST) |
441 |
context['form'] = form |
|
442 |
if form.is_valid(): |
|
443 |
claim_proposal = form.cleaned_data['message'] |
|
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
444 |
addClaim(task, claim_proposal, user) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
445 |
return redirect(claim_url) |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
446 |
else: |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
447 |
return render_to_response('task/claim.html', context) |
22 | 448 |
else: |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
449 |
return render_to_response('task/claim.html', context) |
22 | 450 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
451 |
return show_msg(user, 'You are not logged in to view claims for this task', task_url, 'view the task') |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
452 |
|
94 | 453 |
def rem_user(request, tid): |
454 |
""" show a list of working users and ask for a message/reason for removing user. |
|
455 |
""" |
|
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
456 |
|
94 | 457 |
task_url = "/task/view/tid=%s"%tid |
458 |
||
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
459 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
94 | 460 |
task = getTask(tid) |
461 |
||
462 |
is_guest = True if not user.is_authenticated() else False |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
463 |
is_reviewer = True if user in task.reviewers.all() else False |
94 | 464 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
465 |
if (not is_guest) and is_reviewer: |
94 | 466 |
|
467 |
assigned_users = task.assigned_users.all() |
|
468 |
choices = [ (_.id,_.username) for _ in assigned_users ] |
|
469 |
context = { |
|
470 |
'user':user, |
|
471 |
'task':task, |
|
472 |
} |
|
158
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
473 |
|
162 | 474 |
if task.status in ["WR"]: |
158
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
475 |
if assigned_users: |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
476 |
form = RemoveUserForm(choices) |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
477 |
context['form'] = form |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
478 |
if request.method == "POST": |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
479 |
data = request.POST |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
480 |
form = RemoveUserForm(choices, data) |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
481 |
if form.is_valid(): |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
482 |
data = form.cleaned_data |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
483 |
uid = data['user'] |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
484 |
reason = data['reason'] |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
485 |
rem_user = User.objects.get(id=uid) |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
486 |
removeUser(task, rem_user, user, reason) |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
487 |
return redirect(task_url) |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
488 |
else: |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
489 |
context['form'] = form |
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
490 |
return render_to_response('task/remove_user.html', context) |
94 | 491 |
else: |
158
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
492 |
return render_to_response('task/remove_user.html',context) |
94 | 493 |
else: |
158
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
494 |
return show_msg(user, "There is no one working on this task to be kicked off", task_url, "view the task") |
94 | 495 |
else: |
158
c43e0114e593
removing user deletes all the pending requests that request giving him pynts.
nishanth
parents:
157
diff
changeset
|
496 |
return show_msg(user, "This is not the stage to remove users", task_url, "view the task") |
94 | 497 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
498 |
return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
94 | 499 |
|
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
500 |
def assign_task(request, tid): |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
501 |
""" first get the status of the task and then assign it to one of claimed users |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
502 |
generate list of claimed users by passing it as an argument to a function. |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
503 |
""" |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
504 |
|
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
505 |
task_url = "/task/view/tid=%s"%tid |
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
506 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
507 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
55
ca2486e29178
added a utility called getTask in task events and made changes in task views accordingly
nishanth
parents:
36
diff
changeset
|
508 |
task = getTask(tid) |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
509 |
|
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
510 |
is_guest = True if not user.is_authenticated() else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
511 |
is_reviewer = True if user in task.reviewers.all() else False |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
512 |
|
75
fa59955a340b
modified the assign task view to suit the new design
nishanth
parents:
72
diff
changeset
|
513 |
claimed_users = task.claimed_users.all() |
fa59955a340b
modified the assign task view to suit the new design
nishanth
parents:
72
diff
changeset
|
514 |
assigned_users = task.assigned_users.all() |
fa59955a340b
modified the assign task view to suit the new design
nishanth
parents:
72
diff
changeset
|
515 |
|
fa59955a340b
modified the assign task view to suit the new design
nishanth
parents:
72
diff
changeset
|
516 |
task_claimed = True if claimed_users else False |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
17
diff
changeset
|
517 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
518 |
if (not is_guest) and is_reviewer: |
157
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
519 |
if task.status in ["OP", "WR"]: |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
520 |
if task_claimed: |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
521 |
user_list = ((user.id,user.username) for user in claimed_users) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
522 |
form = ChoiceForm(user_list) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
523 |
|
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
524 |
if request.method == "POST": |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
525 |
uid = request.POST['choice'] |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
526 |
assigned_user = User.objects.get(id=uid) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
527 |
assignTask(task, assigned_user, user) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
528 |
return redirect(task_url) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
529 |
else: |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
530 |
return render_to_response('task/assign.html',{'user':user, 'task':task,'form':form}) |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
531 |
elif assigned_users: |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
532 |
return show_msg(user, 'When the no of users you need for the task is more than the no of users willing to do the task, I\'d say please re consider the task :P',task_url, 'view the task') |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
533 |
else: |
157
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
534 |
return show_msg(user, 'Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task') |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
535 |
else: |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
536 |
return show_msg(user, "The task cannot be assigned to users at this stage", task_url, 'view the task') |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
537 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
538 |
return show_msg(user, 'You are not authorised to perform this action', task_url, 'view the task') |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
539 |
|
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
540 |
def assign_pynts(request, tid): |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
541 |
""" Check if the user is a reviewer and pynts can be assigned. |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
542 |
Then display all the approved pynts. |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
543 |
Then see if reviewer can assign pynts to users also or only reviewers. |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
544 |
Then put up a form for reviewer to assign pynts accordingly. |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
545 |
""" |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
546 |
|
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
547 |
task_url = "/task/view/tid=%s"%tid |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
548 |
|
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
549 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
550 |
task = getTask(tid) |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
551 |
|
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
552 |
## the moment we see that user had requested pynts, it means he had worked and hence we change the status to WR |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
553 |
## we have to discuss on this since, pynts may also be given to reviewer |
157
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
554 |
task.status = "WR" |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
555 |
task.save() |
65d5e9737d1c
fixed assign_task method to display a not_allowed message if task status not in OP WR.
nishanth
parents:
156
diff
changeset
|
556 |
|
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
557 |
is_guest = True if not user.is_authenticated() else False |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
558 |
is_reviewer = True if (not is_guest) and user in task.reviewers.all() else False |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
559 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
560 |
if is_reviewer: |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
561 |
if task.status in ["OP", "WR"]: |
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
562 |
choices = [(_.id,_.username) for _ in task.reviewers.all()] |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
563 |
if task.status == "WR": |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
564 |
choices.extend([(_.id, _.username) for _ in task.assigned_users.all() ]) |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
565 |
prev_pynts = task.request_task.filter(role="PY",is_valid=True,is_replied=True,reply=True).count() |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
566 |
pynt_requests = task.request_task.filter(role="PY",is_valid=True).order_by('creation_date').reverse() |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
567 |
form = AssignPyntForm(choices) |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
568 |
|
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
569 |
context = { |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
570 |
'user':user, |
96
2881ed1c52b0
added events addCredits and assignCredits and modified assign_credits view accordingly.
nishanth
parents:
94
diff
changeset
|
571 |
'task':task, |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
572 |
'prev_pynts':prev_pynts, |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
573 |
'pynt_requests':pynt_requests, |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
574 |
'form':form, |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
575 |
} |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
576 |
|
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
577 |
if request.method == "POST": |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
578 |
data = request.POST |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
579 |
form = AssignPyntForm(choices, data) |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
580 |
if form.is_valid(): |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
581 |
data = form.cleaned_data |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
582 |
uid = data['user'] |
136
8632a44b743d
deducing previous credits for a task using the request model. with a few changes, we can ditchax the credits model.
nishanth
parents:
135
diff
changeset
|
583 |
points = data['pynts'] |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
584 |
given_to = User.objects.get(id=uid) |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
585 |
assignPynts(task=task, given_by=user, given_to=given_to, points=points) |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
586 |
return redirect('/task/assignpynts/tid=%s'%task.id) |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
587 |
else: |
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
588 |
context['form'] = form |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
589 |
return render_to_response('task/assignpynts.html', context) |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
590 |
else: |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
591 |
return render_to_response('task/assignpynts.html', context) |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
592 |
else: |
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
593 |
return show_msg(user, "Pynts cannot be assigned at this stage", task_url, "view the task") |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
594 |
else: |
108
131554cc3434
updated show_msg method to also use the user variable in the context.
nishanth
parents:
105
diff
changeset
|
595 |
return show_msg(user, "You are not authorised to perform this action", task_url, "view the task") |
93
1a1e712e60fd
finished assign_credits view. hav to integrate it with requests now.
nishanth
parents:
92
diff
changeset
|
596 |
|
36
0f10deac0a9b
made urls.py look better and added an empty method edit_task to taskViews .
nishanth
parents:
34
diff
changeset
|
597 |
def edit_task(request, tid): |
0f10deac0a9b
made urls.py look better and added an empty method edit_task to taskViews .
nishanth
parents:
34
diff
changeset
|
598 |
""" see what are the attributes that can be edited depending on the current status |
0f10deac0a9b
made urls.py look better and added an empty method edit_task to taskViews .
nishanth
parents:
34
diff
changeset
|
599 |
and then give the user fields accordingly. |
0f10deac0a9b
made urls.py look better and added an empty method edit_task to taskViews .
nishanth
parents:
34
diff
changeset
|
600 |
""" |
25
c0e4fc8b8b5b
added the functionality to assign a task to one of the claimed users.
nishanth
parents:
22
diff
changeset
|
601 |
|
180 | 602 |
task = getTask(tid) |
603 |
||
165 | 604 |
task_url = "/task/view/tid=%s"%tid |
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
605 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
606 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
607 |
is_reviewer = True if user in task.reviewers.all() else False |
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
608 |
can_edit = True if is_reviewer and task.status == "UP" else False |
165 | 609 |
|
610 |
if can_edit: |
|
181 | 611 |
form = EditTaskForm(instance=task) |
165 | 612 |
if request.method=="POST": |
613 |
data = request.POST |
|
181 | 614 |
form = EditTaskForm(data, instance=task) |
165 | 615 |
if form.is_valid(): |
181 | 616 |
form.save() |
165 | 617 |
return redirect(task_url) |
618 |
else: |
|
619 |
return render_to_response('task/edittask.html',{'user':user, 'form':form}) |
|
620 |
else: |
|
621 |
return render_to_response('task/edittask.html',{'user':user, 'form':form}) |
|
622 |
else: |
|
623 |
return show_msg(user, "You cannot edit the task at this stage", task_url, "view the task") |
|
624 |
||
114 | 625 |
def complete_task(request, tid): |
626 |
""" call the event called complete task. |
|
627 |
and also pass it the current user to know who marked it as complete. |
|
628 |
""" |
|
629 |
||
630 |
task_url = "/task/view/tid=%s"%tid |
|
631 |
||
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
632 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
114 | 633 |
task = getTask(tid) |
634 |
||
635 |
is_guest = True if not user.is_authenticated() else False |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
636 |
is_reviewer = True if user in task.reviewers.all() else False |
114 | 637 |
|
638 |
claimed_users = task.claimed_users.all() |
|
639 |
assigned_users = task.assigned_users.all() |
|
640 |
||
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
641 |
assign_pynts_url = '/task/assignpynts/tid=%s'%task.id |
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
642 |
task_assigned_pynts = task.pynt_set.all() |
114 | 643 |
|
644 |
||
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
645 |
if is_reviewer: |
114 | 646 |
if task.status in ["OP", "WR"]: |
647 |
||
648 |
context = { |
|
649 |
'user':user, |
|
650 |
'task':task, |
|
651 |
} |
|
652 |
||
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
653 |
if task_assigned_pynts: |
114 | 654 |
if request.method=="POST": |
655 |
completeTask(task, user) |
|
656 |
return redirect(task_url) |
|
657 |
else: |
|
658 |
return render_to_response('task/complete.html', context) |
|
659 |
else: |
|
219
f04a1ec7a07f
Replaced the word credit with pynt
Nishanth Amuluru <nishanth@fossee.in>
parents:
218
diff
changeset
|
660 |
return show_msg(user, "Nobody has been pynted for doing this task.", assign_pynts_url, "assign pynts") |
114 | 661 |
else: |
662 |
return show_msg(user, "The task cannot be marked as completed at this stage", task_url, "view the task") |
|
663 |
else: |
|
664 |
return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
|
665 |
||
126 | 666 |
def close_task(request, tid): |
667 |
""" task can be closed only if task is published. |
|
668 |
call the event close task if everything is fine. |
|
669 |
""" |
|
670 |
||
671 |
task_url = "/task/view/tid=%s"%tid |
|
672 |
||
141
2489392ffb56
added the functionality to request a user to be AD MG DV.
nishanth
parents:
138
diff
changeset
|
673 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
126 | 674 |
task = getTask(tid) |
675 |
||
676 |
is_guest = True if not user.is_authenticated() else False |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
677 |
is_reviewer = True if user in task.reviewers.all() else False |
126 | 678 |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
679 |
if is_reviewer: |
126 | 680 |
|
681 |
context = { |
|
682 |
'user':user, |
|
683 |
'task':task, |
|
684 |
} |
|
685 |
||
686 |
if not task.status in ["UP", "CD", "DL", "CM"]: |
|
687 |
if request.method == "POST": |
|
688 |
data = request.POST |
|
689 |
if not data.get("reason", None): |
|
690 |
context["error"] = "Please enter a reason for closing the task" |
|
691 |
return render_to_response('task/close.html', context) |
|
692 |
else: |
|
153 | 693 |
closeTask(task, user, data['reason']) |
126 | 694 |
return show_msg(user, "The task has been closed.", task_url, "view the task.") |
695 |
else: |
|
696 |
return render_to_response('task/close.html', context) |
|
697 |
else: |
|
159 | 698 |
return show_msg(user, "The task is either already closed or cannot be closed at this stage", task_url, "view the task") |
126 | 699 |
else: |
700 |
return show_msg(user, "You are not authorised to do this", task_url, "view the task") |
|
167 | 701 |
|
702 |
def delete_task(request, tid): |
|
703 |
""" mark the task status as DL. |
|
218
59107ce0a618
Replaced the word mentor with reviewer
Nishanth Amuluru <nishanth@fossee.in>
parents:
217
diff
changeset
|
704 |
take a reason from the user and pass on to all the other reviewers. |
167 | 705 |
""" |
706 |
||
707 |
task_url = "/task/view/tid=%s"%tid |
|
708 |
||
709 |
task = getTask(tid) |
|
710 |
user = get_user(request.user) if request.user.is_authenticated() else request.user |
|
711 |
||
712 |
if task.status == "DL": |
|
713 |
return show_msg(user, "This task no longer exists", '/task/browse/', "to browse other tasks") |
|
714 |
||
715 |
can_delete = True if task.status == "UP" and task.created_by == user else False |
|
716 |
||
717 |
if can_delete: |
|
718 |
if request.method == "POST": |
|
719 |
data = request.POST |
|
720 |
reason = data.get('reason', None) |
|
721 |
deleteTask(task, user, reason) |
|
722 |
return show_msg(user, "The task is deleted", '/', "to return to home page") |
|
723 |
else: |
|
724 |
return render_to_response('task/delete.html',{'user':user,}) |
|
725 |
else: |
|
726 |
return show_msg(user, "You are not authorised to do this at this stage", task_url, "view the task") |