def check_directory_permission(permission_codename, request, directory):
 if request.user.is_superuser:
  return True
 if (permission_codename == 'view'):
  context = None
  context = getattr(directory, 'tp', None)
  if (context is None):
   context = getattr(directory, 'project', None)
  if (context is None):
   return True
  return context.is_accessible_by(request.user)
 return (('administrate' in request.permissions) or (permission_codename in request.permissions))

def check_directory_permission ( permission_codename , request , directory ) : if request . user . is_superuser : return True if ( permission_codename == 'view' ) : context = None context = getattr ( directory , 'tp' , None ) if ( context is None ) : context = getattr ( directory , 'project' , None ) if ( context is None ) : return True return context . is_accessible_by ( request . user ) return ( ( 'administrate' in request . permissions ) or ( permission_codename in request . permissions ) )
checks if the current user has permission_codename permissions for a given directory .