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
1be8a449
Commit
1be8a449
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
cleanup in models file
parent
28801496
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
+51
-8
51 additions, 8 deletions
app/models.py
with
51 additions
and
8 deletions
app/models.py
+
51
−
8
View file @
1be8a449
...
...
@@ -205,6 +205,8 @@ class Role(HashidMixin, db.Model):
if
self
.
has_permission
(
x
.
value
)
]
}
if
backrefs
:
pass
if
relationships
:
json_serializeable
[
'
users
'
]
=
{
x
.
hashid
:
x
.
to_json_serializeable
(
relationships
=
True
)
...
...
@@ -256,6 +258,27 @@ class Token(db.Model):
self
.
access_expiration
=
datetime
.
utcnow
()
self
.
refresh_expiration
=
datetime
.
utcnow
()
def
to_json_serializeable
(
self
,
backrefs
=
False
,
relationships
=
False
):
json_serializeable
=
{
'
id
'
:
self
.
hashid
,
'
access_token
'
:
self
.
access_token
,
'
access_expiration
'
:
(
None
if
self
.
access_expiration
is
None
else
f
'
{
self
.
access_expiration
.
isoformat
()
}
Z
'
),
'
refresh_token
'
:
self
.
refresh_token
,
'
refresh_expiration
'
:
(
None
if
self
.
refresh_expiration
is
None
else
f
'
{
self
.
refresh_expiration
.
isoformat
()
}
Z
'
)
}
if
backrefs
:
json_serializeable
[
'
user
'
]
=
\
self
.
user
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
@staticmethod
def
clean
():
"""
Remove any tokens that have been expired for more than a day.
"""
...
...
@@ -288,6 +311,11 @@ class Avatar(HashidMixin, FileMixin, db.Model):
'
id
'
:
self
.
hashid
,
**
self
.
file_mixin_to_json_serializeable
()
}
if
backrefs
:
json_serializeable
[
'
user
'
]
=
\
self
.
user
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -328,6 +356,13 @@ class CorpusFollowerAssociation(HashidMixin, db.Model):
'
corpus
'
:
self
.
corpus
.
to_json_serializeable
(),
'
follower
'
:
self
.
follower
.
to_json_serializeable
()
}
if
backrefs
:
json_serializeable
[
'
corpus
'
]
=
\
self
.
corpus
.
to_json_serializeable
(
backrefs
=
True
)
json_serializeable
[
'
follower
'
]
=
\
self
.
follower
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -620,7 +655,6 @@ class User(HashidMixin, UserMixin, db.Model):
def
is_following_corpus
(
self
,
corpus
):
return
corpus
in
self
.
followed_corpora
def
to_json_serializeable
(
self
,
backrefs
=
False
,
relationships
=
False
,
filter_by_privacy_settings
=
False
):
json_serializeable
=
{
'
id
'
:
self
.
hashid
,
...
...
@@ -628,9 +662,9 @@ class User(HashidMixin, UserMixin, db.Model):
'
email
'
:
self
.
email
,
'
last_seen
'
:
(
None
if
self
.
last_seen
is
None
else
self
.
last_seen
.
strftime
(
'
%Y-%m-%d %H:%M
'
)
else
f
'
{
self
.
last_seen
.
isoformat
()
}
Z
'
),
'
member_since
'
:
self
.
member_since
.
strftime
(
'
%Y-%m-%d
'
)
,
'
member_since
'
:
f
'
{
self
.
member_since
.
isoformat
()
}
Z
'
,
'
username
'
:
self
.
username
,
'
full_name
'
:
self
.
full_name
,
'
about_me
'
:
self
.
about_me
,
...
...
@@ -804,6 +838,8 @@ class TesseractOCRPipelineModel(FileMixin, HashidMixin, db.Model):
if
backrefs
:
json_serializeable
[
'
user
'
]
=
\
self
.
user
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -930,7 +966,10 @@ class SpaCyNLPPipelineModel(FileMixin, HashidMixin, db.Model):
**
self
.
file_mixin_to_json_serializeable
()
}
if
backrefs
:
json_serializeable
[
'
user
'
]
=
self
.
user
.
to_json_serializeable
(
backrefs
=
True
)
json_serializeable
[
'
user
'
]
=
\
self
.
user
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -989,6 +1028,8 @@ class JobInput(FileMixin, HashidMixin, db.Model):
if
backrefs
:
json_serializeable
[
'
job
'
]
=
\
self
.
job
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -1053,6 +1094,8 @@ class JobResult(FileMixin, HashidMixin, db.Model):
if
backrefs
:
json_serializeable
[
'
job
'
]
=
\
self
.
job
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
@@ -1132,7 +1175,6 @@ class Job(HashidMixin, db.Model):
raise
e
return
job
def
delete
(
self
):
'''
Delete the job and its inputs and results from the database.
'''
if
self
.
status
not
in
[
JobStatus
.
COMPLETED
,
JobStatus
.
FAILED
]:
# noqa
...
...
@@ -1177,8 +1219,7 @@ class Job(HashidMixin, db.Model):
'
service_args
'
:
self
.
service_args
,
'
service_version
'
:
self
.
service_version
,
'
status
'
:
self
.
status
.
name
,
'
title
'
:
self
.
title
,
'
url
'
:
self
.
url
'
title
'
:
self
.
title
}
if
backrefs
:
json_serializeable
[
'
user
'
]
=
\
...
...
@@ -1264,9 +1305,9 @@ class CorpusFile(FileMixin, HashidMixin, db.Model):
def
to_json_serializeable
(
self
,
backrefs
=
False
,
relationships
=
False
):
json_serializeable
=
{
'
id
'
:
self
.
hashid
,
'
url
'
:
self
.
url
,
'
address
'
:
self
.
address
,
'
author
'
:
self
.
author
,
'
description
'
:
self
.
description
,
'
booktitle
'
:
self
.
booktitle
,
'
chapter
'
:
self
.
chapter
,
'
editor
'
:
self
.
editor
,
...
...
@@ -1285,6 +1326,8 @@ class CorpusFile(FileMixin, HashidMixin, db.Model):
if
backrefs
:
json_serializeable
[
'
corpus
'
]
=
\
self
.
corpus
.
to_json_serializeable
(
backrefs
=
True
)
if
relationships
:
pass
return
json_serializeable
...
...
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