Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development

This commit is contained in:
Stephan Porada 2020-04-29 16:15:12 +02:00
commit d4318cb205
3 changed files with 62 additions and 30 deletions

View File

@ -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)
password_hash = db.Column(db.String(128))
last_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)
# Fields
filename = db.Column(db.String(255))
dir = db.Column(db.String(255))
# Foreign keys
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
# Fields
dir = db.Column(db.String(255))
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)
# Fields
filename = db.Column(db.String(255))
dir = db.Column(db.String(255))
# Foreign keys
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
# Fields
dir = db.Column(db.String(255))
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,27 +437,26 @@ 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)
last_edited_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:

View File

@ -25,7 +25,7 @@
<p><i class="material-icons left">notifications</i>Job status site notifications</p>
<p class="light">Receive site notifications about job status changes.</p>
</div>
<div class="col s12 m4 right-align">
<div class="col s12 m4 right-align" style="margin-top: -1rem;">
{{ M.render_field(edit_general_settings_form.job_status_site_notifications, label=False) }}
</div>
<div class="col s12"><p>&nbsp;</p></div>
@ -35,7 +35,7 @@
<p><i class="material-icons left">notifications</i>Job status mail notifications</p>
<p class="light">Receive mail notifications about job status changes.</p>
</div>
<div class="col s12 m4 right-align">
<div class="col s12 m4 right-align" style="margin-top: -1rem;">
{{ M.render_field(edit_general_settings_form.job_status_mail_notifications, label=False) }}
</div>
<!--

View File

@ -18,8 +18,15 @@ services:
labels:
- "traefik.docker.network=reverse-proxy"
- "traefik.enable=true"
- "traefik.http.routers.proxy.rule=Host(`nopaque.localhost`)"
- "traefik.http.routers.proxy.entrypoints=web"
- "traefik.http.routers.nopaque.entrypoints=web"
# Change the next line to match your nopaque domain.
- "traefik.http.routers.nopaque.rule=Host(`nopaque.localhost`)"
# The next two lines enable HTTPS.
# - "traefik.http.routers.nopaque.entrypoints=websecure"
# - "traefik.http.routers.nopaque.tls.certresolver=myresolver"
# The next two lines add Basic Authentication. More information: https://docs.traefik.io/middlewares/basicauth/
# - "traefik.http.middlewares.nopaque.basicauth.users=name:hashed-password"
# - "traefik.http.routers.nopaque.middlewares=nopaque"
networks:
- default
- reverse-proxy