示例#1
0
 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)
示例#2
0
文件: __init__.py 项目: strogo/djpcms
    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()))
示例#3
0
文件: text.py 项目: strogo/djpcms
 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)