mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Update background functions
This commit is contained in:
parent
7dd55c47a0
commit
1b02d73d66
@ -2,7 +2,7 @@ from app import db
|
||||
from app.decorators import admin_required
|
||||
from app.models import Role, User
|
||||
from app.tables import AdminUserItem, AdminUserTable
|
||||
from app.background_functions import delete_user_
|
||||
from app.profile.background_functions import delete_user_
|
||||
from flask import current_app, flash, redirect, render_template, url_for
|
||||
from flask_login import login_required
|
||||
from . import admin
|
||||
@ -31,7 +31,7 @@ def for_admins_only():
|
||||
@login_required
|
||||
@admin_required
|
||||
def admin_user_page(user_id):
|
||||
selected_user = User.query.filter_by(id=user_id).first()
|
||||
selected_user = User.query.get_or_404(user_id)
|
||||
title = 'Administration of user {} with ID: {}'.format(
|
||||
selected_user.username,
|
||||
selected_user.id
|
||||
|
@ -41,15 +41,15 @@ def logout():
|
||||
def register():
|
||||
if not current_user.is_anonymous:
|
||||
return redirect(url_for('main.dashboard'))
|
||||
form = RegistrationForm()
|
||||
if form.validate_on_submit():
|
||||
user = User(email=form.email.data.lower(),
|
||||
password=form.password.data,
|
||||
username=form.username.data)
|
||||
registration_form = RegistrationForm()
|
||||
if registration_form.validate_on_submit():
|
||||
user = User(email=registration_form.email.data.lower(),
|
||||
password=registration_form.password.data,
|
||||
username=registration_form.username.data)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
|
||||
str(job.user_id), 'jobs', str(job.id))
|
||||
str(user.id))
|
||||
try:
|
||||
os.makedirs(dir)
|
||||
except OSError:
|
||||
@ -57,15 +57,11 @@ def register():
|
||||
user.delete()
|
||||
else:
|
||||
token = user.generate_confirmation_token()
|
||||
send_email(user.email,
|
||||
'Confirm Your Account',
|
||||
'auth/email/confirm',
|
||||
token=token,
|
||||
user=user)
|
||||
send_email(user.email, 'Confirm Your Account',
|
||||
'auth/email/confirm', token=token, user=user)
|
||||
flash('A confirmation email has been sent to you by email.')
|
||||
return redirect(url_for('auth.login'))
|
||||
return render_template('auth/register.html.j2',
|
||||
form=form,
|
||||
return render_template('auth/register.html.j2', form=registration_form,
|
||||
title='Register')
|
||||
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
from .models import Corpus, Job, User
|
||||
|
||||
|
||||
def delete_corpus_(app, corpus_id):
|
||||
with app.app_context():
|
||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||
if corpus is None:
|
||||
raise Exception('Corpus {} not found!'.format(corpus_id))
|
||||
corpus.delete()
|
||||
|
||||
|
||||
def delete_job_(app, job_id):
|
||||
with app.app_context():
|
||||
job = Job.query.filter_by(id=job_id).first()
|
||||
if job is None:
|
||||
raise Exception('Job {} not found!'.format(job_id))
|
||||
job.delete()
|
||||
|
||||
|
||||
def delete_user_(app, user_id):
|
||||
with app.app_context():
|
||||
user = User.query.filter_by(id=user_id).first()
|
||||
if user is None:
|
||||
raise Exception('User {} not found!'.format(user_id))
|
||||
user.delete()
|
9
app/jobs/background_functions.py
Normal file
9
app/jobs/background_functions.py
Normal file
@ -0,0 +1,9 @@
|
||||
from app.models import Job
|
||||
|
||||
|
||||
def delete_job_(app, job_id):
|
||||
with app.app_context():
|
||||
job = Job.query.filter_by(id=job_id).first()
|
||||
if job is None:
|
||||
raise Exception('Job {} not found!'.format(job_id))
|
||||
job.delete()
|
@ -1,9 +1,9 @@
|
||||
from app.models import Job, JobInput, JobResult
|
||||
from app.background_functions import delete_job_
|
||||
from flask import (abort, current_app, flash, redirect, render_template,
|
||||
send_from_directory, url_for)
|
||||
from flask_login import current_user, login_required
|
||||
from . import jobs
|
||||
from .background_functions import delete_job_
|
||||
import os
|
||||
import threading
|
||||
|
||||
|
9
app/profile/background_functions.py
Normal file
9
app/profile/background_functions.py
Normal file
@ -0,0 +1,9 @@
|
||||
from app.models import User
|
||||
|
||||
|
||||
def delete_user_(app, user_id):
|
||||
with app.app_context():
|
||||
user = User.query.filter_by(id=user_id).first()
|
||||
if user is None:
|
||||
raise Exception('User {} not found!'.format(user_id))
|
||||
user.delete()
|
@ -1,8 +1,8 @@
|
||||
from app import db, logger
|
||||
from app.background_functions import delete_user_
|
||||
from flask import abort, current_app, flash, redirect, render_template, url_for
|
||||
from flask_login import current_user, login_required, logout_user
|
||||
from . import profile
|
||||
from .background_functions import delete_user_
|
||||
from .forms import ChangePasswordForm, EditProfileForm, EditUserSettingsForm
|
||||
import threading
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user