We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Improve documentation of view decorators
Explain what our view decorators are doing and 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 view decorators
Explain what our view decorators are doing and 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/decorators.py`
Content:
```
1 import time
2 from functools import wraps
3 
4 from django.core.exceptions import PermissionDenied
5 from django.shortcuts import redirect
6 
7 from .models import Region
8 
9 
10 def staff_required(function):
11     @wraps(function)
12     def wrap(request, *args, **kwargs):
13         user = request.user
14         # superusers and staff have access to this areas
15         if user.is_superuser or user.is_staff:
16             return function(request, *args, **kwargs)
17         raise PermissionDenied
18     return wrap
19 
20 
21 def region_permission_required(function):
22     @wraps(function)
23     def wrap(request, *args, **kwargs):
24         user = request.user
25         # superusers and staff have permissions for all regions
26         if user.is_superuser or user.is_staff:
27             return function(request, *args, **kwargs)
28         region = Region.get_current_region(request)
29         if region in user.profile.regions.all():
30             return function(request, *args, **kwargs)
31         raise PermissionDenied
32     return wrap
33 
34 def modify_mfa_authenticated(function):
35     @wraps(function)
36     def wrap(request, *args, **kwargs):
37         if not 'modify_mfa_authentication_time' in request.session or request.session['modify_mfa_authentication_time'] < (time.time() - 5 * 60):
38             request.session['mfa_redirect_url'] = request.path
39             return redirect('user_settings_auth_modify_mfa')
40         return function(request, *args, **kwargs)
41     return wrap
42
```
--- 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()

```

diff --git a/src/cms/decorators.py b/src/cms/decorators.py
--- a/src/cms/decorators.py
+++ b/src/cms/decorators.py
@@ -1,3 +1,8 @@
+"""
+Django view decorators can be used to restrict the execution of a view function on certain conditions.
+
+For more information, see :doc:`topics/http/decorators`.
+"""
 import time
 from functools import wraps
 
@@ -8,6 +13,15 @@
 
 
 def staff_required(function):
+    """
+    This decorator can be used to make sure a view can only be retrieved by users who are either staff or superusers.
+
+    :param function: The view function which should be protected
+    :type function: ~collections.abc.Callable
+
+    :return: The decorated function
+    :rtype: ~collections.abc.Callable
+    """
     @wraps(function)
     def wrap(request, *args, **kwargs):
         user = request.user
@@ -19,6 +33,15 @@
 
 
 def region_permission_required(function):
+    """
+    This decorator can be used to make sure a view can only be retrieved by users of the requested region.
+
+    :param function: The view function which should be protected
+    :type function: ~collections.abc.Callable
+
+    :return: The decorated function
+    :rtype: ~collections.abc.Callable
+    """
     @wraps(function)
     def wrap(request, *args, **kwargs):
         user = request.user
@@ -32,6 +55,15 @@
     return wrap
 
 def modify_mfa_authenticated(function):
+    """
+    This decorator can be used to make sure a user can only modify his 2FA settings when he has a valid 2FA session.
+
+    :param function: The view function which should be protected
+    :type function: ~collections.abc.Callable
+
+    :return: The decorated function
+    :rtype: ~collections.abc.Callable
+    """
     @wraps(function)
     def wrap(request, *args, **kwargs):
         if not 'modify_mfa_authentication_time' in request.session or request.session['modify_mfa_authentication_time'] < (time.time() - 5 * 60):

{"golden_diff": "diff --git a/src/cms/decorators.py b/src/cms/decorators.py\n--- a/src/cms/decorators.py\n+++ b/src/cms/decorators.py\n@@ -1,3 +1,8 @@\n+\"\"\"\n+Django view decorators can be used to restrict the execution of a view function on certain conditions.\n+\n+For more information, see :doc:`topics/http/decorators`.\n+\"\"\"\n import time\n from functools import wraps\n \n@@ -8,6 +13,15 @@\n \n \n def staff_required(function):\n+    \"\"\"\n+    This decorator can be used to make sure a view can only be retrieved by users who are either staff or superusers.\n+\n+    :param function: The view function which should be protected\n+    :type function: ~collections.abc.Callable\n+\n+    :return: The decorated function\n+    :rtype: ~collections.abc.Callable\n+    \"\"\"\n     @wraps(function)\n     def wrap(request, *args, **kwargs):\n         user = request.user\n@@ -19,6 +33,15 @@\n \n \n def region_permission_required(function):\n+    \"\"\"\n+    This decorator can be used to make sure a view can only be retrieved by users of the requested region.\n+\n+    :param function: The view function which should be protected\n+    :type function: ~collections.abc.Callable\n+\n+    :return: The decorated function\n+    :rtype: ~collections.abc.Callable\n+    \"\"\"\n     @wraps(function)\n     def wrap(request, *args, **kwargs):\n         user = request.user\n@@ -32,6 +55,15 @@\n     return wrap\n \n def modify_mfa_authenticated(function):\n+    \"\"\"\n+    This decorator can be used to make sure a user can only modify his 2FA settings when he has a valid 2FA session.\n+\n+    :param function: The view function which should be protected\n+    :type function: ~collections.abc.Callable\n+\n+    :return: The decorated function\n+    :rtype: ~collections.abc.Callable\n+    \"\"\"\n     @wraps(function)\n     def wrap(request, *args, **kwargs):\n         if not 'modify_mfa_authentication_time' in request.session or request.session['modify_mfa_authentication_time'] < (time.time() - 5 * 60):\n", "issue": "Improve documentation of view decorators\nExplain what our view decorators are doing and 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 view decorators\nExplain what our view decorators are doing and 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": "import time\nfrom functools import wraps\n\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import redirect\n\nfrom .models import Region\n\n\ndef staff_required(function):\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        user = request.user\n        # superusers and staff have access to this areas\n        if user.is_superuser or user.is_staff:\n            return function(request, *args, **kwargs)\n        raise PermissionDenied\n    return wrap\n\n\ndef region_permission_required(function):\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        user = request.user\n        # superusers and staff have permissions for all regions\n        if user.is_superuser or user.is_staff:\n            return function(request, *args, **kwargs)\n        region = Region.get_current_region(request)\n        if region in user.profile.regions.all():\n            return function(request, *args, **kwargs)\n        raise PermissionDenied\n    return wrap\n\ndef modify_mfa_authenticated(function):\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        if not 'modify_mfa_authentication_time' in request.session or request.session['modify_mfa_authentication_time'] < (time.time() - 5 * 60):\n            request.session['mfa_redirect_url'] = request.path\n            return redirect('user_settings_auth_modify_mfa')\n        return function(request, *args, **kwargs)\n    return wrap\n", "path": "src/cms/decorators.py"}], "after_files": [{"content": "\"\"\"\nDjango view decorators can be used to restrict the execution of a view function on certain conditions.\n\nFor more information, see :doc:`topics/http/decorators`.\n\"\"\"\nimport time\nfrom functools import wraps\n\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import redirect\n\nfrom .models import Region\n\n\ndef staff_required(function):\n    \"\"\"\n    This decorator can be used to make sure a view can only be retrieved by users who are either staff or superusers.\n\n    :param function: The view function which should be protected\n    :type function: ~collections.abc.Callable\n\n    :return: The decorated function\n    :rtype: ~collections.abc.Callable\n    \"\"\"\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        user = request.user\n        # superusers and staff have access to this areas\n        if user.is_superuser or user.is_staff:\n            return function(request, *args, **kwargs)\n        raise PermissionDenied\n    return wrap\n\n\ndef region_permission_required(function):\n    \"\"\"\n    This decorator can be used to make sure a view can only be retrieved by users of the requested region.\n\n    :param function: The view function which should be protected\n    :type function: ~collections.abc.Callable\n\n    :return: The decorated function\n    :rtype: ~collections.abc.Callable\n    \"\"\"\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        user = request.user\n        # superusers and staff have permissions for all regions\n        if user.is_superuser or user.is_staff:\n            return function(request, *args, **kwargs)\n        region = Region.get_current_region(request)\n        if region in user.profile.regions.all():\n            return function(request, *args, **kwargs)\n        raise PermissionDenied\n    return wrap\n\ndef modify_mfa_authenticated(function):\n    \"\"\"\n    This decorator can be used to make sure a user can only modify his 2FA settings when he has a valid 2FA session.\n\n    :param function: The view function which should be protected\n    :type function: ~collections.abc.Callable\n\n    :return: The decorated function\n    :rtype: ~collections.abc.Callable\n    \"\"\"\n    @wraps(function)\n    def wrap(request, *args, **kwargs):\n        if not 'modify_mfa_authentication_time' in request.session or request.session['modify_mfa_authentication_time'] < (time.time() - 5 * 60):\n            request.session['mfa_redirect_url'] = request.path\n            return redirect('user_settings_auth_modify_mfa')\n        return function(request, *args, **kwargs)\n    return wrap\n", "path": "src/cms/decorators.py"}]}