Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
84f1d7dc
Commit
84f1d7dc
authored
4 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add download function to imported result.
parent
ea7bb826
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
web/app/corpora/views.py
+0
-1
0 additions, 1 deletion
web/app/corpora/views.py
web/app/results/views.py
+20
-1
20 additions, 1 deletion
web/app/results/views.py
web/app/static/js/nopaque.lists.js
+8
-0
8 additions, 0 deletions
web/app/static/js/nopaque.lists.js
with
28 additions
and
2 deletions
web/app/corpora/views.py
+
0
−
1
View file @
84f1d7dc
...
@@ -9,7 +9,6 @@ from .forms import (AddCorpusFileForm, AddCorpusForm, EditCorpusFileForm,
...
@@ -9,7 +9,6 @@ from .forms import (AddCorpusFileForm, AddCorpusForm, EditCorpusFileForm,
from
..
import
db
from
..
import
db
from
..models
import
Corpus
,
CorpusFile
from
..models
import
Corpus
,
CorpusFile
import
os
import
os
from
..
import
logger
@corpora.route
(
'
/add
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@corpora.route
(
'
/add
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
...
...
This diff is collapsed.
Click to expand it.
web/app/results/views.py
+
20
−
1
View file @
84f1d7dc
...
@@ -6,7 +6,7 @@ from ..models import Result, ResultFile, User
...
@@ -6,7 +6,7 @@ from ..models import Result, ResultFile, User
from
.forms
import
ImportResultsForm
from
.forms
import
ImportResultsForm
from
datetime
import
datetime
from
datetime
import
datetime
from
flask
import
(
abort
,
render_template
,
current_app
,
request
,
redirect
,
from
flask
import
(
abort
,
render_template
,
current_app
,
request
,
redirect
,
flash
,
url_for
,
make_response
)
flash
,
url_for
,
make_response
,
send_from_directory
)
from
flask_login
import
current_user
,
login_required
from
flask_login
import
current_user
,
login_required
import
json
import
json
import
os
import
os
...
@@ -71,9 +71,11 @@ def results_overview():
...
@@ -71,9 +71,11 @@ def results_overview():
# get all results of current user
# get all results of current user
results
=
User
.
query
.
get
(
current_user
.
id
).
results
results
=
User
.
query
.
get
(
current_user
.
id
).
results
logger
.
warning
(
results
)
logger
.
warning
(
results
)
def
__p_time
(
time_str
):
def
__p_time
(
time_str
):
# helper to convert the datetime into a nice readable string
# helper to convert the datetime into a nice readable string
return
datetime
.
strptime
(
time_str
,
'
%Y-%m-%dT%H:%M:%S.%f
'
)
return
datetime
.
strptime
(
time_str
,
'
%Y-%m-%dT%H:%M:%S.%f
'
)
# convert results into a list of dicts to add the measier to list.js in
# convert results into a list of dicts to add the measier to list.js in
# the template
# the template
results
=
[
dict
(
query
=
r
.
corpus_metadata
[
'
query
'
],
results
=
[
dict
(
query
=
r
.
corpus_metadata
[
'
query
'
],
...
@@ -82,6 +84,7 @@ def results_overview():
...
@@ -82,6 +84,7 @@ def results_overview():
corpus_creation_date
=
__p_time
(
r
.
corpus_metadata
[
'
corpus_creation_date
'
]),
# noqa
corpus_creation_date
=
__p_time
(
r
.
corpus_metadata
[
'
corpus_creation_date
'
]),
# noqa
corpus_analysis_date
=
__p_time
(
r
.
corpus_metadata
[
'
corpus_analysis_date
'
]),
# noqa
corpus_analysis_date
=
__p_time
(
r
.
corpus_metadata
[
'
corpus_analysis_date
'
]),
# noqa
corpus_type
=
r
.
corpus_metadata
[
'
corpus_type
'
],
corpus_type
=
r
.
corpus_metadata
[
'
corpus_type
'
],
file_id
=
r
.
file
[
0
].
id
,
id
=
r
.
id
)
id
=
r
.
id
)
for
r
in
results
]
for
r
in
results
]
return
render_template
(
'
results/results.html.j2
'
,
return
render_template
(
'
results/results.html.j2
'
,
...
@@ -141,3 +144,19 @@ def result_delete(result_id):
...
@@ -141,3 +144,19 @@ def result_delete(result_id):
tasks
.
delete_result
(
result_id
)
tasks
.
delete_result
(
result_id
)
flash
(
'
Result deleted!
'
)
flash
(
'
Result deleted!
'
)
return
redirect
(
url_for
(
'
results.results_overview
'
))
return
redirect
(
url_for
(
'
results.results_overview
'
))
@results.route
(
'
/<int:result_id>/file/<int:result_file_id>/download
'
)
@login_required
def
result_download
(
result_id
,
result_file_id
):
result_file
=
ResultFile
.
query
.
get_or_404
(
result_file_id
)
if
not
result_file
.
result_id
==
result_id
:
abort
(
404
)
if
not
(
result_file
.
result
.
creator
==
current_user
or
current_user
.
is_administrator
()):
abort
(
403
)
dir
=
os
.
path
.
join
(
current_app
.
config
[
'
NOPAQUE_STORAGE
'
],
result_file
.
dir
)
return
send_from_directory
(
as_attachment
=
True
,
directory
=
dir
,
filename
=
result_file
.
filename
)
This diff is collapsed.
Click to expand it.
web/app/static/js/nopaque.lists.js
+
8
−
0
View file @
84f1d7dc
...
@@ -114,6 +114,7 @@ RessourceList.dataMapper = {
...
@@ -114,6 +114,7 @@ RessourceList.dataMapper = {
corpus_type
:
result
.
corpus_type
,
corpus_type
:
result
.
corpus_type
,
"
details-link
"
:
`
${
result
.
id
}
/details`
,
"
details-link
"
:
`
${
result
.
id
}
/details`
,
"
inspect-link
"
:
`
${
result
.
id
}
/inspect`
,
"
inspect-link
"
:
`
${
result
.
id
}
/inspect`
,
"
download-link
"
:
`
${
result
.
id
}
/file/
${
result
.
file_id
}
/download`
,
"
delete-modal
"
:
`delete-result-
${
result
.
id
}
-modal`
"
delete-modal
"
:
`delete-result-
${
result
.
id
}
-modal`
}),
}),
// Mapping for user entities shown in admin table
// Mapping for user entities shown in admin table
...
@@ -285,6 +286,12 @@ RessourceList.options = {
...
@@ -285,6 +286,12 @@ RessourceList.options = {
data-tooltip="View Results">
data-tooltip="View Results">
<i class="material-icons">search</i>
<i class="material-icons">search</i>
</a>
</a>
<a class="btn-floating tooltipped download-link
waves-effect waves-light"
data-position="top"
data-tooltip="Download">
<i class="material-icons">file_download</i>
</a>
<a class="btn-floating tooltipped red delete-modal
<a class="btn-floating tooltipped red delete-modal
waves-effect waves-light modal-trigger"
waves-effect waves-light modal-trigger"
data-position="top"
data-position="top"
...
@@ -303,6 +310,7 @@ RessourceList.options = {
...
@@ -303,6 +310,7 @@ RessourceList.options = {
"
corpus_type
"
,
"
corpus_type
"
,
{
name
:
"
details-link
"
,
attr
:
"
href
"
},
{
name
:
"
details-link
"
,
attr
:
"
href
"
},
{
name
:
"
inspect-link
"
,
attr
:
"
href
"
},
{
name
:
"
inspect-link
"
,
attr
:
"
href
"
},
{
name
:
"
download-link
"
,
attr
:
"
href
"
},
{
name
:
"
delete-modal
"
,
attr
:
"
data-target
"
}]
{
name
:
"
delete-modal
"
,
attr
:
"
data-target
"
}]
},
},
// User entity blueprint setting html strucuture per entity per row
// User entity blueprint setting html strucuture per entity per row
...
...
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