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
29dbdc9f
Commit
29dbdc9f
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add URL property to some models
parent
4c92fdfb
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
+46
-5
46 additions, 5 deletions
web/app/models.py
with
46 additions
and
5 deletions
web/app/models.py
+
46
−
5
View file @
29dbdc9f
from
datetime
import
datetime
from
datetime
import
datetime
from
flask
import
current_app
from
flask
import
current_app
,
url_for
from
flask_login
import
UserMixin
,
AnonymousUserMixin
from
flask_login
import
UserMixin
,
AnonymousUserMixin
from
itsdangerous
import
BadSignature
,
TimedJSONWebSignatureSerializer
from
itsdangerous
import
BadSignature
,
TimedJSONWebSignatureSerializer
from
time
import
sleep
from
time
import
sleep
...
@@ -281,10 +281,20 @@ class JobInput(db.Model):
...
@@ -281,10 +281,20 @@ class JobInput(db.Model):
# Fields
# Fields
filename
=
db
.
Column
(
db
.
String
(
255
))
filename
=
db
.
Column
(
db
.
String
(
255
))
@property
def
download_url
(
self
):
return
url_for
(
'
job.download_job_input
'
,
job_id
=
self
.
job_id
,
job_input_id
=
self
.
id
)
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
job
.
path
,
self
.
filename
)
return
os
.
path
.
join
(
self
.
job
.
path
,
self
.
filename
)
@property
def
url
(
self
):
return
url_for
(
'
jobs.job
'
,
job_id
=
self
.
job_id
,
_anchor
=
'
job-{}-input-{}
'
.
format
(
self
.
job_id
,
self
.
id
))
def
__repr__
(
self
):
def
__repr__
(
self
):
'''
'''
String representation of the JobInput. For human readability.
String representation of the JobInput. For human readability.
...
@@ -292,7 +302,9 @@ class JobInput(db.Model):
...
@@ -292,7 +302,9 @@ class JobInput(db.Model):
return
'
<JobInput {}>
'
.
format
(
self
.
filename
)
return
'
<JobInput {}>
'
.
format
(
self
.
filename
)
def
to_dict
(
self
):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
return
{
'
download_url
'
:
self
.
download_url
,
'
url
'
:
self
.
url
,
'
id
'
:
self
.
id
,
'
job_id
'
:
self
.
job_id
,
'
job_id
'
:
self
.
job_id
,
'
filename
'
:
self
.
filename
}
'
filename
'
:
self
.
filename
}
...
@@ -309,10 +321,20 @@ class JobResult(db.Model):
...
@@ -309,10 +321,20 @@ class JobResult(db.Model):
# Fields
# Fields
filename
=
db
.
Column
(
db
.
String
(
255
))
filename
=
db
.
Column
(
db
.
String
(
255
))
@property
def
download_url
(
self
):
return
url_for
(
'
job.download_job_result
'
,
job_id
=
self
.
job_id
,
job_result_id
=
self
.
id
)
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
job
.
path
,
'
output
'
,
self
.
filename
)
return
os
.
path
.
join
(
self
.
job
.
path
,
'
output
'
,
self
.
filename
)
@property
def
url
(
self
):
return
url_for
(
'
jobs.job
'
,
job_id
=
self
.
job_id
,
_anchor
=
'
job-{}-result-{}
'
.
format
(
self
.
job_id
,
self
.
id
))
def
__repr__
(
self
):
def
__repr__
(
self
):
'''
'''
String representation of the JobResult. For human readability.
String representation of the JobResult. For human readability.
...
@@ -320,7 +342,9 @@ class JobResult(db.Model):
...
@@ -320,7 +342,9 @@ class JobResult(db.Model):
return
'
<JobResult {}>
'
.
format
(
self
.
filename
)
return
'
<JobResult {}>
'
.
format
(
self
.
filename
)
def
to_dict
(
self
):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
return
{
'
download_url
'
:
self
.
download_url
,
'
url
'
:
self
.
url
,
'
id
'
:
self
.
id
,
'
job_id
'
:
self
.
job_id
,
'
job_id
'
:
self
.
job_id
,
'
filename
'
:
self
.
filename
}
'
filename
'
:
self
.
filename
}
...
@@ -359,6 +383,10 @@ class Job(db.Model):
...
@@ -359,6 +383,10 @@ class Job(db.Model):
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
jobs
'
,
str
(
self
.
id
))
return
os
.
path
.
join
(
self
.
creator
.
path
,
'
jobs
'
,
str
(
self
.
id
))
@property
def
path
(
self
):
return
url_for
(
'
job.job
'
,
job_id
=
self
.
id
)
def
__repr__
(
self
):
def
__repr__
(
self
):
'''
'''
String representation of the Job. For human readability.
String representation of the Job. For human readability.
...
@@ -395,7 +423,8 @@ class Job(db.Model):
...
@@ -395,7 +423,8 @@ class Job(db.Model):
self
.
status
=
'
submitted
'
self
.
status
=
'
submitted
'
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
,
...
@@ -435,10 +464,20 @@ class CorpusFile(db.Model):
...
@@ -435,10 +464,20 @@ class CorpusFile(db.Model):
school
=
db
.
Column
(
db
.
String
(
255
))
school
=
db
.
Column
(
db
.
String
(
255
))
title
=
db
.
Column
(
db
.
String
(
255
))
title
=
db
.
Column
(
db
.
String
(
255
))
@property
def
download_url
(
self
):
return
url_for
(
'
corpora.download_corpus_file
'
,
corpus_id
=
self
.
corpus_id
,
corpus_file_id
=
self
.
id
)
@property
@property
def
path
(
self
):
def
path
(
self
):
return
os
.
path
.
join
(
self
.
corpus
.
path
,
self
.
filename
)
return
os
.
path
.
join
(
self
.
corpus
.
path
,
self
.
filename
)
@property
def
url
(
self
):
return
url_for
(
'
corpora.corpus_file
'
,
corpus_id
=
self
.
corpus_id
,
corpus_file_id
=
self
.
id
)
def
delete
(
self
):
def
delete
(
self
):
try
:
try
:
os
.
remove
(
self
.
path
)
os
.
remove
(
self
.
path
)
...
@@ -449,7 +488,9 @@ class CorpusFile(db.Model):
...
@@ -449,7 +488,9 @@ class CorpusFile(db.Model):
self
.
corpus
.
status
=
'
unprepared
'
self
.
corpus
.
status
=
'
unprepared
'
def
to_dict
(
self
):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
return
{
'
download_url
'
:
self
.
download_url
,
'
url
'
:
self
.
url
,
'
id
'
:
self
.
id
,
'
corpus_id
'
:
self
.
corpus_id
,
'
corpus_id
'
:
self
.
corpus_id
,
'
address
'
:
self
.
address
,
'
address
'
:
self
.
address
,
'
author
'
:
self
.
author
,
'
author
'
:
self
.
author
,
...
...
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