示例#1
0
文件: baseview.py 项目: strogo/djpcms
 def has_permission(self, request = None, page = None, obj = None):
     '''Check if view can be displayed.
     '''
     if request and page:
         return has_permission(request.user,get_view_permission(page),page)
     else:
         return True
示例#2
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)
示例#3
0
文件: page.py 项目: strogo/djpcms
    def render(self, djp, plugin = None, wrapper = None):
        '''Render the plugin in the content block
This function call the plugin render function and wrap the resulting HTML
with the wrapper callable.'''
        html = ''
        try:
            plugin  = plugin or self.plugin
            wrapper = wrapper or self.wrapper
            if plugin:
                if has_permission(djp.request.user,get_view_permission(self), self):
                    djp.media += plugin.media
                    html = plugin(djp, self.arguments, wrapper = wrapper)
        except Exception, e:
            if getattr(djp.settings,'TESTING',False):
                raise
            exc_info = sys.exc_info()
            self.logger.error('%s - block %s -- %s' % (plugin,self,e),
                exc_info=exc_info,
                extra={'request':djp.request}
            )
            if djp.request.user.is_superuser:
                html = escape(u'%s' % e)
示例#4
0
文件: _django.py 项目: strogo/djpcms
 def has_delete_permission(self, user, obj=None):
     return has_permission(user, self.get_delete_permission(), obj)
示例#5
0
文件: _django.py 项目: strogo/djpcms
 def has_view_permission(self, user, obj = None):
     return has_permission(user, self.get_view_permission(), obj)
示例#6
0
文件: _django.py 项目: strogo/djpcms
 def has_change_permission(self, user, obj=None):
     return has_permission(user, self.get_change_permission(), obj)