<commit_before>import rules
from rules.predicates import is_superuser

from adhocracy4.modules import predicates as module_predicates
from adhocracy4.projects.predicates import has_context_started

from . import models

rules.add_perm(
    'a4polls.change_poll',
    is_superuser | module_predicates.is_context_initiator
)

rules.add_perm(
    'a4polls.view_poll',
    (module_predicates.is_project_admin |
     (module_predicates.is_allowed_view_item &
      has_context_started))
)

rules.add_perm(
    'a4polls.comment_poll',
    module_predicates.is_allowed_comment_item
)


# It has to be ensured that the permission is always checked against a module
# never a Vote object.
rules.add_perm(
    'a4polls.add_vote',
    module_predicates.is_allowed_add_item(models.Vote)
)<commit_msg>apps/polls: also show poll before project start<commit_after>import rules
from rules.predicates import is_superuser

from adhocracy4.modules import predicates as module_predicates

from . import models

rules.add_perm(
    'a4polls.change_poll',
    is_superuser | module_predicates.is_context_initiator
)

rules.add_perm(
    'a4polls.view_poll',
    (module_predicates.is_project_admin |
     module_predicates.is_allowed_view_item)
)

rules.add_perm(
    'a4polls.comment_poll',
    module_predicates.is_allowed_comment_item
)


# It has to be ensured that the permission is always checked against a module
# never a Vote object.
rules.add_perm(
    'a4polls.add_vote',
    module_predicates.is_allowed_add_item(models.Vote)
)
{'fraction_non_alphanumeric': 0.06921555702043507, 'fraction_numerical': 0.007251153592617007, 'mean_word_length': 4.9296875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4088159', 'n_tokens_mistral': 522, 'n_tokens_neox': 507, 'n_words': 105}