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

This commit is contained in:
Stephan Porada 2020-04-20 09:59:34 +02:00
commit 2eb3d2f03e
23 changed files with 199 additions and 503 deletions

View File

@ -125,7 +125,7 @@ def corpus_analysis_session_handler(app, corpus_id, user_id, session_id):
while corpus.status != 'analysing': while corpus.status != 'analysing':
db.session.refresh(corpus) db.session.refresh(corpus)
socketio.sleep(3) socketio.sleep(3)
client = cqi.CQiClient('corpus_{}_analysis'.format(corpus_id)) client = cqi.CQiClient('cqpserver_{}'.format(corpus_id))
try: try:
payload = client.connect() payload = client.connect()
except cqi.errors.CQiException as e: except cqi.errors.CQiException as e:

View File

@ -1,9 +1,7 @@
from app import logger
from flask import (abort, current_app, flash, make_response, redirect, request, from flask import (abort, current_app, flash, make_response, redirect, request,
render_template, url_for, send_from_directory) render_template, url_for, send_from_directory)
from flask_login import current_user, login_required from flask_login import current_user, login_required
from threading import Thread from threading import Thread
from werkzeug.utils import secure_filename
from . import corpora from . import corpora
from .background_functions import (delete_corpus_, delete_corpus_file_, from .background_functions import (delete_corpus_, delete_corpus_file_,
edit_corpus_file_) edit_corpus_file_)
@ -129,10 +127,10 @@ def add_corpus_file(corpus_id):
return make_response( return make_response(
{'redirect_url': url_for('corpora.corpus', corpus_id=corpus.id)}, {'redirect_url': url_for('corpora.corpus', corpus_id=corpus.id)},
201) 201)
# return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
return render_template('corpora/add_corpus_file.html.j2', return render_template('corpora/add_corpus_file.html.j2',
corpus=corpus,
add_corpus_file_form=add_corpus_file_form, add_corpus_file_form=add_corpus_file_form,
corpus=corpus, title='Add corpus file') title='Add corpus file')
@corpora.route('/<int:corpus_id>/files/<int:corpus_file_id>/delete') @corpora.route('/<int:corpus_id>/files/<int:corpus_file_id>/delete')
@ -170,25 +168,28 @@ def download_corpus_file(corpus_id, corpus_file_id):
methods=['GET', 'POST']) methods=['GET', 'POST'])
@login_required @login_required
def edit_corpus_file(corpus_id, corpus_file_id): def edit_corpus_file(corpus_id, corpus_file_id):
corpus = Corpus.query.get_or_404(corpus_id)
corpus_file = CorpusFile.query.get_or_404(corpus_file_id) corpus_file = CorpusFile.query.get_or_404(corpus_file_id)
if not corpus_file.corpus_id == corpus_id: if not corpus_file.corpus_id == corpus_id:
abort(404) abort(404)
if not (corpus_file.corpus.creator == current_user if not (corpus_file.corpus.creator == current_user
or current_user.is_administrator()): or current_user.is_administrator()):
abort(403) abort(403)
edit_corpus_file_form = EditCorpusFileForm() edit_corpus_file_form = EditCorpusFileForm(prefix='edit-corpus-file-form')
if edit_corpus_file_form.validate_on_submit(): if edit_corpus_file_form.validate_on_submit():
ids = [field.id for field in edit_corpus_file_form if not corpus_file.address = edit_corpus_file_form.address.data
(field.id == 'submit' corpus_file.author = edit_corpus_file_form.author.data
or field.id == "csrf_token" corpus_file.booktitle = edit_corpus_file_form.booktitle.data
or field.id == "file")] corpus_file.chapter = edit_corpus_file_form.chapter.data
data = [field.data for field in edit_corpus_file_form if not corpus_file.editor = edit_corpus_file_form.editor.data
(field.id == 'submit' corpus_file.institution = edit_corpus_file_form.institution.data
or field.id == "csrf_token" corpus_file.journal = edit_corpus_file_form.journal.data
or field.id == "file")] corpus_file.pages = edit_corpus_file_form.pages.data
field_dict = dict(zip(ids, data)) corpus_file.publisher = edit_corpus_file_form.publisher.data
stmt = db.update(CorpusFile).where(CorpusFile.id==corpus_file_id).values(**field_dict) corpus_file.publishing_year = \
db.session.execute(stmt) edit_corpus_file_form.publishing_year.data
corpus_file.school = edit_corpus_file_form.school.data
corpus_file.title = edit_corpus_file_form.title.data
db.session.commit() db.session.commit()
thread = Thread(target=edit_corpus_file_, thread = Thread(target=edit_corpus_file_,
args=(current_app._get_current_object(), args=(current_app._get_current_object(),
@ -196,9 +197,23 @@ def edit_corpus_file(corpus_id, corpus_file_id):
thread.start() thread.start()
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))
# If no form is submitted or valid, fill out fields with current values
edit_corpus_file_form.address.data = corpus_file.address
edit_corpus_file_form.author.data = corpus_file.author
edit_corpus_file_form.booktitle.data = corpus_file.booktitle
edit_corpus_file_form.chapter.data = corpus_file.chapter
edit_corpus_file_form.editor.data = corpus_file.editor
edit_corpus_file_form.institution.data = corpus_file.institution
edit_corpus_file_form.journal.data = corpus_file.journal
edit_corpus_file_form.pages.data = corpus_file.pages
edit_corpus_file_form.publisher.data = corpus_file.publisher
edit_corpus_file_form.publishing_year.data = corpus_file.publishing_year
edit_corpus_file_form.school.data = corpus_file.school
edit_corpus_file_form.title.data = corpus_file.title
return render_template('corpora/edit_corpus_file.html.j2', return render_template('corpora/edit_corpus_file.html.j2',
corpus_file=corpus_file, corpus=corpus,
edit_corpus_file_form=edit_corpus_file_form, edit_corpus_file_form=edit_corpus_file_form,
corpus_file=corpus_file, title='Edit corpus file') title='Edit corpus file')
@corpora.route('/<int:corpus_id>/prepare') @corpora.route('/<int:corpus_id>/prepare')
@ -207,7 +222,7 @@ def prepare_corpus(corpus_id):
corpus = Corpus.query.get_or_404(corpus_id) corpus = Corpus.query.get_or_404(corpus_id)
if not (corpus.creator == current_user or current_user.is_administrator()): if not (corpus.creator == current_user or current_user.is_administrator()):
abort(403) abort(403)
if len(corpus.files.all()) > 0: if corpus.files.all():
corpus.status = 'submitted' corpus.status = 'submitted'
db.session.commit() db.session.commit()
flash('Corpus marked for preparation!') flash('Corpus marked for preparation!')

View File

@ -256,7 +256,6 @@ class JobInput(db.Model):
def to_dict(self): def to_dict(self):
return {'id': self.id, return {'id': self.id,
'dir': self.dir,
'filename': self.filename, 'filename': self.filename,
'job_id': self.job_id} 'job_id': self.job_id}
@ -280,7 +279,6 @@ class JobResult(db.Model):
def to_dict(self): def to_dict(self):
return {'id': self.id, return {'id': self.id,
'dir': self.dir,
'filename': self.filename, 'filename': self.filename,
'job_id': self.job_id} 'job_id': self.job_id}
@ -432,7 +430,6 @@ class CorpusFile(db.Model):
'author': self.author, 'author': self.author,
'booktitle': self.booktitle, 'booktitle': self.booktitle,
'chapter': self.chapter, 'chapter': self.chapter,
'dir': self.dir,
'editor': self.editor, 'editor': self.editor,
'filename': self.filename, 'filename': self.filename,
'institution': self.institution, 'institution': self.institution,

View File

@ -113,18 +113,11 @@ nopaque.Forms.init = function() {
} }
form.addEventListener("submit", function(event) { form.addEventListener("submit", function(event) {
event.preventDefault(); event.preventDefault();
var formData, progressModalTitleElement; var formData;
formData = new FormData(form); formData = new FormData(form);
// Initialize progress modal // Initialize progress modal
if (progressModalElement) { if (progressModalElement) {
progressModalTitleElement = progressModalElement.querySelector(".title");
for(let entry of formData.entries()) {
if (entry[0].endsWith("title")) {
progressModalTitleElement.innerText = entry[1];
break;
}
}
progressElement.style.width = "0%"; progressElement.style.width = "0%";
progressModal.open(); progressModal.open();
} }

View File

@ -12,44 +12,13 @@
<form method="POST"> <form method="POST">
<div class="card-content"> <div class="card-content">
{{ edit_user_form.hidden_tag() }} {{ edit_user_form.hidden_tag() }}
<div class="input-field "> {{ M.render_field(edit_user_form.username, data_length='64', material_icon='account_circle') }}
<i class="material-icons prefix">account_circle</i> {{ M.render_field(edit_user_form.email, class_='validate', material_icon='email', type='email') }}
{{ edit_user_form.username() }} {{ M.render_field(edit_user_form.role, material_icon='swap_vert') }}
{{ edit_user_form.username.label }} {{ M.render_field(edit_user_form.confirmed, material_icon='check') }}
{% for error in edit_user_form.username.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">mail</i>
{{ edit_user_form.email() }}
{{ edit_user_form.email.label }}
{% for error in edit_user_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">swap_vert</i>
{{ edit_user_form.role() }}
{{ edit_user_form.role.label }}
{% for error in edit_user_form.role.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="switch">
<i class="material-icons prefix">check</i>
<label>
Confirmed
{{ edit_user_form.confirmed() }}
<span class="lever"></span>
</label>
{% for error in edit_user_form.confirmed.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(edit_user_form.submit) }} {{ M.render_field(edit_user_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -26,41 +26,21 @@
<div class="col s12 m8"> <div class="col s12 m8">
<div class="card medium"> <div class="card medium">
<form method="POST"> <form method="POST">
{{ login_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field"> {{ login_form.hidden_tag() }}
<i class="material-icons prefix">person</i> {{ M.render_field(login_form.user, material_icon='person') }}
{{ login_form.user(class='validate') }} {{ M.render_field(login_form.password, material_icon='vpn_key') }}
{{ login_form.user.label }}
{% for error in login_form.user.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ login_form.password(class='validate') }}
{{ login_form.password.label }}
{% for error in login_form.password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="row" style="margin-bottom: 0;"> <div class="row" style="margin-bottom: 0;">
<div class="col s6 left-align"> <div class="col s6 left-align">
<a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a> <a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a>
</div> </div>
<div class="col s6 right-align"> <div class="col s6 right-align">
<div class="switch"> {{ M.render_field(login_form.remember_me) }}
<label>
Remember me
{{ login_form.remember_me(class='validate') }}
<span class="lever"></span>
</label>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(login_form.submit) }} {{ M.render_field(login_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -24,43 +24,15 @@
<div class="col s12 m8"> <div class="col s12 m8">
<div class="card medium"> <div class="card medium">
<form method="POST"> <form method="POST">
{{ registration_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field"> {{ registration_form.hidden_tag() }}
<i class="material-icons prefix">person</i> {{ M.render_field(registration_form.username, data_length='64', material_icon='person') }}
{{ registration_form.username(class='validate', data_length='64') }} {{ M.render_field(registration_form.password, data_length='128', material_icon='vpn_key') }}
{{ registration_form.username.label }} {{ M.render_field(registration_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
{% for error in registration_form.username.errors %} {{ M.render_field(registration_form.email, class_='validate', material_icon='email', type='email') }}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ registration_form.password(class='validate') }}
{{ registration_form.password.label }}
{% for error in registration_form.password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ registration_form.password_confirmation(class='validate') }}
{{ registration_form.password_confirmation.label }}
{% for error in registration_form.password_confirmation.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">email</i>
{{ registration_form.email(class='validate', type='email') }}
{{ registration_form.email.label }}
{% for error in registration_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(registration_form.submit) }} {{ M.render_field(registration_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -9,25 +9,13 @@
<div class="col s12 m8"> <div class="col s12 m8">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ reset_password_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field"> {{ reset_password_form.hidden_tag() }}
{{ reset_password_form.password(class='validate') }} {{ M.render_field(reset_password_form.password, data_length='128') }}
{{ reset_password_form.password.label }} {{ M.render_field(reset_password_form.password_confirmation, data_length='128') }}
{% for error in reset_password_form.password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
{{ reset_password_form.password_confirmation(class='validate') }}
{{ reset_password_form.password_confirmation.label }}
{% for error in reset_password_form.password_confirmation.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(reset_password_form.submit) }} {{ M.render_field(reset_password_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -8,18 +8,12 @@
<div class="col s12 m8"> <div class="col s12 m8">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ reset_password_request_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field"> {{ reset_password_request_form.hidden_tag() }}
{{ reset_password_request_form.email(class='validate', type='email') }} {{ M.render_field(reset_password_request_form.email, class_='validate', material_icon='email', type='email') }}
{{ reset_password_request_form.email.label }}
{% for error in reset_password_request_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(reset_password_request_form.submit) }} {{ M.render_field(reset_password_request_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -9,33 +9,19 @@
<div class="col s12 m8"> <div class="col s12 m8">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ add_corpus_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
{{ add_corpus_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(add_corpus_form.title, data_length='32', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ add_corpus_form.title(data_length='32') }}
{{ add_corpus_form.title.label }}
{% for error in add_corpus_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 m8"> <div class="col s12 m8">
<div class="input-field"> {{ M.render_field(add_corpus_form.description, data_length='255', material_icon='description') }}
<i class="material-icons prefix">description</i>
{{ add_corpus_form.description(data_length='255') }}
{{ add_corpus_form.description.label }}
{% for error in add_corpus_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(add_corpus_form.submit) }} {{ M.render_field(add_corpus_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -9,59 +9,27 @@
<div class="col s12 m8"> <div class="col s12 m8">
<form class="nopaque-submit-form" data-progress-modal="progress-modal"> <form class="nopaque-submit-form" data-progress-modal="progress-modal">
{{ add_corpus_file_form.hidden_tag() }}
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<span class="card-title">Required metadata</span> <span class="card-title">Required metadata</span>
{{ add_corpus_file_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(add_corpus_file_form.author, data_length='255', material_icon='person') }}
<i class="material-icons prefix">person</i>
{{ add_corpus_file_form.author(data_length='255') }}
{{ add_corpus_file_form.author.label }}
{% for error in add_corpus_file_form.author.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(add_corpus_file_form.title, data_length='255', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ add_corpus_file_form.title(data_length='255') }}
{{ add_corpus_file_form.title.label }}
{% for error in add_corpus_file_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(add_corpus_file_form.publishing_year, material_icon='access_time') }}
<i class="material-icons prefix">access_time</i>
{{ add_corpus_file_form.publishing_year() }}
{{ add_corpus_file_form.publishing_year.label }}
{% for error in add_corpus_file_form.publishing_year.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12"> <div class="col s12">
<div class="file-field input-field"> {{ M.render_field(add_corpus_file_form.file, accept='.vrt') }}
<div class="btn">
<span>{{ add_corpus_file_form.file.label.text }}</span>
{{ add_corpus_file_form.file(accept='.vrt') }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
{% for error in add_corpus_file_form.file.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(add_corpus_file_form.submit) }} {{ M.render_field(add_corpus_file_form.submit, material_icon='send') }}
</div> </div>
</div> </div>
<br> <br>
@ -69,8 +37,9 @@
<li> <li>
<div class="collapsible-header"><i class="material-icons">add</i>Add additional metadata</div> <div class="collapsible-header"><i class="material-icons">add</i>Add additional metadata</div>
<div class="collapsible-body"> <div class="collapsible-body">
{% for field in add_corpus_file_form if not (field.name.endswith(('author', 'csrf_token', 'file', 'publishing_year', 'submit', 'title'))) %} {% for field in add_corpus_file_form
{{ macros.render_field(field)}} if field.short_name not in ['author', 'csrf_token', 'file', 'publishing_year', 'submit', 'title'] %}
{{ M.render_field(field, data_length='255', material_icon=field.label.text[0:1]) }}
{% endfor %} {% endfor %}
</div> </div>
</li> </li>
@ -95,7 +64,7 @@
<div id="progress-modal" class="modal"> <div id="progress-modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<h4><i class="material-icons prefix">file_upload</i> Uploading files for <span class="title"></span></h4> <h4><i class="material-icons prefix">file_upload</i> Uploading file...</h4>
<div class="progress"> <div class="progress">
<div class="determinate" style="width: 0%"></div> <div class="determinate" style="width: 0%"></div>
</div> </div>

View File

@ -34,7 +34,7 @@
</div> </div>
<div class="col s12 m2"> <div class="col s12 m2">
<br class="hide-on-small-only"> <br class="hide-on-small-only">
{{ macros.submit_button(query_form.submit) }} {{ M.render_field(query_form.submit, material_icon='send') }}
</div> </div>
</div> </div>
</form> </form>
@ -49,27 +49,13 @@
<form id="display-options-form"> <form id="display-options-form">
<div class="row"> <div class="row">
<div class="col s12 m6"> <div class="col s12 m6">
<div class="input-field"> {{ M.render_field(display_options_form.results_per_page, material_icon='format_list_numbered') }}
<i class="material-icons prefix">format_list_numbered</i>
{{ display_options_form.results_per_page() }}
{{ display_options_form.results_per_page.label }}
</div>
</div> </div>
<div class="col s12 m6"> <div class="col s12 m6">
<div class="input-field"> {{ M.render_field(display_options_form.result_context, material_icon='short_text') }}
<i class="material-icons prefix">short_text</i>
{{ display_options_form.result_context() }}
{{ display_options_form.result_context.label }}
</div>
</div> </div>
<div class="col s12"> <div class="col s12">
<div class="switch"> {{ M.render_field(display_options_form.expert_mode) }}
<label>
{{ display_options_form.expert_mode.label.text }}
{{ display_options_form.expert_mode() }}
<span class="lever"></span>
</label>
</div>
</div> </div>
</div> </div>
</form> </form>
@ -152,7 +138,6 @@
<div id="query-results-download-modal" <div id="query-results-download-modal"
class="modal modal-fixed-footer no-autoinit"> class="modal modal-fixed-footer no-autoinit">
<div class="modal-content"> <div class="modal-content">
{{ query_download_form.hidden_tag() }}
<h4>Download current query Results</h4> <h4>Download current query Results</h4>
<p>The results of the current query can be downlaoded as several files like csv or json. Those files can be used in other software like excel. Also it is easy to publish your results as raw data like this!</p> <p>The results of the current query can be downlaoded as several files like csv or json. Those files can be used in other software like excel. Also it is easy to publish your results as raw data like this!</p>
<table> <table>

View File

@ -4,7 +4,7 @@
<div class="col s12 m4"> <div class="col s12 m4">
<h3 id="title">...</h3> <h3 id="title">...</h3>
<p id="description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et</p> <p id="description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et</p>
<a class="btn waves-effect waves-light" href="{{ url_for('corpora.corpus', corpus_id=corpus_file.corpus.id) }}"><i class="material-icons left">arrow_back</i>Back to corpus</a> <a class="btn waves-effect waves-light" href="{{ url_for('corpora.corpus', corpus_id=corpus.id) }}"><i class="material-icons left">arrow_back</i>Back to corpus</a>
</div> </div>
<div class="col s12 m8"> <div class="col s12 m8">
@ -14,39 +14,18 @@
<div class="card-content"> <div class="card-content">
<div class="row"> <div class="row">
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(edit_corpus_file_form.author, data_length='255', material_icon='person') }}
<i class="material-icons prefix">person</i>
{{ edit_corpus_file_form.author(data_length='255', value=corpus_file.author) }}
{{ edit_corpus_file_form.author.label }}
{% for error in edit_corpus_file_form.author.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(edit_corpus_file_form.title, data_length='255', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ edit_corpus_file_form.title(data_length='255', value=corpus_file.title) }}
{{ edit_corpus_file_form.title.label }}
{% for error in edit_corpus_file_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 m4"> <div class="col s12 m4">
<div class="input-field"> {{ M.render_field(edit_corpus_file_form.publishing_year, material_icon='access_time') }}
<i class="material-icons prefix">access_time</i>
{{ edit_corpus_file_form.publishing_year(value=corpus_file.publishing_year) }}
{{ edit_corpus_file_form.publishing_year.label }}
{% for error in edit_corpus_file_form.publishing_year.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(edit_corpus_file_form.submit) }} {{ M.render_field(edit_corpus_file_form.submit, material_icon='send') }}
</div> </div>
</div> </div>
<br> <br>
@ -54,21 +33,11 @@
<li> <li>
<div class="collapsible-header"><i class="material-icons">edit</i>Edit additional metadata</div> <div class="collapsible-header"><i class="material-icons">edit</i>Edit additional metadata</div>
<div class="collapsible-body"> <div class="collapsible-body">
<span> {% for field in edit_corpus_file_form
<div class="row"> if field.short_name not in ['author', 'csrf_token', 'publishing_year', 'submit', 'title'] %}
<div class="col s12"> {{ M.render_field(field) }}
{% for field in edit_corpus_file_form if not (field.name == "file"
or field.name == "author"
or field.name == "submit"
or field.name == "csrf_token"
or field.name == "title"
or field.name == "publishing_year") %}
{{ macros.render_field_with_value(field, corpus_file)}}
{% endfor %} {% endfor %}
</div> </div>
</div>
</span>
</div>
</li> </li>
</ul> </ul>
</form> </form>

View File

@ -1,30 +0,0 @@
{% macro render_field(field) %}
<div class="input-field">
<i class="prefix">{{ field.label.text[0:1]|upper }}</i>
{{ field.label }}
{{ field(data_length='255')|safe }}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
{% endmacro %}
{% macro render_field_with_value(field, corpus_file) %}
<div class="input-field">
<i class="prefix">{{ field.label.text[0:1]|upper }}</i>
{{ field.label }}
{{ field(value=corpus_file[field.name], data_length='255')| safe }}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
{% endmacro %}
{% macro submit_button(input) %}
<button class="btn waves-effect waves-light" id="{{ input.id }}" name="{{ input.name }}" type="submit" value="{{ input.label.text }}">
{{ input.label.text }}
<i class="material-icons right">send</i>
</button>
{% endmacro %}

View File

@ -0,0 +1,69 @@
{% macro render_field(field) %}
{% if field.type == 'BooleanField' %}
{{ render_boolean_field(field, *args, **kwargs) }}
{% elif field.type == 'SubmitField' %}
{{ render_submit_field(field, *args, **kwargs) }}
{% elif field.type in ['FileField', 'MultipleFileField'] %}
{{ render_file_field(field, *args, **kwargs) }}
{% elif field.type in ['IntegerField', 'PasswordField', 'SelectField', 'StringField'] %}
{{ render_generic_field(field, *args, **kwargs) }}
{% endif %}
{% endmacro %}
{% macro render_boolean_field(field) %}
<div class="switch">
{% if 'material_icon' in kwargs %}
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
{% endif %}
<label>
{{ field.label.text }}
{{ field() }}
<span class="lever"></span>
</label>
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
{% endmacro %}
{% macro render_file_field(field) %}
<div class="file-field input-field">
<div class="btn">
<span>{{ field.label.text }}</span>
{{ field(**kwargs) }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
{% endmacro %}
{% macro render_generic_field(field) %}
{% if field.type == 'IntegerField' %}
{% set tmp = kwargs.update({'type': 'number'}) %}
{% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %}
{% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %}
{% else %}
{% set tmp = kwargs.update({'class_': 'validate'}) %}
{% endif %}
{% endif %}
<div class="input-field">
{% if 'material_icon' in kwargs %}
<i class="material-icons prefix">{{ kwargs.pop('material_icon') }}</i>
{% endif %}
{{ field(**kwargs) }}
{{ field.label }}
{% for error in field.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
{% endmacro %}
{% macro render_submit_field(field) %}
<button class="btn waves-effect waves-light" id="{{ field.id }}" name="{{ field.name }}" type="submit" value="{{ field.label.text }}">
{{ field.label.text }}
{% if 'material_icon' in kwargs %}
<i class="material-icons right">{{ kwargs.pop('material_icon') }}</i>
{% endif %}
</button>
{% endmacro %}

View File

@ -26,7 +26,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(feedback_form.submit) }} {{ M.render_field(feedback_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -145,39 +145,19 @@
<div class="card-content"> <div class="card-content">
<span class="card-title">Log in</span> <span class="card-title">Log in</span>
{{ login_form.hidden_tag() }} {{ login_form.hidden_tag() }}
<div class="input-field"> {{ M.render_field(login_form.user, material_icon='person') }}
<i class="material-icons prefix">person</i> {{ M.render_field(login_form.password, material_icon='vpn_key') }}
{{ login_form.user(class='validate') }}
{{ login_form.user.label }}
{% for error in login_form.user.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ login_form.password(class='validate') }}
{{ login_form.password.label }}
{% for error in login_form.password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="row" style="margin-bottom: 0;"> <div class="row" style="margin-bottom: 0;">
<div class="col s6 left-align"> <div class="col s6 left-align">
<a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a> <a href="{{ url_for('auth.reset_password_request') }}">Forgot your password?</a>
</div> </div>
<div class="col s6 right-align"> <div class="col s6 right-align">
<div class="switch"> {{ M.render_field(login_form.remember_me) }}
<label>
Remember me
{{ login_form.remember_me() }}
<span class="lever"></span>
</label>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(login_form.submit) }} {{ M.render_field(login_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -187,7 +187,7 @@
<a href="{{ url_for('auth.reset_password_request') }}">No account yet?</a> <a href="{{ url_for('auth.reset_password_request') }}">No account yet?</a>
</div> </div>
<div class="col s6 right-align"> <div class="col s6 right-align">
{{ macros.submit_button(login_form.submit) }} {{ materialize.submit_button(login_form.submit) }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
{% import "macros.jinja" as macros %} {% import "macros/materialize.html.j2" as M %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@ -8,8 +8,8 @@
<br class="hide-on-small-only"> <br class="hide-on-small-only">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ edit_general_settings_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
{{ edit_general_settings_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s9"> <div class="col s9">
<p><i class="material-icons left">brightness_3</i>{{ edit_general_settings_form.dark_mode.label.text }}</p> <p><i class="material-icons left">brightness_3</i>{{ edit_general_settings_form.dark_mode.label.text }}</p>
@ -46,7 +46,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(edit_general_settings_form.save_settings) }} {{ M.render_field(edit_general_settings_form.save_settings, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>
@ -63,35 +63,14 @@
<br class="hide-on-small-only"> <br class="hide-on-small-only">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ edit_password_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field "> {{ edit_password_form.hidden_tag() }}
<i class="material-icons prefix">vpn_key</i> {{ M.render_field(edit_password_form.current_password, data_length='128', material_icon='vpn_key') }}
{{ edit_password_form.current_password() }} {{ M.render_field(edit_password_form.password, data_length='128', material_icon='vpn_key') }}
{{ edit_password_form.current_password.label }} {{ M.render_field(edit_password_form.password_confirmation, data_length='128', material_icon='vpn_key') }}
{% for error in edit_password_form.current_password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ edit_password_form.password() }}
{{ edit_password_form.password.label }}
{% for error in edit_password_form.password.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
<div class="input-field">
<i class="material-icons prefix">vpn_key</i>
{{ edit_password_form.password_confirmation() }}
{{ edit_password_form.password_confirmation.label }}
{% for error in edit_password_form.password_confirmation.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(edit_password_form.save_password) }} {{ M.render_field(edit_password_form.save_password, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>
@ -108,19 +87,12 @@
<br class="hide-on-small-only"> <br class="hide-on-small-only">
<div class="card"> <div class="card">
<form method="POST"> <form method="POST">
{{ edit_email_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
<div class="input-field"> {{ edit_email_form.hidden_tag() }}
<i class="material-icons prefix">mail</i> {{ M.render_field(edit_email_form.email, class_='validate', material_icon='email', type='email') }}
{{ edit_email_form.email() }}
{{ edit_email_form.email.label }}
{% for error in edit_email_form.email.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(edit_email_form.save_email) }} {{ M.render_field(edit_email_form.save_email, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>

View File

@ -26,57 +26,25 @@
<h3>Submit a job</h3> <h3>Submit a job</h3>
<div class="card"> <div class="card">
<form class="nopaque-submit-form" data-progress-modal="progress-modal"> <form class="nopaque-submit-form" data-progress-modal="progress-modal">
{{ add_job_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
{{ add_job_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s12 l4"> <div class="col s12 l4">
<div class="input-field"> {{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ add_job_form.title(data_length='32') }}
{{ add_job_form.title.label }}
{% for error in add_job_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 l8"> <div class="col s12 l8">
<div class="input-field"> {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
<i class="material-icons prefix">description</i>
{{ add_job_form.description(data_length='255') }}
{{ add_job_form.description.label }}
{% for error in add_job_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12"> <div class="col s12">
<div class="file-field input-field"> {{ M.render_field(add_job_form.files, accept='image/jpeg, image/png, image/tiff') }}
<div class="btn">
<span>{{ add_job_form.files.label.text }}</span>
{{ add_job_form.files(accept='image/jpeg, image/png, image/tiff') }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
{% for error in add_job_form.files.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 hide"> <div class="col s12 hide">
<div class="input-field"> {{ M.render_field(add_job_form.version, material_icon='apps') }}
<i class="material-icons prefix">apps</i>
{{ add_job_form.version() }}
{{ add_job_form.version.label }}
{% for error in add_job_form.version.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(add_job_form.submit) }} {{ M.render_field(add_job_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>
@ -84,7 +52,7 @@
<div id="progress-modal" class="modal"> <div id="progress-modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<h4><i class="material-icons prefix">file_upload</i> Uploading files for <span class="title"></span></h4> <h4><i class="material-icons prefix">file_upload</i> Uploading files...</h4>
<div class="progress"> <div class="progress">
<div class="determinate" style="width: 0%"></div> <div class="determinate" style="width: 0%"></div>
</div> </div>

View File

@ -44,64 +44,23 @@
<h3>Submit a job</h3> <h3>Submit a job</h3>
<div class="card"> <div class="card">
<form class="nopaque-submit-form" data-progress-modal="progress-modal"> <form class="nopaque-submit-form" data-progress-modal="progress-modal">
{{ add_job_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
{{ add_job_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s12 l4"> <div class="col s12 l4">
<div class="input-field"> {{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ add_job_form.title(data_length='32') }}
{{ add_job_form.title.label }}
{% for error in add_job_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div> </div>
<div class="col s12 l8">
{{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
</div>
<div class="col s12 l5">
{{ M.render_field(add_job_form.files, accept='text/plain') }}
</div> </div>
<div class="col s12 l4"> <div class="col s12 l4">
<div class="input-field"> {{ M.render_field(add_job_form.language, material_icon='language') }}
<i class="material-icons prefix">language</i>
{{ add_job_form.language() }}
{{ add_job_form.language.label }}
{% for error in add_job_form.language.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div>
<div class="col s12 l4">
<div class="input-field">
<i class="material-icons prefix">language</i>
{{ add_job_form.version() }}
{{ add_job_form.version.label }}
{% for error in add_job_form.version.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div>
</div>
<div class="row">
<div class="col s12 l6">
<div class="file-field input-field">
<div class="btn">
<span>{{ add_job_form.files.label.text }}</span>
{{ add_job_form.files(accept='text/plain') }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
{% for error in add_job_form.files.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div>
<div class="col s12 l6">
<div class="input-field">
<i class="material-icons prefix">description</i>
{{ add_job_form.description(data_length='255') }}
{{ add_job_form.description.label }}
{% for error in add_job_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div> </div>
<div class="col s12 l3">
{{ M.render_field(add_job_form.version, material_icon='apps') }}
</div> </div>
<div class="col s12"> <div class="col s12">
<span class="card-title">Preprocessing</span> <span class="card-title">Preprocessing</span>
@ -127,7 +86,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(add_job_form.submit) }} {{ M.render_field(add_job_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>
@ -135,7 +94,7 @@
<div id="progress-modal" class="modal"> <div id="progress-modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<h4><i class="material-icons prefix">file_upload</i> Uploading files for <span class="title"></span></h4> <h4><i class="material-icons prefix">file_upload</i> Uploading files...</h4>
<div class="progress"> <div class="progress">
<div class="determinate" style="width: 0%"></div> <div class="determinate" style="width: 0%"></div>
</div> </div>

View File

@ -26,62 +26,23 @@
<h3>Submit a job</h3> <h3>Submit a job</h3>
<div class="card"> <div class="card">
<form class="nopaque-submit-form" data-progress-modal="progress-modal"> <form class="nopaque-submit-form" data-progress-modal="progress-modal">
{{ add_job_form.hidden_tag() }}
<div class="card-content"> <div class="card-content">
{{ add_job_form.hidden_tag() }}
<div class="row"> <div class="row">
<div class="col s12 l4"> <div class="col s12 l4">
<div class="input-field"> {{ M.render_field(add_job_form.title, data_length='32', material_icon='title') }}
<i class="material-icons prefix">title</i>
{{ add_job_form.title(class="validate", data_length='32') }}
{{ add_job_form.title.label }}
{% for error in add_job_form.title.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 l8"> <div class="col s12 l8">
<div class="input-field"> {{ M.render_field(add_job_form.description, data_length='255', material_icon='description') }}
<i class="material-icons prefix">description</i>
{{ add_job_form.description(class="validate", data_length='255') }}
{{ add_job_form.description.label }}
{% for error in add_job_form.description.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 l5"> <div class="col s12 l5">
<div class="file-field input-field"> {{ M.render_field(add_job_form.files, accept='application/pdf') }}
<div class="btn">
<span>{{ add_job_form.files.label.text }}</span>
{{ add_job_form.files(accept='application/pdf') }}
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
{% for error in add_job_form.files.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 l4"> <div class="col s12 l4">
<div class="input-field"> {{ M.render_field(add_job_form.language, material_icon='language') }}
<i class="material-icons prefix">language</i>
{{ add_job_form.language(class="validate") }}
{{ add_job_form.language.label }}
{% for error in add_job_form.language.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12 l3"> <div class="col s12 l3">
<div class="input-field"> {{ M.render_field(add_job_form.version, material_icon='apps') }}
<i class="material-icons prefix">apps</i>
{{ add_job_form.version(class="validate") }}
{{ add_job_form.version.label }}
{% for error in add_job_form.version.errors %}
<span class="helper-text red-text">{{ error }}</span>
{% endfor %}
</div>
</div> </div>
<div class="col s12"> <div class="col s12">
<span class="card-title">Preprocessing</span> <span class="card-title">Preprocessing</span>
@ -152,7 +113,7 @@
</div> </div>
</div> </div>
<div class="card-action right-align"> <div class="card-action right-align">
{{ macros.submit_button(add_job_form.submit) }} {{ M.render_field(add_job_form.submit, material_icon='send') }}
</div> </div>
</form> </form>
</div> </div>
@ -160,7 +121,7 @@
<div id="progress-modal" class="modal"> <div id="progress-modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<h4><i class="material-icons left">file_upload</i>Uploading files for <span class="title"></span></h4> <h4><i class="material-icons left">file_upload</i>Uploading files...</h4>
<div class="progress"> <div class="progress">
<div class="determinate" style="width: 0%"></div> <div class="determinate" style="width: 0%"></div>
</div> </div>