How to use the rules.add_perm function in rules

To help you get started, we’ve selected a few rules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pretalx / pretalx / src / pretalx / orga / permissions.py View on Github external
rules.add_perm("orga.view_tracks", can_change_submissions)
rules.add_perm("orga.view_track", can_change_submissions)
rules.add_perm("orga.edit_track", can_change_event_settings)
rules.add_perm("orga.remove_track", can_change_event_settings)
rules.add_perm("orga.view_access_codes", can_change_submissions)
rules.add_perm("orga.view_access_code", can_change_submissions)
rules.add_perm("orga.edit_access_code", can_change_event_settings)
rules.add_perm("orga.remove_access_code", can_change_event_settings)
rules.add_perm("orga.view_mails", can_change_submissions)
rules.add_perm("orga.send_mails", can_change_submissions)
rules.add_perm("orga.edit_mails", can_change_submissions & can_edit_mail)
rules.add_perm("orga.purge_mails", can_change_submissions)
rules.add_perm("orga.view_mail_templates", can_change_submissions)
rules.add_perm("orga.edit_mail_templates", can_change_submissions)
rules.add_perm("orga.view_review_dashboard", can_change_submissions | is_reviewer)
rules.add_perm(
    "orga.view_reviews", can_change_submissions | (is_reviewer & can_view_reviews)
)
rules.add_perm(
    "orga.view_all_reviews",
    can_change_submissions | (is_reviewer & can_view_all_reviews),
)
rules.add_perm("orga.perform_reviews", is_reviewer & reviews_are_open)
rules.add_perm(
    "orga.remove_review", is_administrator | (is_review_author & can_be_reviewed)
)
rules.add_perm("orga.view_schedule", can_change_submissions)
rules.add_perm("orga.release_schedule", can_change_submissions)
rules.add_perm("orga.edit_schedule", can_change_submissions)
rules.add_perm("orga.schedule_talk", can_change_submissions)
rules.add_perm("orga.view_room", can_change_submissions)
rules.add_perm("orga.edit_room", can_change_submissions)
github pretalx / pretalx / src / pretalx / orga / permissions.py View on Github external
def can_view_speaker_names(user, obj):
    event = obj.event
    return event.active_review_phase and event.active_review_phase.can_see_speaker_names


rules.add_perm("orga.view_orga_area", can_change_submissions | is_reviewer)
rules.add_perm("orga.change_settings", can_change_event_settings)
rules.add_perm("orga.change_organiser_settings", can_change_organiser_settings)
rules.add_perm("orga.view_organisers", can_change_any_organiser_settings)
rules.add_perm("orga.change_teams", is_administrator | can_change_teams)
rules.add_perm("orga.view_submission_cards", can_change_submissions)
rules.add_perm("orga.edit_cfp", can_change_event_settings)
rules.add_perm("orga.view_question", can_change_submissions)
rules.add_perm("orga.edit_question", can_change_event_settings)
rules.add_perm("orga.remove_question", can_change_event_settings)
rules.add_perm("orga.view_submission_type", can_change_submissions)
rules.add_perm("orga.edit_submission_type", can_change_event_settings)
rules.add_perm("orga.remove_submission_type", can_change_event_settings)
rules.add_perm("orga.view_tracks", can_change_submissions)
rules.add_perm("orga.view_track", can_change_submissions)
rules.add_perm("orga.edit_track", can_change_event_settings)
rules.add_perm("orga.remove_track", can_change_event_settings)
rules.add_perm("orga.view_access_codes", can_change_submissions)
rules.add_perm("orga.view_access_code", can_change_submissions)
rules.add_perm("orga.edit_access_code", can_change_event_settings)
rules.add_perm("orga.remove_access_code", can_change_event_settings)
rules.add_perm("orga.view_mails", can_change_submissions)
rules.add_perm("orga.send_mails", can_change_submissions)
rules.add_perm("orga.edit_mails", can_change_submissions & can_edit_mail)
rules.add_perm("orga.purge_mails", can_change_submissions)
rules.add_perm("orga.view_mail_templates", can_change_submissions)
rules.add_perm("orga.edit_mail_templates", can_change_submissions)
github pretalx / pretalx / src / pretalx / submission / permissions.py View on Github external
return result.exists()


@rules.predicate
def reviewer_can_change_submissions(user, obj):
    return (
        obj.event.active_review_phase
        and obj.event.active_review_phase.can_change_submission_state
    )


rules.add_perm(
    "submission.accept_or_reject_submissions",
    can_change_submissions | (is_reviewer & reviewer_can_change_submissions),
)
rules.add_perm("submission.perform_actions", is_speaker)
rules.add_perm("submission.withdraw_submission", can_be_withdrawn & is_speaker)
rules.add_perm(
    "submission.reject_submission",
    can_be_rejected
    & (can_change_submissions | (is_reviewer & reviewer_can_change_submissions)),
)
rules.add_perm(
    "submission.accept_submission",
    can_be_accepted
    & (can_change_submissions | (is_reviewer & reviewer_can_change_submissions)),
)
rules.add_perm(
    "submission.confirm_submission",
    can_be_confirmed & (is_speaker | can_change_submissions),
)
rules.add_perm(
github pretalx / pretalx / src / pretalx / orga / permissions.py View on Github external
rules.add_perm("orga.edit_question", can_change_event_settings)
rules.add_perm("orga.remove_question", can_change_event_settings)
rules.add_perm("orga.view_submission_type", can_change_submissions)
rules.add_perm("orga.edit_submission_type", can_change_event_settings)
rules.add_perm("orga.remove_submission_type", can_change_event_settings)
rules.add_perm("orga.view_tracks", can_change_submissions)
rules.add_perm("orga.view_track", can_change_submissions)
rules.add_perm("orga.edit_track", can_change_event_settings)
rules.add_perm("orga.remove_track", can_change_event_settings)
rules.add_perm("orga.view_access_codes", can_change_submissions)
rules.add_perm("orga.view_access_code", can_change_submissions)
rules.add_perm("orga.edit_access_code", can_change_event_settings)
rules.add_perm("orga.remove_access_code", can_change_event_settings)
rules.add_perm("orga.view_mails", can_change_submissions)
rules.add_perm("orga.send_mails", can_change_submissions)
rules.add_perm("orga.edit_mails", can_change_submissions & can_edit_mail)
rules.add_perm("orga.purge_mails", can_change_submissions)
rules.add_perm("orga.view_mail_templates", can_change_submissions)
rules.add_perm("orga.edit_mail_templates", can_change_submissions)
rules.add_perm("orga.view_review_dashboard", can_change_submissions | is_reviewer)
rules.add_perm(
    "orga.view_reviews", can_change_submissions | (is_reviewer & can_view_reviews)
)
rules.add_perm(
    "orga.view_all_reviews",
    can_change_submissions | (is_reviewer & can_view_all_reviews),
)
rules.add_perm("orga.perform_reviews", is_reviewer & reviews_are_open)
rules.add_perm(
    "orga.remove_review", is_administrator | (is_review_author & can_be_reviewed)
)
rules.add_perm("orga.view_schedule", can_change_submissions)