mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
a2f7f90137
@ -15,8 +15,8 @@ before_script:
|
|||||||
|
|
||||||
Build:
|
Build:
|
||||||
script:
|
script:
|
||||||
- docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
|
- docker build --pull -t $CI_REGISTRY_IMAGE:tmp .
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker push $CI_REGISTRY_IMAGE:tmp
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -25,8 +25,8 @@ Push development:
|
|||||||
only:
|
only:
|
||||||
- development
|
- development
|
||||||
script:
|
script:
|
||||||
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker pull $CI_REGISTRY_IMAGE:tmp
|
||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:development
|
- docker tag $CI_REGISTRY_IMAGE:tmp $CI_REGISTRY_IMAGE:development
|
||||||
- docker push $CI_REGISTRY_IMAGE:development
|
- docker push $CI_REGISTRY_IMAGE:development
|
||||||
stage: push
|
stage: push
|
||||||
tags:
|
tags:
|
||||||
@ -36,8 +36,8 @@ Push latest:
|
|||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
script:
|
script:
|
||||||
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker pull $CI_REGISTRY_IMAGE:tmp
|
||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
|
- docker tag $CI_REGISTRY_IMAGE:tmp $CI_REGISTRY_IMAGE:latest
|
||||||
- docker push $CI_REGISTRY_IMAGE:latest
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
stage: push
|
stage: push
|
||||||
tags:
|
tags:
|
||||||
@ -47,8 +47,8 @@ Push tag:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
- docker pull $CI_REGISTRY_IMAGE:tmp
|
||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
- docker tag $CI_REGISTRY_IMAGE:tmp $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
||||||
stage: push
|
stage: push
|
||||||
tags:
|
tags:
|
||||||
|
@ -19,7 +19,7 @@ def add_corpus():
|
|||||||
if add_corpus_form.validate_on_submit():
|
if add_corpus_form.validate_on_submit():
|
||||||
corpus = Corpus(creator=current_user,
|
corpus = Corpus(creator=current_user,
|
||||||
description=add_corpus_form.description.data,
|
description=add_corpus_form.description.data,
|
||||||
title=add_corpus_form.title.data)
|
status='unprepared', title=add_corpus_form.title.data)
|
||||||
db.session.add(corpus)
|
db.session.add(corpus)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||||
@ -166,6 +166,7 @@ def edit_corpus_file(corpus_id, corpus_file_id):
|
|||||||
corpus_file.author = edit_corpus_file_form.author.data
|
corpus_file.author = edit_corpus_file_form.author.data
|
||||||
corpus_file.publishing_year = edit_corpus_file_form.publishing_year.data
|
corpus_file.publishing_year = edit_corpus_file_form.publishing_year.data
|
||||||
corpus_file.title = edit_corpus_file_form.title.data
|
corpus_file.title = edit_corpus_file_form.title.data
|
||||||
|
corpus_file.insert_metadata()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Corpus file edited!')
|
flash('Corpus file edited!')
|
||||||
return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
||||||
|
@ -2,6 +2,7 @@ from flask import current_app
|
|||||||
from flask_login import UserMixin, AnonymousUserMixin
|
from flask_login import UserMixin, AnonymousUserMixin
|
||||||
from itsdangerous import BadSignature, TimedJSONWebSignatureSerializer
|
from itsdangerous import BadSignature, TimedJSONWebSignatureSerializer
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
from . import db
|
from . import db
|
||||||
from . import login_manager
|
from . import login_manager
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -410,6 +411,18 @@ class CorpusFile(db.Model):
|
|||||||
title = db.Column(db.String(64))
|
title = db.Column(db.String(64))
|
||||||
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id'))
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(CorpusFile, self).__init__(**kwargs)
|
||||||
|
file = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||||
|
self.dir,
|
||||||
|
self.filename)
|
||||||
|
element_tree = ET.parse(file)
|
||||||
|
text_node = element_tree.find('text')
|
||||||
|
text_node.set('author', self.author)
|
||||||
|
text_node.set('publishing_year', str(self.publishing_year))
|
||||||
|
text_node.set('title', self.title)
|
||||||
|
element_tree.write(file)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.warning('Called CorpusFile.delete')
|
logger.warning('Called CorpusFile.delete')
|
||||||
@ -434,18 +447,15 @@ class Corpus(db.Model):
|
|||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
creation_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
creation_date = db.Column(db.DateTime(), default=datetime.utcnow)
|
||||||
description = db.Column(db.String(255))
|
description = db.Column(db.String(255))
|
||||||
|
status = db.Column(db.String(16))
|
||||||
title = db.Column(db.String(32))
|
title = db.Column(db.String(32))
|
||||||
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
|
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
|
||||||
status = db.Column(db.String(16))
|
|
||||||
# Relationships
|
# Relationships
|
||||||
files = db.relationship('CorpusFile',
|
files = db.relationship('CorpusFile',
|
||||||
backref='corpus',
|
backref='corpus',
|
||||||
lazy='dynamic',
|
lazy='dynamic',
|
||||||
cascade='save-update, merge, delete')
|
cascade='save-update, merge, delete')
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super(Corpus, self).__init__(**kwargs)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
String representation of the corpus. For human readability.
|
String representation of the corpus. For human readability.
|
||||||
@ -482,6 +492,9 @@ class Corpus(db.Model):
|
|||||||
db.session.delete(self)
|
db.session.delete(self)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def prepare(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
' Flask-Login is told to use the application’s custom anonymous user by setting
|
' Flask-Login is told to use the application’s custom anonymous user by setting
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<div class="col s12 m4">
|
<div class="col s12 m4">
|
||||||
<h3 id="title">{{ corpus.title }}</h3>
|
<h3 id="title">{{ corpus.title }}</h3>
|
||||||
<p id="description">{{ corpus.description }}</p>
|
<p id="description">{{ corpus.description }}</p>
|
||||||
|
<a class="waves-effect waves-light btn">{{ corpus.status }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s12 m8">
|
<div class="col s12 m8">
|
||||||
@ -18,13 +19,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="card-title">Actions</span>
|
</div>
|
||||||
<a href="{{ url_for('corpora.corpus_analysis', corpus_id=corpus.id) }}" class="waves-effect waves-light btn">
|
<div class="card-action right-align">
|
||||||
<i class="material-icons left">help</i>Analyse
|
<a href="{{ url_for('corpora.corpus_analysis', corpus_id=corpus.id) }}" class="waves-effect waves-light btn"><i class="material-icons left">help</i>Analyse</a>
|
||||||
</a>
|
<a data-target="delete-corpus-modal" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete Corpus</a>
|
||||||
<a data-target="delete-corpus-modal" class="waves-effect waves-light btn red modal-trigger right">
|
|
||||||
<i class="material-icons left">delete</i>Delete Corpus
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
if (timestamp === null) {
|
if (timestamp === null) {
|
||||||
end_date = "N.a.";
|
end_date = "N.a.";
|
||||||
} else {
|
} else {
|
||||||
end_date = new Date(timestamp * 1000).toLocaleString();
|
end_date = new Date(timestamp * 1000).toLocaleString("en-US");
|
||||||
}
|
}
|
||||||
document.getElementById("end-date").value = end_date;
|
document.getElementById("end-date").value = end_date;
|
||||||
M.updateTextFields();
|
M.updateTextFields();
|
||||||
@ -118,23 +118,6 @@
|
|||||||
<h3 id="title">{{ job.title }}</h3>
|
<h3 id="title">{{ job.title }}</h3>
|
||||||
<p id="description">{{ job.description }}</p>
|
<p id="description">{{ job.description }}</p>
|
||||||
<a class="waves-effect waves-light btn" id="status"></a>
|
<a class="waves-effect waves-light btn" id="status"></a>
|
||||||
<h2>Actions:</h2>
|
|
||||||
<!-- Confirm deletion of job with modal dialogue
|
|
||||||
Modal Trigger-->
|
|
||||||
<a href="#modal-confirm-delete" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete Job</a>
|
|
||||||
<a href="#" class="waves-effect waves-light btn"><i class="material-icons left">settings</i>Export Parameters</a>
|
|
||||||
<!-- Modal Strucutre -->
|
|
||||||
<div id="modal-confirm-delete" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<h4>Confirm deletion</h4>
|
|
||||||
<p>Do you really want to delete the job {{job.title}}?
|
|
||||||
All iput and output files will be permanently deleted.</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="{{ url_for('jobs.delete_job', job_id=job.id) }}" class="modal-close waves-effect waves-green btn red"><i class="material-icons left">delete</i>Delete Job</a>
|
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn cancel">Cancel</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -195,6 +178,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-action right-align">
|
||||||
|
<a href="#" class="waves-effect waves-light btn"><i class="material-icons left">settings</i>Export Parameters</a>
|
||||||
|
<a data-target="delete-job-modal" class="waves-effect waves-light btn red modal-trigger"><i class="material-icons left">delete</i>Delete Job</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -228,4 +215,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modals -->
|
||||||
|
<div id="delete-job-modal" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4>Confirm deletion</h4>
|
||||||
|
<p>Do you really want to delete the job {{job.title}}? All associated files will be permanently deleted.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn cancel">Cancel</a>
|
||||||
|
<a class="modal-close waves-effect waves-green btn red" href="{{ url_for('jobs.delete_job', job_id=job.id) }}">Confirm<i class="material-icons right">send</i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from .models import Job, User, Corpus
|
from .models import Job, User, Corpus, CorpusFile
|
||||||
from . import db
|
from . import db
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -64,3 +64,8 @@ def background_delete_corpus(app, corpus_id):
|
|||||||
logger.warning('Corpus id is: {}.'.format(corpus_id))
|
logger.warning('Corpus id is: {}.'.format(corpus_id))
|
||||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||||
corpus.delete()
|
corpus.delete()
|
||||||
|
|
||||||
|
|
||||||
|
def background_prepare_corpus_file(app, corpus_file_id):
|
||||||
|
with app.app_context():
|
||||||
|
corpus_file = CorpusFile.query.filter_by(id=corpus_file_id).first()
|
||||||
|
Loading…
Reference in New Issue
Block a user