Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Onboarding
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
3lisvequii
Onboarding
Commits
d6e8fe77
Commit
d6e8fe77
authored
2 years ago
by
Tom Teichler
Browse files
Options
Downloads
Patches
Plain Diff
Fix permissionk
parent
143b60b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/tezor/predicates.py
+0
-1
0 additions, 1 deletion
aleksis/apps/tezor/predicates.py
aleksis/apps/tezor/rules.py
+3
-0
3 additions, 0 deletions
aleksis/apps/tezor/rules.py
aleksis/apps/tezor/views.py
+10
-2
10 additions, 2 deletions
aleksis/apps/tezor/views.py
with
13 additions
and
3 deletions
aleksis/apps/tezor/predicates.py
+
0
−
1
View file @
d6e8fe77
...
...
@@ -10,7 +10,6 @@ User = get_user_model()
@predicate
def
is_own_invoice
(
user
:
User
,
obj
:
Invoice
):
"""
Predicate which checks if the invoice is linked to the current user.
"""
return
obj
.
get_person
()
==
user
.
person
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/tezor/rules.py
+
3
−
0
View file @
d6e8fe77
...
...
@@ -150,3 +150,6 @@ send_invoice_email_predicate = (
|
has_object_perm
(
"
tezor.send_invoice_email
"
)
)
rules
.
add_perm
(
"
tezor.send_invoice_email_rule
"
,
send_invoice_email_predicate
)
view_own_invoices_predicate
=
has_person
rules
.
add_perm
(
"
tezor.view_own_invoices_list_rule
"
,
view_own_invoices_predicate
)
This diff is collapsed.
Click to expand it.
aleksis/apps/tezor/views.py
+
10
−
2
View file @
d6e8fe77
...
...
@@ -34,6 +34,13 @@ class GetInvoicePDF(PermissionRequiredMixin, RenderPDFView):
return
context
def
has_permission
(
self
):
invoice
=
Invoice
.
objects
.
get
(
token
=
self
.
kwargs
[
"
token
"
])
perms
=
self
.
get_permission_required
()
return
self
.
request
.
user
.
has_perms
(
perms
,
invoice
)
class
DoPaymentView
(
PermissionRequiredMixin
,
View
):
...
...
@@ -238,15 +245,16 @@ class SendInvoiceEmail(PermissionRequiredMixin, View):
return
redirect
(
url
)
class
MyInvoicesListView
(
PermissionRequiredMixin
,
SingleTableView
):
"""
Table of all invoices belonging to a user.
"""
model
=
Invoice
table_class
=
InvoicesTable
permission_required
=
"
tezor.
display_billing
_rule
"
permission_required
=
"
tezor.
view_own_invoices_list
_rule
"
template_name
=
"
tezor/invoice/list.html
"
def
get_queryset
(
self
,
*
args
,
**
kwargs
):
invoices
=
self
.
model
.
objects
.
filter
(
billing_email
=
self
.
request
.
user
.
person
.
email
)
invoices
=
self
.
model
.
objects
.
filter
(
person
=
self
.
request
.
user
.
person
)
return
invoices
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment