mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user