def edit_status(request, slug): project = get_object_or_404(Project, slug=slug) metric_permissions = project.get_metrics_permissions(request.user) if request.method == 'POST': form = project_forms.ProjectStatusForm( request.POST, instance=project) if form.is_valid(): project = form.save(commit=False) project.set_duration(form.cleaned_data['duration']) project.save() messages.success(request, _('%s updated!') % project.kind.capitalize()) return http.HttpResponseRedirect(reverse('projects_edit_status', kwargs={ 'slug': project.slug, })) else: msg = _('There was a problem saving the %s\'s status.') messages.error(request, msg % project.kind.lower()) else: form = project_forms.ProjectStatusForm(instance=project, initial={'duration': project.get_duration()}) return render_to_response('projects/project_edit_status.html', { 'form': form, 'project': project, 'status_tab': True, 'can_view_metric_overview': metric_permissions, 'is_challenge': (project.category == project.CHALLENGE), }, context_instance=RequestContext(request))
def edit_status(request, slug): project = get_object_or_404(Project, slug=slug) metric_permissions = project.get_metrics_permissions(request.user) if request.method == 'POST': form = project_forms.ProjectStatusForm(request.POST, instance=project) if form.is_valid(): form.save() return http.HttpResponseRedirect( reverse('projects_show', kwargs={ 'slug': project.slug, })) else: msg = _('There was a problem saving the %s\'s status.') messages.error(request, msg % project.kind.lower()) else: form = project_forms.ProjectStatusForm(instance=project) return render_to_response( 'projects/project_edit_status.html', { 'form': form, 'project': project, 'status_tab': True, 'can_view_metric_overview': metric_permissions[0], 'is_challenge': (project.category == project.CHALLENGE), }, context_instance=RequestContext(request))
def edit_status(request, slug): project = get_object_or_404(Project, slug=slug) if request.method == 'POST': form = project_forms.ProjectStatusForm( request.POST, instance=project) if form.is_valid(): form.save() return http.HttpResponseRedirect(reverse('projects_show', kwargs={ 'slug': project.slug, })) else: messages.error(request, _('There was a problem saving study group\'s status.')) else: form = project_forms.ProjectStatusForm(instance=project) return render_to_response('projects/project_edit_status.html', { 'form': form, 'project': project, 'status_tab': True, }, context_instance=RequestContext(request))