def fpcommand_delete(request, uuid): command = get_object_or_404(fprmodels.FPCommand, uuid=uuid) dependent_objects = utils.dependent_objects(command) breadcrumbs = [ { 'text': _('Format policy commands'), 'link': reverse('fpcommand_list') }, { 'text': command.description, 'link': reverse('fpcommand_detail', args=[command.uuid]) }, ] if request.method == 'POST': if 'disable' in request.POST: command.enabled = False messages.info(request, _('Disabled.')) for obj in dependent_objects: obj['value'].enabled = False obj['value'].save() if 'enable' in request.POST: command.enabled = True messages.info(request, _('Enabled.')) command.save() return redirect('fpcommand_detail', command.uuid) return render( request, 'fpr/disable.html', context({ 'breadcrumbs': breadcrumbs, 'dependent_objects': dependent_objects, 'form_url': reverse('fpcommand_delete', args=[command.uuid]), 'toggle_label': _('Enable/disable format policy command'), 'object': command, }))
def fpcommand_delete(request, uuid): command = get_object_or_404(fprmodels.FPCommand, uuid=uuid) dependent_objects = utils.dependent_objects(command) breadcrumbs = [ {"text": _("Format policy commands"), "link": reverse("fpcommand_list")}, { "text": command.description, "link": reverse("fpcommand_detail", args=[command.uuid]), }, ] if request.method == "POST": if "disable" in request.POST: command.enabled = False messages.info(request, _("Disabled.")) for obj in dependent_objects: obj["value"].enabled = False obj["value"].save() if "enable" in request.POST: command.enabled = True messages.info(request, _("Enabled.")) command.save() return redirect("fpcommand_detail", command.uuid) return render( request, "fpr/disable.html", context( { "breadcrumbs": breadcrumbs, "dependent_objects": dependent_objects, "form_url": reverse("fpcommand_delete", args=[command.uuid]), "toggle_label": _("Enable/disable format policy command"), "object": command, } ), )
def formatversion_delete(request, format_slug, slug): format = get_object_or_404(fprmodels.Format, slug=format_slug) version = get_object_or_404(fprmodels.FormatVersion, slug=slug, format=format) dependent_objects = utils.dependent_objects(version) breadcrumbs = [ { "text": _("Format versions"), "link": reverse("format_list") }, { "text": format.description, "link": reverse("format_detail", args=[format.slug]), }, ] if request.method == "POST": if "disable" in request.POST: version.enabled = False messages.info(request, _("Disabled.")) for obj in dependent_objects: obj["value"].enabled = False obj["value"].save() if "enable" in request.POST: version.enabled = True messages.info(request, _("Enabled.")) version.save() return redirect("format_detail", format.slug) return render( request, "fpr/disable.html", context({ "breadcrumbs": breadcrumbs, "dependent_objects": dependent_objects, "form_url": reverse("formatversion_delete", args=[format.slug, version.slug]), "toggle_label": _("Enable/disable format version"), "object": version, }), )
def formatversion_delete(request, format_slug, slug): format = get_object_or_404(fprmodels.Format, slug=format_slug) version = get_object_or_404(fprmodels.FormatVersion, slug=slug, format=format) dependent_objects = utils.dependent_objects(version) breadcrumbs = [ { 'text': _('Format versions'), 'link': reverse('format_list') }, { 'text': format.description, 'link': reverse('format_detail', args=[format.slug]) }, ] if request.method == 'POST': if 'disable' in request.POST: version.enabled = False messages.info(request, _('Disabled.')) for obj in dependent_objects: obj['value'].enabled = False obj['value'].save() if 'enable' in request.POST: version.enabled = True messages.info(request, _('Enabled.')) version.save() return redirect('format_detail', format.slug) return render( request, 'fpr/disable.html', context({ 'breadcrumbs': breadcrumbs, 'dependent_objects': dependent_objects, 'form_url': reverse('formatversion_delete', args=[format.slug, version.slug]), 'toggle_label': _('Enable/disable format version'), 'object': version, }))