Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
12152e7d
Commit
12152e7d
authored
7 years ago
by
Jaden Diefenbaugh
Browse files
Options
Downloads
Patches
Plain Diff
clarify permissions scheme for viewing reports & tighten up perms
parent
4359d2d3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!223
Reports overhaul
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/reports/views.py
+22
-2
22 additions, 2 deletions
beat/web/reports/views.py
with
22 additions
and
2 deletions
beat/web/reports/views.py
+
22
−
2
View file @
12152e7d
...
...
@@ -33,6 +33,7 @@ from django.views.generic import TemplateView
from
django.contrib.auth.models
import
User
from
django.db.models
import
Q
from
django.db.models.functions
import
Coalesce
from
django.http
import
Http404
from
..ui.templatetags.markup
import
restructuredtext
...
...
@@ -44,11 +45,26 @@ import simplejson as json
#------------------------------------------------
# Permissions for viewing a report is complicated:
# 'E' means that the specific type of user may view the editable mode
# of the report when the report is in the specified state.
# 'V' is the same, but for the view-only mode
# REPORT STATE: | Editable | Locked | Published |
# USER: -------------------------------------
# Author | E, V | V | V |
# BEAT User | V | V | V |
# Anon | | V | V |
# Public Reports List | | | V |
def
by_number
(
request
,
number
):
# get the query from the DB
obj
=
get_object_or_404
(
Report
,
number
=
int
(
number
))
isAnon
=
request
.
user
.
is_anonymous
()
if
obj
.
status
==
'
E
'
and
isAnon
:
# return 404
raise
Http404
(
'
No %s matches the given query.
'
%
Report
.
_meta
.
object_name
)
return
render_to_response
(
'
reports/report.html
'
,
{
'
report_number
'
:
number
,
...
...
@@ -63,12 +79,16 @@ def by_number(request, number):
def
for_author
(
request
,
author_name
,
report_name
):
# get the query from the DB
obj
=
get_object_or_404
(
Report
,
author__username
=
author_name
,
name
=
report_name
)
isAuthor
=
request
.
user
.
username
==
obj
.
author
.
username
if
not
isAuthor
:
# return 404
raise
Http404
(
'
No %s matches the given query.
'
%
Report
.
_meta
.
object_name
)
return
render_to_response
(
'
reports/report.html
'
,
{
...
...
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