mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Use links as list items for corpora and jobs. Add colors for service types. Link jobs to job page.
This commit is contained in:
parent
136f2ee2b2
commit
50273ea4d1
@ -1,6 +1,6 @@
|
||||
from flask import current_app, flash, redirect, render_template, url_for
|
||||
from flask import abort, current_app, flash, redirect, render_template, url_for
|
||||
from flask_login import current_user, login_required
|
||||
from ..models import User, Corpus
|
||||
from ..models import Corpus, User, Job
|
||||
from ..tables import AdminUserTable, AdminUserItem
|
||||
from . import main
|
||||
from .forms import CreateCorpusForm
|
||||
@ -14,9 +14,16 @@ def index():
|
||||
return render_template('main/index.html.j2', title='Opaque')
|
||||
|
||||
|
||||
@main.route('/corpora/<corpus>')
|
||||
def corpora(corpus):
|
||||
return render_template('main/corpus.html.j2', title=corpus)
|
||||
@main.route('/admin', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def for_admins_only():
|
||||
users = User.query.order_by(User.username).all()
|
||||
items = [AdminUserItem(u.username, u.email, u.role_id, u.confirmed) for u in users]
|
||||
table = AdminUserTable(items).__html__() # converts table object to html string
|
||||
table = table.replace('tbody', 'tbody class="list"', 1) # add class list to tbody element. Needed by list.js
|
||||
return render_template('main/admin.html.j2', title='Administration tools',
|
||||
table=table)
|
||||
|
||||
|
||||
@main.route('/dashboard', methods=['GET', 'POST'])
|
||||
@ -54,13 +61,15 @@ def dashboard():
|
||||
)
|
||||
|
||||
|
||||
@main.route('/admin', methods=['GET', 'POST'])
|
||||
@main.route('/jobs/<int:job_id>')
|
||||
@login_required
|
||||
@admin_required
|
||||
def for_admins_only():
|
||||
users = User.query.order_by(User.username).all()
|
||||
items = [AdminUserItem(u.username, u.email, u.role_id, u.confirmed) for u in users]
|
||||
table = AdminUserTable(items).__html__() # converts table object to html string
|
||||
table = table.replace('tbody', 'tbody class="list"', 1) # add class list to tbody element. Needed by list.js
|
||||
return render_template('main/admin.html.j2', title='Administration tools',
|
||||
table=table)
|
||||
def job(job_id):
|
||||
job = Job.query.filter_by(id=job_id).first()
|
||||
if not job:
|
||||
print('Job not found.')
|
||||
abort(404)
|
||||
elif not job.user_id == current_user.id:
|
||||
print('Job does not belong to current user.')
|
||||
abort(403)
|
||||
print(job)
|
||||
return render_template('main/corpus.html.j2', title=job.title)
|
||||
|
@ -27,16 +27,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="collection list">
|
||||
<div class="collection list">
|
||||
{% for corpus in current_user.corpora.all() %}
|
||||
<li class="collection-item avatar">
|
||||
<a href="#!" class="collection-item avatar">
|
||||
<i class="material-icons circle">book</i>
|
||||
<span class="title">{{ corpus.title }}</span>
|
||||
<p>{{ corpus.description }}</p>
|
||||
<a href="#!" class="secondary-content"><i class="material-icons">send</i></a>
|
||||
</li>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
@ -78,13 +77,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="collection list">
|
||||
<div class="collection list">
|
||||
{% for job in current_user.jobs.all() %}
|
||||
{% if job.service == 'nlp' %}
|
||||
{% set service_color = 'blue' %}
|
||||
{% set service_icon = 'format_textdirection_l_to_r' %}
|
||||
{% elif job.service =='ocr' %}
|
||||
{% set service_color = 'green' %}
|
||||
{% set service_icon = 'find_in_page' %}
|
||||
{% else %}
|
||||
{% set service_color = 'red' %}
|
||||
{% set service_icon = 'help' %}
|
||||
{% endif %}
|
||||
{% if job.status == 'pending' %}
|
||||
@ -96,14 +98,14 @@
|
||||
{% else %}
|
||||
{% set badge_color = 'red' %}
|
||||
{% endif %}
|
||||
<li class="collection-item avatar">
|
||||
<i class="material-icons circle">{{ service_icon }}</i>
|
||||
<a href="{{ url_for('main.job', job_id=job.id) }}" class="collection-item avatar">
|
||||
<i class="material-icons circle {{ service_color }}">{{ service_icon }}</i>
|
||||
<span class="new badge {{ badge_color }}" data-badge-caption="">{{ job.status }}</span>
|
||||
<span class="title">{{ job.title }}</span>
|
||||
<p>{{ job.description }}</p>
|
||||
</li>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
Loading…
Reference in New Issue
Block a user