def institutequota_edit(request, institutequota_id): institute_chunk = get_object_or_404(InstituteQuota, pk=institutequota_id) old_mc = institute_chunk.machine_category form = InstituteQuotaForm(request.POST or None, instance=institute_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: institute_chunk = form.save() return HttpResponseRedirect( institute_chunk.institute.get_absolute_url()) return render_to_response('karaage/institutes/institutequota_form.html', { 'form': form, 'institute': institute_chunk.institute, 'object': institute_chunk }, context_instance=RequestContext(request))
def institutequota_add(request, institute_id): institute = get_object_or_404(Institute, pk=institute_id) institute_chunk = InstituteQuota() institute_chunk.institute = institute form = InstituteQuotaForm(request.POST or None, instance=institute_chunk) if request.method == 'POST': if form.is_valid(): mc = form.cleaned_data['machine_category'] conflicting = InstituteQuota.objects.filter(institute=institute, machine_category=mc) if conflicting.count() >= 1: form._errors["machine_category"] = \ ErrorList([ "Cap already exists with this machine category"]) else: institute_chunk = form.save() return HttpResponseRedirect(institute.get_absolute_url()) return render_to_response('karaage/institutes/institutequota_form.html', { 'form': form, 'institute': institute, }, context_instance=RequestContext(request))
def institutequota_add(request, institute_id): institute = get_object_or_404(Institute, pk=institute_id) institute_chunk = InstituteQuota() institute_chunk.institute = institute form = InstituteQuotaForm(request.POST or None, instance=institute_chunk) if request.method == 'POST': if form.is_valid(): mc = form.cleaned_data['machine_category'] conflicting = InstituteQuota.objects.filter( institute=institute, machine_category=mc) if conflicting.count() >= 1: form._errors["machine_category"] = \ ErrorList([ "Cap already exists with this machine category"]) else: institute_chunk = form.save() return HttpResponseRedirect(institute.get_absolute_url()) return render_to_response( 'karaage/institutes/institutequota_form.html', {'form': form, 'institute': institute, }, context_instance=RequestContext(request))
def institutequota_edit(request, institutequota_id): institute_chunk = get_object_or_404(InstituteQuota, pk=institutequota_id) old_mc = institute_chunk.machine_category form = InstituteQuotaForm(request.POST or None, instance=institute_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: institute_chunk = form.save() return HttpResponseRedirect(institute_chunk.institute.get_absolute_url()) return render( template_name="karaage/institutes/institutequota_form.html", context={"form": form, "institute": institute_chunk.institute, "object": institute_chunk}, request=request, )
def institutequota_edit(request, institutequota_id): institute_chunk = get_object_or_404(InstituteQuota, pk=institutequota_id) old_mc = institute_chunk.machine_category form = InstituteQuotaForm(request.POST or None, instance=institute_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: institute_chunk = form.save() return HttpResponseRedirect( institute_chunk.institute.get_absolute_url()) return render_to_response( 'karaage/institutes/institutequota_form.html', {'form': form, 'institute': institute_chunk.institute, 'object': institute_chunk}, context_instance=RequestContext(request))
def institutequota_add(request, institute_id): institute = get_object_or_404(Institute, pk=institute_id) institute_chunk = InstituteQuota() institute_chunk.institute = institute form = InstituteQuotaForm(request.POST or None, instance=institute_chunk) if request.method == "POST": if form.is_valid(): mc = form.cleaned_data["machine_category"] conflicting = InstituteQuota.objects.filter(institute=institute, machine_category=mc) if conflicting.count() >= 1: form._errors["machine_category"] = ErrorList(["Cap already exists with this machine category"]) else: institute_chunk = form.save() return HttpResponseRedirect(institute.get_absolute_url()) return render( template_name="karaage/institutes/institutequota_form.html", context={"form": form, "institute": institute}, request=request, )