prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Improve documentation of cms rules
  Explain the rules module and how it interacts with our permission management. Add docstrings of the following format:
  ```
  """
  [Summary]
  
  :param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]
  :type [ParamName]: [ParamType](, optional)
  ...
  :raises [ErrorType]: [ErrorDescription]
  ...
  :return: [ReturnDescription]
  :rtype: [ReturnType]
  """
  ```
  Improve documentation of cms rules
  Explain the rules module and how it interacts with our permission management. Add docstrings of the following format:
  ```
  """
  [Summary]
  
  :param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]
  :type [ParamName]: [ParamType](, optional)
  ...
  :raises [ErrorType]: [ErrorDescription]
  ...
  :return: [ReturnDescription]
  :rtype: [ReturnType]
  """
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cms/rules.py`
  Content:
  ```
  1 from rules import add_perm, predicate
  2 
  3 
  4 # Predicates
  5 
  6 @predicate
  7 def is_page_editor(user, page):
  8     if not page:
  9         return False
  10     return user in page.editors.all()
  11 
  12 @predicate
  13 def is_page_publisher(user, page):
  14     if not page:
  15         return False
  16     return user in page.publishers.all()
  17 
  18 @predicate
  19 # pylint: disable=unused-argument
  20 def can_edit_all_pages(user, page):
  21     return user.has_perm('cms.edit_pages')
  22 
  23 @predicate
  24 # pylint: disable=unused-argument
  25 def can_publish_all_pages(user, page):
  26     return user.has_perm('cms.publish_pages')
  27 
  28 
  29 # Permissions
  30 
  31 add_perm('cms.edit_page', can_edit_all_pages | is_page_editor | can_publish_all_pages | is_page_publisher)
  32 add_perm('cms.publish_page', can_publish_all_pages | is_page_publisher)
  33
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/cms/rules.py b/src/cms/rules.py
  --- a/src/cms/rules.py
  +++ b/src/cms/rules.py
  @@ -1,3 +1,22 @@
  +"""
  +We use `django-rules <https://pypi.org/project/rules/>`_ to add custom permissions for specific pages.
  +
  +For a given user and page, the following permissions are added:
  +
  +* ``cms.edit_page`` if one of the following predicates return true:
  +
  +    * :func:`~cms.rules.can_edit_all_pages`
  +    * :func:`~cms.rules.is_page_editor`
  +    * :func:`~cms.rules.can_publish_all_pages`
  +    * :func:`~cms.rules.is_page_publisher`
  +
  +* ``cms.publish_page`` if one of the following predicates return true:
  +
  +    * :func:`~cms.rules.can_publish_all_pages`
  +    * :func:`~cms.rules.is_page_publisher`
  +
  +See the project's `README <https://github.com/dfunckt/django-rules/blob/master/README.rst>`_ to learn more.
  +"""
   from rules import add_perm, predicate
   
   
  @@ -5,12 +24,36 @@
   
   @predicate
   def is_page_editor(user, page):
  +    """
  +    This predicate checks whether the given user is one of the editors of the given page.
  +
  +    :param user: The user who's permission should be checked
  +    :type user: ~django.contrib.auth.models.User
  +
  +    :param page: The requested page
  +    :type page: ~cms.models.pages.page.Page
  +
  +    :return: Whether or not ``user`` is an editor of ``page``
  +    :rtype: bool
  +    """
       if not page:
           return False
       return user in page.editors.all()
   
   @predicate
   def is_page_publisher(user, page):
  +    """
  +    This predicate checks whether the given user is one of the publishers of the given page.
  +
  +    :param user: The user who's permission should be checked
  +    :type user: ~django.contrib.auth.models.User
  +
  +    :param page: The requested page
  +    :type page: ~cms.models.pages.page.Page
  +
  +    :return: Whether or not ``user`` is a publisher of ``page``
  +    :rtype: bool
  +    """
       if not page:
           return False
       return user in page.publishers.all()
  @@ -18,11 +61,35 @@
   @predicate
   # pylint: disable=unused-argument
   def can_edit_all_pages(user, page):
  +    """
  +    This predicate checks whether the given user can edit all pages.
  +
  +    :param user: The user who's permission should be checked
  +    :type user: ~django.contrib.auth.models.User
  +
  +    :param page: Unused page parameter (the function signature must match the other predicates)
  +    :type page: ~cms.models.pages.page.Page
  +
  +    :return: Whether or not ``user`` can edit all pages
  +    :rtype: bool
  +    """
       return user.has_perm('cms.edit_pages')
   
   @predicate
   # pylint: disable=unused-argument
   def can_publish_all_pages(user, page):
  +    """
  +    This predicate checks whether the given user can publish all pages.
  +
  +    :param user: The user who's permission should be checked
  +    :type user: ~django.contrib.auth.models.User
  +
  +    :param page: Unused page parameter (the function signature must match the other predicates)
  +    :type page: ~cms.models.pages.page.Page
  +
  +    :return: Whether or not ``user`` can publish all pages
  +    :rtype: bool
  +    """
       return user.has_perm('cms.publish_pages')
  
verification_info: {"golden_diff": "diff --git a/src/cms/rules.py b/src/cms/rules.py\n--- a/src/cms/rules.py\n+++ b/src/cms/rules.py\n@@ -1,3 +1,22 @@\n+\"\"\"\n+We use `django-rules <https://pypi.org/project/rules/>`_ to add custom permissions for specific pages.\n+\n+For a given user and page, the following permissions are added:\n+\n+* ``cms.edit_page`` if one of the following predicates return true:\n+\n+    * :func:`~cms.rules.can_edit_all_pages`\n+    * :func:`~cms.rules.is_page_editor`\n+    * :func:`~cms.rules.can_publish_all_pages`\n+    * :func:`~cms.rules.is_page_publisher`\n+\n+* ``cms.publish_page`` if one of the following predicates return true:\n+\n+    * :func:`~cms.rules.can_publish_all_pages`\n+    * :func:`~cms.rules.is_page_publisher`\n+\n+See the project's `README <https://github.com/dfunckt/django-rules/blob/master/README.rst>`_ to learn more.\n+\"\"\"\n from rules import add_perm, predicate\n \n \n@@ -5,12 +24,36 @@\n \n @predicate\n def is_page_editor(user, page):\n+    \"\"\"\n+    This predicate checks whether the given user is one of the editors of the given page.\n+\n+    :param user: The user who's permission should be checked\n+    :type user: ~django.contrib.auth.models.User\n+\n+    :param page: The requested page\n+    :type page: ~cms.models.pages.page.Page\n+\n+    :return: Whether or not ``user`` is an editor of ``page``\n+    :rtype: bool\n+    \"\"\"\n     if not page:\n         return False\n     return user in page.editors.all()\n \n @predicate\n def is_page_publisher(user, page):\n+    \"\"\"\n+    This predicate checks whether the given user is one of the publishers of the given page.\n+\n+    :param user: The user who's permission should be checked\n+    :type user: ~django.contrib.auth.models.User\n+\n+    :param page: The requested page\n+    :type page: ~cms.models.pages.page.Page\n+\n+    :return: Whether or not ``user`` is a publisher of ``page``\n+    :rtype: bool\n+    \"\"\"\n     if not page:\n         return False\n     return user in page.publishers.all()\n@@ -18,11 +61,35 @@\n @predicate\n # pylint: disable=unused-argument\n def can_edit_all_pages(user, page):\n+    \"\"\"\n+    This predicate checks whether the given user can edit all pages.\n+\n+    :param user: The user who's permission should be checked\n+    :type user: ~django.contrib.auth.models.User\n+\n+    :param page: Unused page parameter (the function signature must match the other predicates)\n+    :type page: ~cms.models.pages.page.Page\n+\n+    :return: Whether or not ``user`` can edit all pages\n+    :rtype: bool\n+    \"\"\"\n     return user.has_perm('cms.edit_pages')\n \n @predicate\n # pylint: disable=unused-argument\n def can_publish_all_pages(user, page):\n+    \"\"\"\n+    This predicate checks whether the given user can publish all pages.\n+\n+    :param user: The user who's permission should be checked\n+    :type user: ~django.contrib.auth.models.User\n+\n+    :param page: Unused page parameter (the function signature must match the other predicates)\n+    :type page: ~cms.models.pages.page.Page\n+\n+    :return: Whether or not ``user`` can publish all pages\n+    :rtype: bool\n+    \"\"\"\n     return user.has_perm('cms.publish_pages')\n", "issue": "Improve documentation of cms rules\nExplain the rules module and how it interacts with our permission management. Add docstrings of the following format:\r\n```\r\n\"\"\"\r\n[Summary]\r\n\r\n:param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]\r\n:type [ParamName]: [ParamType](, optional)\r\n...\r\n:raises [ErrorType]: [ErrorDescription]\r\n...\r\n:return: [ReturnDescription]\r\n:rtype: [ReturnType]\r\n\"\"\"\r\n```\nImprove documentation of cms rules\nExplain the rules module and how it interacts with our permission management. Add docstrings of the following format:\r\n```\r\n\"\"\"\r\n[Summary]\r\n\r\n:param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]\r\n:type [ParamName]: [ParamType](, optional)\r\n...\r\n:raises [ErrorType]: [ErrorDescription]\r\n...\r\n:return: [ReturnDescription]\r\n:rtype: [ReturnType]\r\n\"\"\"\r\n```\n", "before_files": [{"content": "from rules import add_perm, predicate\n\n\n# Predicates\n\n@predicate\ndef is_page_editor(user, page):\n    if not page:\n        return False\n    return user in page.editors.all()\n\n@predicate\ndef is_page_publisher(user, page):\n    if not page:\n        return False\n    return user in page.publishers.all()\n\n@predicate\n# pylint: disable=unused-argument\ndef can_edit_all_pages(user, page):\n    return user.has_perm('cms.edit_pages')\n\n@predicate\n# pylint: disable=unused-argument\ndef can_publish_all_pages(user, page):\n    return user.has_perm('cms.publish_pages')\n\n\n# Permissions\n\nadd_perm('cms.edit_page', can_edit_all_pages | is_page_editor | can_publish_all_pages | is_page_publisher)\nadd_perm('cms.publish_page', can_publish_all_pages | is_page_publisher)\n", "path": "src/cms/rules.py"}], "after_files": [{"content": "\"\"\"\nWe use `django-rules <https://pypi.org/project/rules/>`_ to add custom permissions for specific pages.\n\nFor a given user and page, the following permissions are added:\n\n* ``cms.edit_page`` if one of the following predicates return true:\n\n    * :func:`~cms.rules.can_edit_all_pages`\n    * :func:`~cms.rules.is_page_editor`\n    * :func:`~cms.rules.can_publish_all_pages`\n    * :func:`~cms.rules.is_page_publisher`\n\n* ``cms.publish_page`` if one of the following predicates return true:\n\n    * :func:`~cms.rules.can_publish_all_pages`\n    * :func:`~cms.rules.is_page_publisher`\n\nSee the project's `README <https://github.com/dfunckt/django-rules/blob/master/README.rst>`_ to learn more.\n\"\"\"\nfrom rules import add_perm, predicate\n\n\n# Predicates\n\n@predicate\ndef is_page_editor(user, page):\n    \"\"\"\n    This predicate checks whether the given user is one of the editors of the given page.\n\n    :param user: The user who's permission should be checked\n    :type user: ~django.contrib.auth.models.User\n\n    :param page: The requested page\n    :type page: ~cms.models.pages.page.Page\n\n    :return: Whether or not ``user`` is an editor of ``page``\n    :rtype: bool\n    \"\"\"\n    if not page:\n        return False\n    return user in page.editors.all()\n\n@predicate\ndef is_page_publisher(user, page):\n    \"\"\"\n    This predicate checks whether the given user is one of the publishers of the given page.\n\n    :param user: The user who's permission should be checked\n    :type user: ~django.contrib.auth.models.User\n\n    :param page: The requested page\n    :type page: ~cms.models.pages.page.Page\n\n    :return: Whether or not ``user`` is a publisher of ``page``\n    :rtype: bool\n    \"\"\"\n    if not page:\n        return False\n    return user in page.publishers.all()\n\n@predicate\n# pylint: disable=unused-argument\ndef can_edit_all_pages(user, page):\n    \"\"\"\n    This predicate checks whether the given user can edit all pages.\n\n    :param user: The user who's permission should be checked\n    :type user: ~django.contrib.auth.models.User\n\n    :param page: Unused page parameter (the function signature must match the other predicates)\n    :type page: ~cms.models.pages.page.Page\n\n    :return: Whether or not ``user`` can edit all pages\n    :rtype: bool\n    \"\"\"\n    return user.has_perm('cms.edit_pages')\n\n@predicate\n# pylint: disable=unused-argument\ndef can_publish_all_pages(user, page):\n    \"\"\"\n    This predicate checks whether the given user can publish all pages.\n\n    :param user: The user who's permission should be checked\n    :type user: ~django.contrib.auth.models.User\n\n    :param page: Unused page parameter (the function signature must match the other predicates)\n    :type page: ~cms.models.pages.page.Page\n\n    :return: Whether or not ``user`` can publish all pages\n    :rtype: bool\n    \"\"\"\n    return user.has_perm('cms.publish_pages')\n\n\n# Permissions\n\nadd_perm('cms.edit_page', can_edit_all_pages | is_page_editor | can_publish_all_pages | is_page_publisher)\nadd_perm('cms.publish_page', can_publish_all_pages | is_page_publisher)\n", "path": "src/cms/rules.py"}]}