13 from pytask.views import show_msg |
13 from pytask.views import show_msg |
14 |
14 |
15 from pytask.taskapp.models import Task, TaskComment, TaskClaim |
15 from pytask.taskapp.models import Task, TaskComment, TaskClaim |
16 from pytask.taskapp.forms import CreateTaskForm, EditTaskForm, \ |
16 from pytask.taskapp.forms import CreateTaskForm, EditTaskForm, \ |
17 TaskCommentForm, ClaimTaskForm, \ |
17 TaskCommentForm, ClaimTaskForm, \ |
18 ChoiceForm |
18 ChoiceForm, EditTaskForm |
19 from pytask.taskapp.utils import getTask |
19 from pytask.taskapp.utils import getTask |
20 from pytask.profile.utils import get_notification |
20 from pytask.profile.utils import get_notification |
21 |
21 |
22 |
22 |
23 @login_required |
23 @login_required |
106 context['selected_users'] = selected_users |
106 context['selected_users'] = selected_users |
107 context['is_selected'] = True if user in selected_users else False |
107 context['is_selected'] = True if user in selected_users else False |
108 context['can_approve'] = True if task.status == "UP" and\ |
108 context['can_approve'] = True if task.status == "UP" and\ |
109 profile.rights in ["MG", "DC"]\ |
109 profile.rights in ["MG", "DC"]\ |
110 else False |
110 else False |
111 context['can_edit'] = True if is_creator else False |
111 context['can_edit'] = True if is_creator and task.status == "UP" else False |
112 context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_reviewer else False |
112 context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_reviewer else False |
113 context['can_delete'] = True if task.status == "UP" and is_creator else False |
113 context['can_delete'] = True if task.status == "UP" and is_creator else False |
114 |
114 |
115 context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False |
115 context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False |
116 context['task_claimable'] = True if task.status in ["OP", "WR"] else False |
116 context['task_claimable'] = True if task.status in ["OP", "WR"] else False |
141 form = TaskCommentForm() |
141 form = TaskCommentForm() |
142 context['form'] = form |
142 context['form'] = form |
143 return render_to_response('task/view.html', context) |
143 return render_to_response('task/view.html', context) |
144 |
144 |
145 @login_required |
145 @login_required |
|
146 def edit_task(request, tid): |
|
147 """ only creator gets to edit the task and that too only before it gets |
|
148 approved. |
|
149 """ |
|
150 |
|
151 user = request.user |
|
152 profile = user.get_profile() |
|
153 |
|
154 task_url = "/task/view/tid=%s"%tid |
|
155 task = getTask(tid) |
|
156 |
|
157 is_creator = True if user == task.created_by else False |
|
158 can_edit = True if task.status == "UP" and is_creator else False |
|
159 if not can_edit: |
|
160 raise Http404 |
|
161 |
|
162 context = {"user": user, |
|
163 "profile": profile, |
|
164 "task": task, |
|
165 } |
|
166 |
|
167 context.update(csrf(request)) |
|
168 |
|
169 if request.method == "POST": |
|
170 form = EditTaskForm(request.POST, instance=task) |
|
171 if form.is_valid(): |
|
172 form.save() |
|
173 return redirect(task_url) |
|
174 else: |
|
175 context.update({"form": form}) |
|
176 return render_to_response("task/edit.html", context) |
|
177 else: |
|
178 form = EditTaskForm(instance=task) |
|
179 context.update({"form": form}) |
|
180 return render_to_response("task/edit.html", context) |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 @login_required |
146 def claim_task(request, tid): |
186 def claim_task(request, tid): |
147 |
187 |
148 task_url = "/task/view/tid=%s"%tid |
188 task_url = "/task/view/tid=%s"%tid |
149 claim_url = "/task/claim/tid=%s"%tid |
189 claim_url = "/task/claim/tid=%s"%tid |
150 task = getTask(tid) |
190 task = getTask(tid) |