mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Code enhancement
This commit is contained in:
parent
f22bff4ed0
commit
aacfe40bd6
@ -10,10 +10,10 @@ from . import admin
|
||||
from .forms import EditProfileAdminForm
|
||||
|
||||
|
||||
@admin.route('/board')
|
||||
@admin.route('/')
|
||||
@login_required
|
||||
@admin_required
|
||||
def board():
|
||||
def index():
|
||||
users = User.query.all()
|
||||
items = [AdminUserItem(u.username, u.email, u.role_id, u.confirmed, u.id)
|
||||
for u in users]
|
||||
@ -21,8 +21,8 @@ def board():
|
||||
table = AdminUserTable(items).__html__()
|
||||
# Add class "list" to tbody element. Needed for "List.js"
|
||||
table = table.replace('tbody', 'tbody class="list"', 1)
|
||||
return render_template('admin/board.html.j2', table=table,
|
||||
title='Admin board')
|
||||
return render_template('admin/index.html.j2', table=table,
|
||||
title='Administration tools')
|
||||
|
||||
|
||||
@admin.route('/user/<int:user_id>')
|
||||
@ -30,7 +30,7 @@ def board():
|
||||
@admin_required
|
||||
def user(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
return render_template('admin/user.html.j2', title='Administrate user',
|
||||
return render_template('admin/user.html.j2', title='Administration: User',
|
||||
user=user)
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ def delete_user(user_id):
|
||||
args=(current_app._get_current_object(), user.id))
|
||||
thread.start()
|
||||
flash('User has been deleted!')
|
||||
return redirect(url_for('admin.board'))
|
||||
return redirect(url_for('admin.index'))
|
||||
|
||||
|
||||
@admin.route('/user/<int:user_id>/edit', methods=['GET', 'POST'])
|
||||
@ -66,4 +66,4 @@ def edit_user(user_id):
|
||||
form.confirmed.data = user.confirmed
|
||||
form.role.data = user.role_id
|
||||
return render_template('admin/edit_user.html.j2', form=form,
|
||||
title='Edit user', user=user)
|
||||
title='Administration: Edit user', user=user)
|
||||
|
@ -91,16 +91,14 @@ def add_corpus_file(corpus_id):
|
||||
for corpus_file in corpus.files:
|
||||
if filename == corpus_file.filename:
|
||||
flash('File already registered to this corpus.')
|
||||
return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
||||
return redirect(url_for('corpora.add_corpus_file',
|
||||
corpus_id=corpus_id))
|
||||
# Save the file
|
||||
dir = os.path.join(str(corpus.user_id), 'corpora', str(corpus.id))
|
||||
file.save(os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||
dir, filename))
|
||||
|
||||
corpus_file = CorpusFile(author=add_corpus_file_form.author.data,
|
||||
corpus=corpus,
|
||||
dir=dir,
|
||||
filename=filename,
|
||||
corpus=corpus, dir=dir, filename=filename,
|
||||
publishing_year=add_corpus_file_form.publishing_year.data,
|
||||
title=add_corpus_file_form.title.data)
|
||||
db.session.add(corpus_file)
|
||||
|
@ -1,10 +1,10 @@
|
||||
from app import db, logger
|
||||
from flask import abort, current_app, flash, redirect, render_template, url_for
|
||||
from flask_login import current_user, login_required, logout_user
|
||||
from threading import Thread
|
||||
from . import profile
|
||||
from .background_functions import delete_user_
|
||||
from .forms import ChangePasswordForm, EditProfileForm, EditUserSettingsForm
|
||||
import threading
|
||||
|
||||
|
||||
@profile.route('/', methods=['GET', 'POST'])
|
||||
@ -94,10 +94,9 @@ def delete_self():
|
||||
"""
|
||||
View to delete yourslef and all associated data.
|
||||
"""
|
||||
delete_thread = threading.Thread(target=delete_user_,
|
||||
args=(current_app._get_current_object(),
|
||||
current_user.id))
|
||||
delete_thread.start()
|
||||
thread = Thread(target=delete_user_,
|
||||
args=(current_app._get_current_object(), current_user.id))
|
||||
thread.start()
|
||||
logout_user()
|
||||
flash('Your account has been deleted!')
|
||||
return redirect(url_for('main.index'))
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="col s12 m4">
|
||||
<h3 id="title">{{ user.username }}</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 justo duo dolores et ea rebum. Stet clita kasd gubergren,</p>
|
||||
<a class="waves-effect waves-light btn" href="{{ url_for('admin.board') }}"><i class="material-icons left">arrow_back</i>Back to admin board</a>
|
||||
<a class="waves-effect waves-light btn" href="{{ url_for('admin.index') }}"><i class="material-icons left">arrow_back</i>Back to admin board</a>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m8">
|
||||
|
@ -140,7 +140,7 @@
|
||||
{% if current_user.is_administrator() %}
|
||||
<li><div class="divider"></div></li>
|
||||
<li><a class="subheader">Administration</a></li>
|
||||
<li><a href="{{ url_for('admin.board') }}"><i class="material-icons">build</i>Administration tools</a></li>
|
||||
<li><a href="{{ url_for('admin.index') }}"><i class="material-icons">build</i>Administration tools</a></li>
|
||||
{% endif %}
|
||||
<div class="hide-on-large-only">
|
||||
<li><div class="divider"></div></li>
|
||||
|
Loading…
Reference in New Issue
Block a user