def post(self, request, **kwargs): component = self.get_component() name = request.POST.get('name') addon = ADDONS.get(name) installed = set([x.addon.name for x in self.get_queryset()]) if (not name or addon is None or not addon.can_install(component, request.user) or (name in installed and not addon.multiple)): return self.redirect_list(_('Invalid addon name specified!')) form = None if addon.settings_form is None: addon.create(component) return self.redirect_list() elif 'form' in request.POST: form = addon.get_add_form(component, data=request.POST) if form.is_valid(): form.save() return self.redirect_list() else: form = addon.get_add_form(component) return self.response_class( request=self.request, template=['addons/addon_detail.html'], context={ 'addon': addon, 'form': form, 'object': self.kwargs['component_obj'], }, )
def post(self, request, **kwargs): component = self.get_component() name = request.POST.get("name") addon = ADDONS.get(name) installed = {x.addon.name for x in self.get_queryset()} if (not name or addon is None or not addon.can_install(component, request.user) or (name in installed and not addon.multiple)): return self.redirect_list(_("Invalid addon name specified!")) form = None if addon.settings_form is None: addon.create(component) return self.redirect_list() if "form" in request.POST: form = addon.get_add_form(component, data=request.POST) if form.is_valid(): form.save() return self.redirect_list() else: form = addon.get_add_form(component) addon.pre_install(component, request) return self.response_class( request=self.request, template=["addons/addon_detail.html"], context={ "addon": addon, "form": form, "object": self.kwargs["component_obj"], }, )