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
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
a2102a48
Commit
a2102a48
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add url properties to db models
parent
29dbdc9f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/app/models.py
+18
-2
18 additions, 2 deletions
web/app/models.py
with
18 additions
and
2 deletions
web/app/models.py
+
18
−
2
View file @
a2102a48
...
@@ -533,8 +533,13 @@ class Corpus(db.Model):
...
@@ -533,8 +533,13 @@ class Corpus(db.Model):
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
corpora
'
,
str
(
self
.
id
))
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
corpora
'
,
str
(
self
.
id
))
@property
def
url
(
self
):
return
url_for
(
'
corpora.corpus
'
,
corpus_id
=
self
.
id
)
def
to_dict
(
self
):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
return
{
'
url
'
:
self
.
url
,
'
id
'
:
self
.
id
,
'
user_id
'
:
self
.
user_id
,
'
user_id
'
:
self
.
user_id
,
'
creation_date
'
:
self
.
creation_date
.
timestamp
(),
'
creation_date
'
:
self
.
creation_date
.
timestamp
(),
'
description
'
:
self
.
description
,
'
description
'
:
self
.
description
,
...
@@ -600,17 +605,28 @@ class QueryResult(db.Model):
...
@@ -600,17 +605,28 @@ class QueryResult(db.Model):
query_metadata
=
db
.
Column
(
db
.
JSON
())
query_metadata
=
db
.
Column
(
db
.
JSON
())
title
=
db
.
Column
(
db
.
String
(
32
))
title
=
db
.
Column
(
db
.
String
(
32
))
@property
def
download_url
(
self
):
return
url_for
(
'
corpora.download_query_result
'
,
query_result_id
=
self
.
id
)
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
query_results
'
,
str
(
self
.
id
),
self
.
filename
)
self
.
creator
.
path
,
'
query_results
'
,
str
(
self
.
id
),
self
.
filename
)
@property
def
url
(
self
):
return
url_for
(
'
corpora.query_result
'
,
query_result_id
=
self
.
id
)
def
delete
(
self
):
def
delete
(
self
):
shutil
.
rmtree
(
self
.
path
,
ignore_errors
=
True
)
shutil
.
rmtree
(
self
.
path
,
ignore_errors
=
True
)
db
.
session
.
delete
(
self
)
db
.
session
.
delete
(
self
)
def
to_dict
(
self
):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
return
{
'
download_url
'
:
self
.
download_url
,
'
url
'
:
self
.
url
,
'
id
'
:
self
.
id
,
'
user_id
'
:
self
.
user_id
,
'
user_id
'
:
self
.
user_id
,
'
description
'
:
self
.
description
,
'
description
'
:
self
.
description
,
'
filename
'
:
self
.
filename
,
'
filename
'
:
self
.
filename
,
...
...
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