def change_component(request, project, component): obj = get_component(request, project, component) if not request.user.has_perm('component.edit', obj): raise Http404() if request.method == 'POST': form = ComponentSettingsForm(request, request.POST, instance=obj) if form.is_valid(): form.save() messages.success(request, _('Settings saved')) return redirect('settings', project=obj.project.slug, component=obj.slug) else: messages.error( request, _('Invalid settings, please check the form for errors!')) else: form = ComponentSettingsForm(request, instance=obj) return render( request, 'component-settings.html', { 'project': obj.project, 'object': obj, 'form': form }, )
def change_component(request, project, component): obj = get_component(request, project, component) if not request.user.has_perm("component.edit", obj): raise Http404() if request.method == "POST": form = ComponentSettingsForm(request, request.POST, instance=obj) if form.is_valid(): form.save() messages.success(request, _("Settings saved")) return redirect("settings", project=obj.project.slug, component=obj.slug) else: messages.error( request, _("Invalid settings, please check the form for errors!")) else: form = ComponentSettingsForm(request, instance=obj) return render( request, "component-settings.html", { "project": obj.project, "object": obj, "form": form }, )
def change_component(request, project, component): obj = get_component(request, project, component) if not request.user.has_perm('component.edit', obj): raise Http404() if request.method == 'POST': form = ComponentSettingsForm(request.POST, instance=obj) if form.is_valid(): form.save() messages.success(request, _('Settings saved')) return redirect( 'settings', project=obj.project.slug, component=obj.slug ) else: messages.error( request, _('Invalid settings, please check the form for errors!') ) else: form = ComponentSettingsForm(instance=obj) return render( request, 'component-settings.html', { 'project': obj.project, 'object': obj, 'form': form, } )
def change_component(request, project, component): obj = get_component(request, project, component) if not request.user.has_perm("component.edit", obj): raise Http404() if request.method == "POST": form = ComponentSettingsForm(request, request.POST, instance=obj) if form.is_valid(): form.save() messages.success(request, _("Settings saved")) return redirect("settings", project=obj.project.slug, component=obj.slug) else: messages.error( request, _("Invalid settings, please check the form for errors!")) # Get a fresh copy of object, otherwise it will use unsaved changes # from the failed form obj = Component.objects.get(pk=obj.pk) else: form = ComponentSettingsForm(request, instance=obj) if obj.repo_needs_merge(): messages.warning( request, _("The repository is outdated, you might not get " "expected results until you update it."), ) return render( request, "component-settings.html", { "project": obj.project, "object": obj, "form": form }, )