145 context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False |
145 context['can_assign_pynts'] = True if task.status in ["OP", "WR"] and is_reviewer else False |
146 context['task_claimable'] = True if task.status in ["OP", "WR"] else False |
146 context['task_claimable'] = True if task.status in ["OP", "WR"] else False |
147 |
147 |
148 context['can_comment'] = True if task.status != "UP" or\ |
148 context['can_comment'] = True if task.status != "UP" or\ |
149 profile.rights!="CT" else False |
149 profile.rights!="CT" else False |
|
150 |
|
151 context['can_mod_reviewers'] = True if profile.rights in ["MG", "DC"] else\ |
|
152 False |
150 |
153 |
151 # if task.status == "CD": |
154 # if task.status == "CD": |
152 # context['closing_notification'] = Notification.objects.filter(task=task,role="CD")[0] |
155 # context['closing_notification'] = Notification.objects.filter(task=task,role="CD")[0] |
153 # elif task.status == "CM": |
156 # elif task.status == "CM": |
154 # context['completed_notification'] = Notifications.objects.filter(task=task,role="CM")[0] |
157 # context['completed_notification'] = Notifications.objects.filter(task=task,role="CM")[0] |
251 } |
254 } |
252 |
255 |
253 return render_to_response("task/approved_task.html", context) |
256 return render_to_response("task/approved_task.html", context) |
254 |
257 |
255 @login_required |
258 @login_required |
|
259 def addreviewer(request, tid): |
|
260 |
|
261 user = request.user |
|
262 profile = user.get_profile() |
|
263 |
|
264 task_url = "/task/view/tid=%s"%tid |
|
265 task = getTask(tid) |
|
266 |
|
267 can_mod_reviewers = True if profile.rights in ["MG", "DC"] else False |
|
268 if not can_mod_reviewers: |
|
269 raise Http404 |
|
270 |
|
271 context = {"user": user, |
|
272 "profile": profile, |
|
273 "task": task, |
|
274 } |
|
275 |
|
276 context.update(csrf(request)) |
|
277 |
|
278 |
|
279 # This part has to be made better |
|
280 reviewer_choices = User.objects.filter(is_active=True).\ |
|
281 exclude(reviewing_tasks__uniq_key=tid).\ |
|
282 exclude(claimed_tasks__uniq_key=tid).\ |
|
283 exclude(approved_tasks__uniq_key=tid).\ |
|
284 exclude(created_tasks__uniq_key=tid) |
|
285 choices = ((a_user.id,a_user.username) for a_user in reviewer_choices) |
|
286 label = "Reviewer" |
|
287 |
|
288 if request.method == "POST": |
|
289 form = ChoiceForm(choices, data=request.POST, label=label) |
|
290 if form.is_valid(): |
|
291 data = form.cleaned_data.copy() |
|
292 uid = data['choice'] |
|
293 reviewer = User.objects.get(id=uid) |
|
294 |
|
295 task.reviewers.add(reviewer) |
|
296 return redirect(task_url) |
|
297 else: |
|
298 context.update({"form": form}) |
|
299 return render_to_response("task/addreviewer.html", context) |
|
300 else: |
|
301 form = ChoiceForm(choices, label=label) |
|
302 context.update({"form": form}) |
|
303 return render_to_response("task/addreviewer.html", context) |
|
304 |
|
305 @login_required |
256 def create_textbook(request): |
306 def create_textbook(request): |
257 |
307 |
258 user = request.user |
308 user = request.user |
259 profile = user.get_profile() |
309 profile = user.get_profile() |
260 |
310 |