コード例 #1
0
ファイル: views.py プロジェクト: andrewspiers/karaage
def projectquota_add(request, project_id):

    project = get_object_or_404(Project, pid=project_id)

    project_chunk = ProjectQuota()
    project_chunk.project = project

    form = ProjectQuotaForm(request.POST or None, instance=project_chunk)
    if request.method == 'POST':
        if form.is_valid():
            mc = form.cleaned_data['machine_category']
            conflicting = ProjectQuota.objects.filter(
                project=project, machine_category=mc)

            if conflicting.count() >= 1:
                form._errors["machine_category"] = \
                    ErrorList(
                        ["Cap already exists with this machine category"])
            else:
                project_chunk = form.save()
                new_cap = project_chunk.cap
                return HttpResponseRedirect(project.get_absolute_url())

    return render_to_response(
        'projects/projectquota_form.html',
        locals(),
        context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: kerriwait/karaage
def projectquota_add(request, project_id):

    project = get_object_or_404(Project, id=project_id)

    project_chunk = ProjectQuota()
    project_chunk.project = project

    form = ProjectQuotaForm(request.POST or None, instance=project_chunk)
    if request.method == 'POST':
        if form.is_valid():
            mc = form.cleaned_data['machine_category']
            conflicting = ProjectQuota.objects.filter(project=project,
                                                      machine_category=mc)

            if conflicting.count() >= 1:
                form._errors["machine_category"] = \
                    ErrorList(
                        ["Cap already exists with this machine category"])
            else:
                project_chunk = form.save()
                new_cap = project_chunk.cap
                return HttpResponseRedirect(project.get_absolute_url())

    return render_to_response('karaage/projects/projectquota_form.html',
                              locals(),
                              context_instance=RequestContext(request))
コード例 #3
0
ファイル: admin.py プロジェクト: NeCTAR-RC/karaage
def projectquota_edit(request, projectquota_id):

    project_chunk = get_object_or_404(ProjectQuota, pk=projectquota_id)
    old_cap = project_chunk.cap
    old_mc = project_chunk.machine_category

    form = ProjectQuotaForm(request.POST or None, instance=project_chunk)
    if request.method == 'POST':
        if form.is_valid():
            mc = form.cleaned_data['machine_category']
            if old_mc.pk != mc.pk:
                form._errors["machine_category"] = ErrorList(["Please don't change the machine category; it confuses me"])
            else:
                project_chunk = form.save()
                new_cap = project_chunk.cap
                if old_cap != new_cap:
                    log(request.user, project_chunk.project, 2, 'Changed cap from %s to %s' % (old_cap, new_cap))
                return HttpResponseRedirect(project_chunk.project.get_absolute_url())

    return render_to_response('projects/projectquota_form.html', locals(), context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: kerriwait/karaage
def projectquota_edit(request, projectquota_id):

    project_chunk = get_object_or_404(ProjectQuota, pk=projectquota_id)
    old_mc = project_chunk.machine_category

    form = ProjectQuotaForm(request.POST or None, instance=project_chunk)
    if request.method == 'POST':
        if form.is_valid():
            mc = form.cleaned_data['machine_category']
            if old_mc.pk != mc.pk:
                form._errors["machine_category"] = ErrorList([
                    "Please don't change the machine category; "
                    "it confuses me"
                ])
            else:
                project_chunk = form.save()
                return HttpResponseRedirect(
                    project_chunk.project.get_absolute_url())

    return render_to_response('karaage/projects/projectquota_form.html',
                              locals(),
                              context_instance=RequestContext(request))
コード例 #5
0
def projectquota_edit(request, projectquota_id):

    project_chunk = get_object_or_404(ProjectQuota, pk=projectquota_id)
    old_mc = project_chunk.machine_category

    form = ProjectQuotaForm(request.POST or None, instance=project_chunk)
    if request.method == 'POST':
        if form.is_valid():
            mc = form.cleaned_data['machine_category']
            if old_mc.pk != mc.pk:
                form._errors["machine_category"] = ErrorList([
                    "Please don't change the machine category; "
                    "it confuses me"])
            else:
                project_chunk = form.save()
                return HttpResponseRedirect(
                    project_chunk.project.get_absolute_url())

    return render(
        template_name='karaage/projects/projectquota_form.html',
        context=locals(),
        request=request)