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
19f1dea4
Commit
19f1dea4
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Use list comprehension instead of class methods.
parent
5602ba95
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/events.py
+4
-4
4 additions, 4 deletions
app/events.py
app/models.py
+0
-12
0 additions, 12 deletions
app/models.py
with
4 additions
and
16 deletions
app/events.py
+
4
−
4
View file @
19f1dea4
...
@@ -73,16 +73,16 @@ def user_ressource_subscription_handler(app, user_id, session_id,
...
@@ -73,16 +73,16 @@ def user_ressource_subscription_handler(app, user_id, session_id,
with
app
.
app_context
():
with
app
.
app_context
():
# Gather current values from database.
# Gather current values from database.
user
=
User
.
query
.
filter_by
(
id
=
user_id
).
first
()
user
=
User
.
query
.
filter_by
(
id
=
user_id
).
first
()
corpora
=
user
.
corpora_as_dict
()
corpora
=
{
corpus
.
id
:
corpus
.
to_dict
()
for
corpus
in
user
.
corpora
}
jobs
=
user
.
jobs_as_dict
()
jobs
=
{
job
.
id
:
job
.
to_dict
()
for
job
in
user
.
jobs
}
# Send initial values to the user.
# Send initial values to the user.
socketio
.
emit
(
init_events
[
'
corpora
'
],
json
.
dumps
(
corpora
),
socketio
.
emit
(
init_events
[
'
corpora
'
],
json
.
dumps
(
corpora
),
room
=
session_id
)
room
=
session_id
)
socketio
.
emit
(
init_events
[
'
jobs
'
],
json
.
dumps
(
jobs
),
room
=
session_id
)
socketio
.
emit
(
init_events
[
'
jobs
'
],
json
.
dumps
(
jobs
),
room
=
session_id
)
while
session_id
in
connected_sessions
:
while
session_id
in
connected_sessions
:
# Get new values from the database
# Get new values from the database
new_corpora
=
user
.
corpora_as_dict
()
new_corpora
=
{
corpus
.
id
:
corpus
.
to_dict
()
for
corpus
in
user
.
corpora
}
new_jobs
=
user
.
jobs_as_dict
()
new_jobs
=
{
job
.
id
:
job
.
to_dict
()
for
job
in
user
.
jobs
}
# Compute JSON patches.
# Compute JSON patches.
corpora_patch
=
jsonpatch
.
JsonPatch
.
from_diff
(
corpora
,
new_corpora
)
corpora_patch
=
jsonpatch
.
JsonPatch
.
from_diff
(
corpora
,
new_corpora
)
jobs_patch
=
jsonpatch
.
JsonPatch
.
from_diff
(
jobs
,
new_jobs
)
jobs_patch
=
jsonpatch
.
JsonPatch
.
from_diff
(
jobs
,
new_jobs
)
...
...
This diff is collapsed.
Click to expand it.
app/models.py
+
0
−
12
View file @
19f1dea4
...
@@ -208,18 +208,6 @@ class User(UserMixin, db.Model):
...
@@ -208,18 +208,6 @@ class User(UserMixin, db.Model):
"""
"""
return
self
.
can
(
Permission
.
ADMIN
)
return
self
.
can
(
Permission
.
ADMIN
)
def
corpora_as_dict
(
self
):
corpora
=
{}
for
corpus
in
self
.
corpora
:
corpora
[
str
(
corpus
.
id
)]
=
corpus
.
to_dict
()
return
corpora
def
jobs_as_dict
(
self
):
jobs
=
{}
for
job
in
self
.
jobs
:
jobs
[
str
(
job
.
id
)]
=
job
.
to_dict
()
return
jobs
def
delete_user
(
self
):
def
delete_user
(
self
):
"""
"""
Delete user from database. Also delete all associated jobs and corpora
Delete user from database. Also delete all associated jobs and corpora
...
...
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