Ejemplo n.º 1
0
def parameter_add(request, task_id):
    task = get_object_or_404(Task, pk=task_id)
    if not request.user.has_perm('exmo2010.admin_monitoring', task.organization.monitoring):
        return HttpResponseForbidden(_('Forbidden'))
    redirect = '%s?%s' % (reverse('exmo2010:score_list_by_task', args=[task.pk]), request.GET.urlencode())
    redirect = redirect.replace("%", "%%")
    title = _('Add parameter for %s') % task
    form = None
    if request.method == 'GET':
        form = ParameterForm(monitoring=task.organization.monitoring)
    elif request.method == 'POST':
        form = ParameterForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(redirect)

    crumbs = ['Home', 'Monitoring', 'Organization', 'ScoreList']
    breadcrumbs(request, crumbs, task)
    current_title = _('Add parameter')

    return render_to_response(
        'parameter_form.html',
        {
            'form': form,
            'current_title': current_title,
            'title': title,
            'task': task,
            'media': CORE_MEDIA + form.media,
        },
        context_instance=RequestContext(request),
    )
Ejemplo n.º 2
0
def parameter_add(request, task_pk):
    task = get_object_or_404(Task, pk=task_pk)
    if not request.user.has_perm('exmo2010.admin_monitoring', task.organization.monitoring):
        return HttpResponseForbidden(_('Forbidden'))
    redirect = '%s?%s' % (reverse('exmo2010:score_list_by_task', args=[task.pk]), request.GET.urlencode())
    redirect = redirect.replace("%", "%%")
    title = _('Add parameter for %s') % task
    form = None
    if request.method == 'GET':
        form = ParameterForm(monitoring=task.organization.monitoring)
    elif request.method == 'POST':
        form = ParameterForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(redirect)

    return TemplateResponse(request, 'parameter_form.html', {
        'form': form,
        'title': title,
        'media': CORE_MEDIA + form.media,
    })