prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Use predicates to prevent access to items if no phase has started yet
  With topicprio and polls items are created before any phase has been started.
  On the project_detail page a according message and no content is shown.
  This is checked via the `PhaseDispatchMixin`.
  As for items it is not possible to use the `PhaseDispatchMixin` a new
  predicate has been introduced which tests if a phase has been started
  yet. Be aware, that this does not imply an active phase.
  If no phase has been started yet access to the items should be prevented. 
  But if participation did finish the items should still be available.
  See 362a8ce6a79888b2cc1dbdeb789107a156c5d15f for reference. 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/polls/rules.py`
  Content:
  ```
  1 import rules
  2 from rules.predicates import is_superuser
  3 
  4 from adhocracy4.modules import predicates as module_predicates
  5 
  6 from . import models
  7 
  8 rules.add_perm(
  9     'meinberlin_polls.change_poll',
  10     is_superuser | module_predicates.is_context_initiator
  11 )
  12 
  13 rules.add_perm(
  14     'meinberlin_polls.view_poll',
  15     module_predicates.is_public_context
  16 )
  17 
  18 rules.add_perm(
  19     'meinberlin_polls.comment_poll',
  20     module_predicates.is_allowed_comment_item
  21 )
  22 
  23 rules.add_perm(
  24     'meinberlin_polls.add_vote',
  25     module_predicates.is_allowed_add_item(models.Vote)
  26 )
  27 
  28 rules.add_perm(
  29     'meinberlin_polls.change_vote',
  30     module_predicates.is_allowed_add_item(models.Vote)
  31 )
  32
  ```
  
  Path: `apps/topicprio/rules.py`
  Content:
  ```
  1 import rules
  2 
  3 from adhocracy4.modules import predicates as module_predicates
  4 
  5 rules.add_perm(
  6     'meinberlin_topicprio.add_topic',
  7     module_predicates.is_project_admin
  8 )
  9 
  10 rules.add_perm(
  11     'meinberlin_topicprio.change_topic',
  12     module_predicates.is_project_admin
  13 )
  14 
  15 rules.add_perm(
  16     'meinberlin_topicprio.rate_topic',
  17     module_predicates.is_allowed_rate_item
  18 )
  19 
  20 rules.add_perm(
  21     'meinberlin_topicprio.comment_topic',
  22     module_predicates.is_allowed_comment_item
  23 )
  24
  ```
  --- 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/apps/polls/rules.py b/apps/polls/rules.py
  --- a/apps/polls/rules.py
  +++ b/apps/polls/rules.py
  @@ -2,6 +2,7 @@
   from rules.predicates import is_superuser
   
   from adhocracy4.modules import predicates as module_predicates
  +from apps.contrib import predicates as contrib_predicates
   
   from . import models
   
  @@ -12,7 +13,9 @@
   
   rules.add_perm(
       'meinberlin_polls.view_poll',
  -    module_predicates.is_public_context
  +    (module_predicates.is_project_admin |
  +     (module_predicates.is_allowed_view_item &
  +      contrib_predicates.has_context_started))
   )
   
   rules.add_perm(
  diff --git a/apps/topicprio/rules.py b/apps/topicprio/rules.py
  --- a/apps/topicprio/rules.py
  +++ b/apps/topicprio/rules.py
  @@ -1,6 +1,7 @@
   import rules
   
   from adhocracy4.modules import predicates as module_predicates
  +from apps.contrib import predicates as contrib_predicates
   
   rules.add_perm(
       'meinberlin_topicprio.add_topic',
  @@ -12,6 +13,13 @@
       module_predicates.is_project_admin
   )
   
  +rules.add_perm(
  +    'meinberlin_topicprio.view_topic',
  +    (module_predicates.is_project_admin |
  +     (module_predicates.is_allowed_view_item &
  +      contrib_predicates.has_context_started))
  +)
  +
   rules.add_perm(
       'meinberlin_topicprio.rate_topic',
       module_predicates.is_allowed_rate_item
  
verification_info: {"golden_diff": "diff --git a/apps/polls/rules.py b/apps/polls/rules.py\n--- a/apps/polls/rules.py\n+++ b/apps/polls/rules.py\n@@ -2,6 +2,7 @@\n from rules.predicates import is_superuser\n \n from adhocracy4.modules import predicates as module_predicates\n+from apps.contrib import predicates as contrib_predicates\n \n from . import models\n \n@@ -12,7 +13,9 @@\n \n rules.add_perm(\n     'meinberlin_polls.view_poll',\n-    module_predicates.is_public_context\n+    (module_predicates.is_project_admin |\n+     (module_predicates.is_allowed_view_item &\n+      contrib_predicates.has_context_started))\n )\n \n rules.add_perm(\ndiff --git a/apps/topicprio/rules.py b/apps/topicprio/rules.py\n--- a/apps/topicprio/rules.py\n+++ b/apps/topicprio/rules.py\n@@ -1,6 +1,7 @@\n import rules\n \n from adhocracy4.modules import predicates as module_predicates\n+from apps.contrib import predicates as contrib_predicates\n \n rules.add_perm(\n     'meinberlin_topicprio.add_topic',\n@@ -12,6 +13,13 @@\n     module_predicates.is_project_admin\n )\n \n+rules.add_perm(\n+    'meinberlin_topicprio.view_topic',\n+    (module_predicates.is_project_admin |\n+     (module_predicates.is_allowed_view_item &\n+      contrib_predicates.has_context_started))\n+)\n+\n rules.add_perm(\n     'meinberlin_topicprio.rate_topic',\n     module_predicates.is_allowed_rate_item\n", "issue": "Use predicates to prevent access to items if no phase has started yet\nWith topicprio and polls items are created before any phase has been started.\r\nOn the project_detail page a according message and no content is shown.\r\nThis is checked via the `PhaseDispatchMixin`.\r\nAs for items it is not possible to use the `PhaseDispatchMixin` a new\r\npredicate has been introduced which tests if a phase has been started\r\nyet. Be aware, that this does not imply an active phase.\r\nIf no phase has been started yet access to the items should be prevented. \r\nBut if participation did finish the items should still be available.\r\nSee 362a8ce6a79888b2cc1dbdeb789107a156c5d15f for reference. \n", "before_files": [{"content": "import rules\nfrom rules.predicates import is_superuser\n\nfrom adhocracy4.modules import predicates as module_predicates\n\nfrom . import models\n\nrules.add_perm(\n    'meinberlin_polls.change_poll',\n    is_superuser | module_predicates.is_context_initiator\n)\n\nrules.add_perm(\n    'meinberlin_polls.view_poll',\n    module_predicates.is_public_context\n)\n\nrules.add_perm(\n    'meinberlin_polls.comment_poll',\n    module_predicates.is_allowed_comment_item\n)\n\nrules.add_perm(\n    'meinberlin_polls.add_vote',\n    module_predicates.is_allowed_add_item(models.Vote)\n)\n\nrules.add_perm(\n    'meinberlin_polls.change_vote',\n    module_predicates.is_allowed_add_item(models.Vote)\n)\n", "path": "apps/polls/rules.py"}, {"content": "import rules\n\nfrom adhocracy4.modules import predicates as module_predicates\n\nrules.add_perm(\n    'meinberlin_topicprio.add_topic',\n    module_predicates.is_project_admin\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.change_topic',\n    module_predicates.is_project_admin\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.rate_topic',\n    module_predicates.is_allowed_rate_item\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.comment_topic',\n    module_predicates.is_allowed_comment_item\n)\n", "path": "apps/topicprio/rules.py"}], "after_files": [{"content": "import rules\nfrom rules.predicates import is_superuser\n\nfrom adhocracy4.modules import predicates as module_predicates\nfrom apps.contrib import predicates as contrib_predicates\n\nfrom . import models\n\nrules.add_perm(\n    'meinberlin_polls.change_poll',\n    is_superuser | module_predicates.is_context_initiator\n)\n\nrules.add_perm(\n    'meinberlin_polls.view_poll',\n    (module_predicates.is_project_admin |\n     (module_predicates.is_allowed_view_item &\n      contrib_predicates.has_context_started))\n)\n\nrules.add_perm(\n    'meinberlin_polls.comment_poll',\n    module_predicates.is_allowed_comment_item\n)\n\nrules.add_perm(\n    'meinberlin_polls.add_vote',\n    module_predicates.is_allowed_add_item(models.Vote)\n)\n\nrules.add_perm(\n    'meinberlin_polls.change_vote',\n    module_predicates.is_allowed_add_item(models.Vote)\n)\n", "path": "apps/polls/rules.py"}, {"content": "import rules\n\nfrom adhocracy4.modules import predicates as module_predicates\nfrom apps.contrib import predicates as contrib_predicates\n\nrules.add_perm(\n    'meinberlin_topicprio.add_topic',\n    module_predicates.is_project_admin\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.change_topic',\n    module_predicates.is_project_admin\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.view_topic',\n    (module_predicates.is_project_admin |\n     (module_predicates.is_allowed_view_item &\n      contrib_predicates.has_context_started))\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.rate_topic',\n    module_predicates.is_allowed_rate_item\n)\n\nrules.add_perm(\n    'meinberlin_topicprio.comment_topic',\n    module_predicates.is_allowed_comment_item\n)\n", "path": "apps/topicprio/rules.py"}]}