Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SMASCH
scheduling-system
Commits
f40191bc
Commit
f40191bc
authored
4 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added provenance to export view
parent
6bffc65f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!266
Resolve "Record who exports information and restrict who can export info."
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/views/export.py
+25
-2
25 additions, 2 deletions
smash/web/views/export.py
with
25 additions
and
2 deletions
smash/web/views/export.py
+
25
−
2
View file @
f40191bc
...
...
@@ -7,7 +7,7 @@ from django.http import HttpResponse
from
.notifications
import
get_today_midnight_date
from
web.decorators
import
PermissionDecorator
from
.
import
e500_error
,
wrap_response
from
..models
import
Subject
,
StudySubject
,
Appointment
,
ConfigurationItem
from
..models
import
Subject
,
StudySubject
,
Appointment
,
ConfigurationItem
,
Worker
,
Provenance
,
Visit
from
web.models.constants
import
VISIT_SHOW_VISIT_NUMBER_FROM_ZERO
from
distutils.util
import
strtobool
from
web.templatetags.filters
import
display_visit_number
...
...
@@ -32,6 +32,14 @@ def export_to_csv(request, data_type="subjects"):
for
row
in
data
:
writer
.
writerow
([
s
.
encode
(
"
utf-8
"
)
for
s
in
row
])
worker
=
Worker
.
get_by_user
(
request
.
user
)
p
=
Provenance
(
modification_author
=
worker
,
modification_description
=
f
'
Export
{
data_type
}
to csv
'
,
modified_field
=
''
,
request_path
=
request
.
path
)
p
.
save
()
return
response
...
...
@@ -49,6 +57,14 @@ def export_to_excel(request, data_type="subjects"):
response
=
excel
.
make_response_from_array
(
data
,
'
xls
'
,
file_name
=
filename
)
response
[
'
Content-Disposition
'
]
=
'
attachment; filename=
"'
+
filename
+
'"'
worker
=
Worker
.
get_by_user
(
request
.
user
)
p
=
Provenance
(
modification_author
=
worker
,
modification_description
=
f
'
Export
{
data_type
}
to excel
'
,
modified_field
=
''
,
request_path
=
request
.
path
)
p
.
save
()
return
response
...
...
@@ -208,7 +224,14 @@ def get_appointments_as_array(selected_fields=None):
@PermissionDecorator
(
'
export_subjects
'
,
'
subject
'
)
def
export
(
request
):
provenances
=
Provenance
.
objects
.
filter
(
modified_table__isnull
=
True
,
previous_value__isnull
=
True
,
new_value__isnull
=
True
,
modified_field
=
''
,
request_path__startswith
=
'
/export/
'
).
order_by
(
'
-modification_date
'
)
return
wrap_response
(
request
,
'
export/index.html
'
,
{
'
subject_fields
'
:
get_default_subject_fields
(),
'
appointment_fields
'
:
get_appointment_fields
()[
0
]
'
appointment_fields
'
:
get_appointment_fields
()[
0
],
'
provenances
'
:
provenances
})
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