def add_license(request, software_id): software = get_object_or_404(Software, pk=software_id) form = LicenseForm(request.POST or None) if request.method == 'POST': if form.is_valid(): l = form.save() log(request.user, software, 1, "license: %s added" % l) return HttpResponseRedirect(software.get_absolute_url()) return render_to_response('software/license_form.html', locals(), context_instance=RequestContext(request))
def edit_license(request, license_id): l = get_object_or_404(SoftwareLicense, pk=license_id) software = l.software form = LicenseForm(request.POST or None, instance=l) if request.method == 'POST': if form.is_valid(): form.save() return HttpResponseRedirect(software.get_absolute_url()) return render_to_response('software/license_form.html', locals(), context_instance=RequestContext(request))
def add_edit_license(request, package_id, license_id=None): package = get_object_or_404(SoftwarePackage, pk=package_id) if license_id is None: l = None else: l = get_object_or_404(SoftwareLicense, pk=license_id) if request.method == 'POST': form = LicenseForm(request.POST, instance=l) if form.is_valid(): l = form.save() if license_id is None: log(request.user, package, 1, "license: %s added" % l) package.save() return HttpResponseRedirect(package.get_absolute_url()) else: form = LicenseForm(instance=l) return render_to_response('software/license_form.html', locals(), context_instance=RequestContext(request))