def check_permission(permission_codename, request):
 if request.user.is_superuser:
  return True
 if (permission_codename == 'view'):
  path_obj = None
  if hasattr(request, 'translation_project'):
   path_obj = request.translation_project
  elif hasattr(request, 'project'):
   path_obj = request.project
  if (path_obj is None):
   return True
  return path_obj.is_accessible_by(request.user)
 return (('administrate' in request.permissions) or (permission_codename in request.permissions))

def check_permission ( permission_codename , request ) : if request . user . is_superuser : return True if ( permission_codename == 'view' ) : path_obj = None if hasattr ( request , 'translation_project' ) : path_obj = request . translation_project elif hasattr ( request , 'project' ) : path_obj = request . project if ( path_obj is None ) : return True return path_obj . is_accessible_by ( request . user ) return ( ( 'administrate' in request . permissions ) or ( permission_codename in request . permissions ) )
generic check for permission with owner fallback .