code: def checkUserAccess(worksheet, request, redirect=True):
      
      # Deny access to foreign analysts
      allowed = worksheet.checkUserAccess()
      if allowed == False and redirect == True:
          msg =  _('You do not have sufficient privileges to view '
                   'the worksheet ${worksheet_title}.',
                   mapping={"worksheet_title": worksheet.Title()})
          worksheet.plone_utils.addPortalMessage(msg, 'warning')
          # Redirect to WS list
          portal = getToolByName(worksheet, 'portal_url').getPortalObject()
          destination_url = portal.absolute_url() + "/worksheets"
          request.response.redirect(destination_url)
  
      return allowed
docs: Checks if the current user has granted access to the worksheet.
          If the user is an analyst without LabManager, LabClerk and
          RegulatoryInspector roles and the option 'Allow analysts
          only to access to the Worksheets on which they are assigned' is
          ticked and the above condition is true, it will redirect to
          the main Worksheets view.
          Returns False if the user has no access, otherwise returns True