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
b7fc804b
Commit
b7fc804b
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Sort things a bit... this should get improved in the future
parent
2ceb53ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+49
-24
49 additions, 24 deletions
app/models.py
with
49 additions
and
24 deletions
app/models.py
+
49
−
24
View file @
b7fc804b
...
...
@@ -35,6 +35,12 @@ class Role(db.Model):
# Relationships
users
=
db
.
relationship
(
'
User
'
,
backref
=
'
role
'
,
lazy
=
'
dynamic
'
)
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
default
'
:
self
.
default
,
'
name
'
:
self
.
name
,
'
permissions
'
:
self
.
permissions
}
def
__init__
(
self
,
**
kwargs
):
super
(
Role
,
self
).
__init__
(
**
kwargs
)
if
self
.
permissions
is
None
:
...
...
@@ -104,26 +110,42 @@ class User(UserMixin, db.Model):
__tablename__
=
'
users
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
role_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
roles.id
'
))
# Fields
confirmed
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
last_seen
=
db
.
Column
(
db
.
DateTime
(),
default
=
datetime
.
utcnow
)
email
=
db
.
Column
(
db
.
String
(
254
),
unique
=
True
,
index
=
True
)
p
as
sword_hash
=
db
.
Column
(
db
.
String
(
128
)
)
l
as
t_seen
=
db
.
Column
(
db
.
DateTime
(),
default
=
datetime
.
utcnow
)
member_since
=
db
.
Column
(
db
.
DateTime
(),
default
=
datetime
.
utcnow
)
role_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
roles.id
'
))
username
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
,
index
=
True
)
# Setting Fields
password_hash
=
db
.
Column
(
db
.
String
(
128
))
setting_dark_mode
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
setting_job_status_mail_notifications
=
db
.
Column
(
db
.
String
(
16
),
default
=
'
end
'
)
setting_job_status_site_notifications
=
db
.
Column
(
db
.
String
(
16
),
default
=
'
all
'
)
username
=
db
.
Column
(
db
.
String
(
64
),
unique
=
True
,
index
=
True
)
# Relationships
corpora
=
db
.
relationship
(
'
Corpus
'
,
backref
=
'
creator
'
,
lazy
=
'
dynamic
'
,
cascade
=
'
save-update, merge, delete
'
)
jobs
=
db
.
relationship
(
'
Job
'
,
backref
=
'
creator
'
,
lazy
=
'
dynamic
'
,
cascade
=
'
save-update, merge, delete
'
)
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
confirmed
'
:
self
.
confirmed
,
'
email
'
:
self
.
email
,
'
last_seen
'
:
self
.
last_seen
.
timestamp
(),
'
member_since
'
:
self
.
member_since
.
timestamp
(),
'
role_id
'
:
self
.
role_id
,
'
username
'
:
self
.
username
,
'
settings
'
:
{
'
dark_mode
'
:
self
.
setting_dark_mode
,
'
job_status_mail_notifications
'
:
self
.
setting_job_status_mail_notifications
,
'
job_status_site_notifications
'
:
self
.
setting_job_status_site_notifications
},
'
corpora
'
:
[
corpus
.
to_dict
()
for
corpus
in
self
.
corpora
],
'
jobs
'
:
[
job
.
to_dict
()
for
job
in
self
.
jobs
]}
def
__repr__
(
self
):
"""
String representation of the User. For human readability.
...
...
@@ -245,10 +267,11 @@ class JobInput(db.Model):
__tablename__
=
'
job_inputs
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
# Fields
filename
=
db
.
Column
(
db
.
String
(
255
))
dir
=
db
.
Column
(
db
.
String
(
255
))
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
filename
=
db
.
Column
(
db
.
String
(
255
))
def
__repr__
(
self
):
"""
...
...
@@ -258,8 +281,8 @@ class JobInput(db.Model):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
filename
'
:
self
.
filename
,
'
job_id
'
:
self
.
job_id
}
'
job_id
'
:
self
.
job_id
,
'
filename
'
:
self
.
filename
}
class
JobResult
(
db
.
Model
):
...
...
@@ -269,10 +292,11 @@ class JobResult(db.Model):
__tablename__
=
'
job_results
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
# Fields
filename
=
db
.
Column
(
db
.
String
(
255
))
dir
=
db
.
Column
(
db
.
String
(
255
))
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
filename
=
db
.
Column
(
db
.
String
(
255
))
def
__repr__
(
self
):
"""
...
...
@@ -282,8 +306,8 @@ class JobResult(db.Model):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
filename
'
:
self
.
filename
,
'
job_id
'
:
self
.
job_id
}
'
job_id
'
:
self
.
job_id
,
'
filename
'
:
self
.
filename
}
class
Job
(
db
.
Model
):
...
...
@@ -293,6 +317,8 @@ class Job(db.Model):
__tablename__
=
'
jobs
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
# Fields
creation_date
=
db
.
Column
(
db
.
DateTime
(),
default
=
datetime
.
utcnow
)
description
=
db
.
Column
(
db
.
String
(
255
))
...
...
@@ -309,7 +335,6 @@ class Job(db.Model):
service_version
=
db
.
Column
(
db
.
String
(
16
))
status
=
db
.
Column
(
db
.
String
(
16
))
title
=
db
.
Column
(
db
.
String
(
32
))
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
# Relationships
inputs
=
db
.
relationship
(
'
JobInput
'
,
backref
=
'
job
'
,
lazy
=
'
dynamic
'
,
cascade
=
'
save-update, merge, delete
'
)
...
...
@@ -341,6 +366,7 @@ class Job(db.Model):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
user_id
'
:
self
.
user_id
,
'
creation_date
'
:
self
.
creation_date
.
timestamp
(),
'
description
'
:
self
.
description
,
'
end_date
'
:
(
self
.
end_date
.
timestamp
()
if
self
.
end_date
else
...
...
@@ -353,8 +379,7 @@ class Job(db.Model):
'
service_args
'
:
self
.
service_args
,
'
service_version
'
:
self
.
service_version
,
'
status
'
:
self
.
status
,
'
title
'
:
self
.
title
,
'
user_id
'
:
self
.
user_id
}
'
title
'
:
self
.
title
}
class
CorpusFile
(
db
.
Model
):
...
...
@@ -364,6 +389,8 @@ class CorpusFile(db.Model):
__tablename__
=
'
corpus_files
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
corpus_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
corpora.id
'
))
# Fields
address
=
db
.
Column
(
db
.
String
(
255
))
author
=
db
.
Column
(
db
.
String
(
255
))
...
...
@@ -379,7 +406,6 @@ class CorpusFile(db.Model):
publishing_year
=
db
.
Column
(
db
.
Integer
)
school
=
db
.
Column
(
db
.
String
(
255
))
title
=
db
.
Column
(
db
.
String
(
255
))
corpus_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
corpora.id
'
))
def
delete
(
self
):
self
.
corpus
.
status
=
'
unprepared
'
...
...
@@ -388,6 +414,7 @@ class CorpusFile(db.Model):
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
corpus_id
'
:
self
.
corpus_id
,
'
address
'
:
self
.
address
,
'
author
'
:
self
.
author
,
'
booktitle
'
:
self
.
booktitle
,
...
...
@@ -400,8 +427,7 @@ class CorpusFile(db.Model):
'
publisher
'
:
self
.
publisher
,
'
publishing_year
'
:
self
.
publishing_year
,
'
school
'
:
self
.
school
,
'
title
'
:
self
.
title
,
'
corpus_id
'
:
self
.
corpus_id
}
'
title
'
:
self
.
title
}
class
Corpus
(
db
.
Model
):
...
...
@@ -411,26 +437,25 @@ class Corpus(db.Model):
__tablename__
=
'
corpora
'
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
# Fields
creation_date
=
db
.
Column
(
db
.
DateTime
(),
default
=
datetime
.
utcnow
)
description
=
db
.
Column
(
db
.
String
(
255
))
status
=
db
.
Column
(
db
.
String
(
16
))
title
=
db
.
Column
(
db
.
String
(
32
))
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
analysis_container_ip
=
db
.
Column
(
db
.
String
(
16
))
analysis_container_name
=
db
.
Column
(
db
.
String
(
32
))
# Relationships
files
=
db
.
relationship
(
'
CorpusFile
'
,
backref
=
'
corpus
'
,
lazy
=
'
dynamic
'
,
cascade
=
'
save-update, merge, delete
'
)
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
user_id
'
:
self
.
user_id
,
'
creation_date
'
:
self
.
creation_date
.
timestamp
(),
'
description
'
:
self
.
description
,
'
files
'
:
[
file
.
to_dict
()
for
file
in
self
.
files
],
'
status
'
:
self
.
status
,
'
title
'
:
self
.
title
,
'
user_id
'
:
self
.
user_id
}
'
files
'
:
[
file
.
to_dict
()
for
file
in
self
.
files
]
}
def
delete
(
self
):
for
corpus_file
in
self
.
files
:
...
...
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