Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Tezor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Onboarding
AlekSIS-App-Tezor
Merge requests
!6
Add rules
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add rules
rules
into
master
Overview
4
Commits
4
Pipelines
6
Changes
2
Merged
Tom Teichler
requested to merge
rules
into
master
3 years ago
Overview
4
Commits
4
Pipelines
6
Changes
2
Expand
0
0
Merge request reports
Compare
master
version 5
4d30e080
3 years ago
version 4
92b04d83
3 years ago
version 3
d5456bfc
3 years ago
version 2
1085f5f9
3 years ago
version 1
f98412c7
3 years ago
master (base)
and
version 5
latest version
a1f7091c
4 commits,
3 years ago
version 5
4d30e080
3 commits,
3 years ago
version 4
92b04d83
2 commits,
3 years ago
version 3
d5456bfc
2 commits,
3 years ago
version 2
1085f5f9
1 commit,
3 years ago
version 1
f98412c7
1 commit,
3 years ago
2 files
+
82
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
aleksis/apps/tezor/rules.py
0 → 100644
+
72
−
0
Options
import
rules
from
.models.base
import
Client
from
.models.invoice
import
Invoice
,
InvoiceGroup
from
aleksis.core.util.predicates
import
has_person
,
has_global_perm
,
has_any_object
# View clients
view_clients_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.view_client
"
)
|
has_any_object
(
"
tezor.view_client
"
,
Client
)
)
rules
.
add_perm
(
"
tezor.view_clients_rule
"
,
view_clients_predicate
)
# View client
view_client_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.view_client
"
)
|
has_object_perm
(
"
tezor.view_client
"
)
)
rules
.
add_perm
(
"
tezor.view_client_rule
"
,
view_client_predicate
)
# Edit clients
edit_client_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.edit_client
"
)
|
has_object_perm
(
"
tezor.edit_client
"
)
)
rules
.
add_perm
(
"
tezor.edit_client_rule
"
,
edit_clients_predicate
)
# Create clients
create_clients_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.create_client
"
)
|
has_any_object
(
"
tezor.create_client
"
,
Client
)
)
rules
.
add_perm
(
"
tezor.create_clients_rule
"
,
create_clients_predicate
)
# Delete clients
delete_client_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.delete_client
"
)
|
has_object_perm
(
"
tezor.delete_client
"
)
)
rules
.
add_perm
(
"
tezor.delete_client_rule
"
,
delete_client_predicate
)
# View invoice groups
view_invoice_groups_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.view_invoice_group
"
)
|
has_any_object
(
"
tezor.view_invoice_group
"
,
InvoiceGroup
)
)
rules
.
add_perm
(
"
tezor.view_invoice_groups_rule
"
,
view_invoice_groups_predicate
)
# View invoice_group
view_invoice_group_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.view_invoice_group
"
)
|
has_object_perm
(
"
tezor.view_invoice_group
"
)
)
rules
.
add_perm
(
"
tezor.view_invoice_group_rule
"
,
view_invoice_group_predicate
)
# Edit invoice groups
edit_invoice_group_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.edit_invoice_group
"
)
|
has_object_perm
(
"
tezor.edit_invoice_group
"
)
)
rules
.
add_perm
(
"
tezor.edit_invoice_group_rule
"
,
edit_invoice_group_predicate
)
# Create invoice groups
create_invoice_groups_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.create_invoice_group
"
)
|
has_any_object
(
"
tezor.create_invoice_group
"
,
InvoiceGroup
)
)
rules
.
add_perm
(
"
tezor.create_invoice_groups_rule
"
,
create_invoice_groups_predicate
)
# Delete invoice groups
delete_invoice_groups_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.delete_invoice_group
"
)
|
has_any_object
(
"
tezor.delete_invoice_group
"
,
InvoiceGroup
)
)
rules
.
add_perm
(
"
tezor.delete_invoice_groups_rule
"
,
delete_invoice_groups_predicate
)
# View invoice
view_invoice_predicate
=
has_person
&
(
has_global_perm
(
"
tezor.view_invoice
"
)
|
has_object_perm
(
"
tezor.view_invoice
"
)
)
rules
.
add_perm
(
"
tezor.view_invoice_rule
"
,
view_invoice_predicate
)
Loading