Example #1
0
import rules

from adhocracy4.modules import predicates as module_predicates

from . import models

rules.add_perm(
    'a4_candy_budgeting.view_proposal',
    module_predicates.is_allowed_view_item
)


rules.add_perm(
    'a4_candy_budgeting.add_proposal',
    module_predicates.is_allowed_add_item(models.Proposal)
)

rules.add_perm(
    'a4_candy_budgeting.rate_proposal',
    module_predicates.is_allowed_rate_item
)


rules.add_perm(
    'a4_candy_budgeting.comment_proposal',
    module_predicates.is_allowed_comment_item
)


rules.add_perm(
    'a4_candy_budgeting.change_proposal',
Example #2
0
import rules

from adhocracy4.modules import predicates as module_predicates

from . import models

rules.add_perm('{{cookiecutter.project_app_prefix}}_mapideas.view_mapidea',
               module_predicates.is_allowed_view_item)

rules.add_perm('{{cookiecutter.project_app_prefix}}_mapideas.add_mapidea',
               module_predicates.is_allowed_add_item(models.MapIdea))

rules.add_perm('{{cookiecutter.project_app_prefix}}_mapideas.change_mapidea',
               module_predicates.is_allowed_change_item)

rules.add_perm('{{cookiecutter.project_app_prefix}}_mapideas.rate_mapidea',
               module_predicates.is_allowed_rate_item)

rules.add_perm('{{cookiecutter.project_app_prefix}}_mapideas.comment_mapidea',
               module_predicates.is_allowed_comment_item)

rules.add_perm(
    '{{cookiecutter.project_app_prefix}}_mapideas.moderate_mapidea',
    module_predicates.is_context_moderator
    | module_predicates.is_context_initiator)

rules.add_perm(
    '{{cookiecutter.project_app_prefix}}_mapideas.export_mapideas',
    module_predicates.is_context_moderator
    | module_predicates.is_context_initiator)
Example #3
0
)

rules.add_perm(
    'civic_europe_ideas.follow_idea',
    is_authenticated
)

rules.add_perm(
    'civic_europe_ideas.export_idea',
    is_staff |
    is_superuser
)

rules.add_perm(
    'civic_europe_ideas.add_idea',
    mod_predicates.is_allowed_add_item(models.Idea)
)

rules.add_perm(
    'civic_europe_ideas.change_idea',
    mod_predicates.is_project_admin |
    mod_predicates.is_context_member &
    (
        mod_predicates.is_owner |
        predicates.is_co_worker
    ) &
    phase_predicates.phase_allows_change
)


rules.add_perm(
Example #4
0
from adhocracy4.modules import predicates as module_predicates
from apps.contrib import predicates as contrib_predicates

from . import models

rules.add_perm(
    'a4_candy_polls.change_poll',
    module_predicates.is_context_initiator |
    module_predicates.is_context_moderator
)

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

rules.add_perm(
    'a4_candy_polls.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(
    'a4_candy_polls.add_vote',
    module_predicates.is_allowed_add_item(models.Vote)
)