mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Move auth.settings to a new package (profile) as profile.index
This commit is contained in:
		@@ -1,23 +1,18 @@
 | 
			
		||||
from flask_wtf import FlaskForm
 | 
			
		||||
from wtforms import MultipleFileField, StringField, SubmitField, ValidationError
 | 
			
		||||
from wtforms import (MultipleFileField, StringField, SubmitField,
 | 
			
		||||
                     ValidationError)
 | 
			
		||||
from wtforms.validators import DataRequired, Length
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateCorpusForm(FlaskForm):
 | 
			
		||||
    description = StringField(
 | 
			
		||||
        'Description',
 | 
			
		||||
        validators=[DataRequired(), Length(1, 64)]
 | 
			
		||||
    )
 | 
			
		||||
    description = StringField('Description',
 | 
			
		||||
                              validators=[DataRequired(), Length(1, 64)])
 | 
			
		||||
    files = MultipleFileField('Files', validators=[DataRequired()])
 | 
			
		||||
    submit = SubmitField('Create corpus')
 | 
			
		||||
    title = StringField(
 | 
			
		||||
        'Title',
 | 
			
		||||
        validators=[DataRequired(), Length(1, 32)]
 | 
			
		||||
    )
 | 
			
		||||
    title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
 | 
			
		||||
 | 
			
		||||
    def validate_files(form, field):
 | 
			
		||||
        for file in field.data:
 | 
			
		||||
            if not file.filename.lower().endswith('.vrt'):
 | 
			
		||||
                raise ValidationError(
 | 
			
		||||
                    'File does not have an approved extension: .vrt'
 | 
			
		||||
                )
 | 
			
		||||
                raise ValidationError('File does not have an approved '
 | 
			
		||||
                                      'extension: .vrt')
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,13 @@
 | 
			
		||||
from app.utils import background_delete_job
 | 
			
		||||
from flask import (abort, current_app, flash, redirect, request,
 | 
			
		||||
                   render_template, url_for, send_from_directory)
 | 
			
		||||
from flask_login import current_user, login_required
 | 
			
		||||
from . import main
 | 
			
		||||
from .forms import CreateCorpusForm
 | 
			
		||||
from .. import db
 | 
			
		||||
from ..models import Corpus, Job
 | 
			
		||||
from ..models import Corpus
 | 
			
		||||
import os
 | 
			
		||||
import logging
 | 
			
		||||
import threading
 | 
			
		||||
from app.utils import background_delete_job
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@main.route('/')
 | 
			
		||||
@@ -84,11 +83,9 @@ def dashboard():
 | 
			
		||||
            flash('Corpus created!')
 | 
			
		||||
        return redirect(url_for('main.dashboard'))
 | 
			
		||||
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'main/dashboard.html.j2',
 | 
			
		||||
        title='Dashboard',
 | 
			
		||||
        create_corpus_form=create_corpus_form
 | 
			
		||||
    )
 | 
			
		||||
    return render_template('main/dashboard.html.j2',
 | 
			
		||||
                           create_corpus_form=create_corpus_form,
 | 
			
		||||
                           title='Dashboard')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@main.route('/jobs/<int:job_id>')
 | 
			
		||||
@@ -145,9 +142,10 @@ def job_download(job_id):
 | 
			
		||||
@main.route('/jobs/<int:job_id>/delete')
 | 
			
		||||
@login_required
 | 
			
		||||
def delete_job(job_id):
 | 
			
		||||
    delete_thread = threading.Thread(target=background_delete_job,
 | 
			
		||||
                                     args=(current_app._get_current_object(),
 | 
			
		||||
                                           job_id))
 | 
			
		||||
    delete_thread = threading.Thread(
 | 
			
		||||
        target=background_delete_job,
 | 
			
		||||
        args=(current_app._get_current_object(), job_id)
 | 
			
		||||
    )
 | 
			
		||||
    delete_thread.start()
 | 
			
		||||
    flash('Job has been deleted!')
 | 
			
		||||
    return redirect(url_for('main.dashboard'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user