def get_formset(self, request = None, data = None, **kwargs): if not request: formset = self.FormSet(data=data, **kwargs) else: formset = self.FormSet(**form_kwargs(request = request, queryset = self.queryset(request), **kwargs)) return FormsetWrap(formset,self.legend)
def get_form(self, djp, args = None, withdata = True): '''Return an instance of a :attr:`form` or `None`. Used to edit the plugin when in editing mode. Usually, there is no need to override this function. If your plugin needs input parameters when editing, simple set the :attr:`form` attribute. ''' if self.form: initial = self.arguments(args) or None return self.form(**form_kwargs(request = djp.request, initial = initial, withrequest = self.form_withrequest, withdata = withdata, own_view = djp.own_view()))
def edit_form(self, djp, site_content = None, **kwargs): if site_content: try: obj = SiteContent.objects.get(id = int(site_content)) except Exception, e: return None # Check for permissions if has_permission(djp.request.user,get_change_permission(obj), obj): return EditContentForm(**form_kwargs(request = djp.request, instance = obj, withrequest = True, **kwargs)) else: raise PermissionDenied("Cannot edit '%s'. You don't have the right permissions" % obj)