def task_status_edit(request, status_id, response_format='html'): """TaskStatus edit""" status = get_object_or_404(TaskStatus, pk=status_id) if not request.user.profile.has_permission(status, mode='w'): return user_denied(request, message="You don't have access to this Task Status") if request.POST: if 'cancel' not in request.POST: form = TaskStatusForm( request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id])) else: return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id])) else: form = TaskStatusForm(request.user.profile, instance=status) context = _get_default_context(request) context.update({'form': form, 'status': status}) return render_to_response('projects/status_edit', context, context_instance=RequestContext(request), response_format=response_format)
def task_change_status(task_id): if not current_user.is_authenticated: return is_not_auth() task = Task.get(Task.id == task_id) form = TaskStatusForm(formdata=request.form, obj=task) if request.method == "GET": content = render_form(form=form, action=url_for("task_change_status", task_id=task_id), button="Обновить") return render_content(content, "Изменить статус - {}".format(task.title)) if request.method == 'POST' and form.validate(): status = request.form['status'] task.status = status task.save() flash('Статус <b><em>{}</em></b> успешно обновлен'.format(task.title), 'success') return redirect(url_for('task_list'))
def task_status_add(request, response_format='html'): """TaskStatus add""" if not request.user.profile.is_admin('anaf.projects'): return user_denied(request, message="You don't have administrator access to the Projects module") if request.POST: if 'cancel' not in request.POST: status = TaskStatus() form = TaskStatusForm( request.user.profile, request.POST, instance=status) if form.is_valid(): status = form.save() status.set_user_from_request(request) return HttpResponseRedirect(reverse('projects_index_by_status', args=[status.id])) else: return HttpResponseRedirect(reverse('projects_settings_view')) else: form = TaskStatusForm(request.user.profile) context = _get_default_context(request) context.update({'form': form}) return render_to_response('projects/status_add', context, context_instance=RequestContext(request), response_format=response_format)