prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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]
  """
  ```
  
  </issue>
  <code>
  [start of src/cms/rules.py]
  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 of src/cms/rules.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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"}]}