mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	update new forms
This commit is contained in:
		@@ -1,15 +1,63 @@
 | 
				
			|||||||
from flask_wtf import FlaskForm
 | 
					from flask_wtf import FlaskForm
 | 
				
			||||||
from wtforms import BooleanField, StringField, SubmitField, SelectField
 | 
					from wtforms import (BooleanField, FileField, StringField, SubmitField,
 | 
				
			||||||
 | 
					                     ValidationError, IntegerField, SelectField)
 | 
				
			||||||
from wtforms.validators import DataRequired, Length
 | 
					from wtforms.validators import DataRequired, Length
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PJQueryForm(FlaskForm):
 | 
					class AddCorpusFileForm(FlaskForm):
 | 
				
			||||||
 | 
					    address = StringField('Adress', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    author = StringField('Author', validators=[DataRequired(), Length(1, 255)])
 | 
				
			||||||
 | 
					    booktitle = StringField('Booktitle', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    chapter = StringField('Chapter', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    editor = StringField('Editor', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    file = FileField('File', validators=[DataRequired()])
 | 
				
			||||||
 | 
					    institution = StringField('Institution', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    journal = StringField('Journal', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    pages = StringField('Pages', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    publisher = StringField('Publisher', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    publishing_year = IntegerField('Publishing year',
 | 
				
			||||||
 | 
					                                   validators=[DataRequired()])
 | 
				
			||||||
 | 
					    school = StringField('School', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    submit = SubmitField()
 | 
				
			||||||
 | 
					    title = StringField('Title', validators=[DataRequired(), Length(1, 255)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def validate_file(form, field):
 | 
				
			||||||
 | 
					        if not field.data.filename.lower().endswith('.vrt'):
 | 
				
			||||||
 | 
					            raise ValidationError('File does not have an approved extension: '
 | 
				
			||||||
 | 
					                                  '.vrt')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class EditCorpusFileForm(FlaskForm):
 | 
				
			||||||
 | 
					    address = StringField('Adress', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    author = StringField('Author', validators=[DataRequired(), Length(1, 255)])
 | 
				
			||||||
 | 
					    booktitle = StringField('Booktitle', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    chapter = StringField('Chapter', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    editor = StringField('Editor', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    institution = StringField('Institution', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    journal = StringField('Journal', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    pages = StringField('Pages', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    publisher = StringField('Publisher', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    publishing_year = IntegerField('Publishing year',
 | 
				
			||||||
 | 
					                                   validators=[DataRequired()])
 | 
				
			||||||
 | 
					    school = StringField('School', validators=[Length(0, 255)])
 | 
				
			||||||
 | 
					    submit = SubmitField()
 | 
				
			||||||
 | 
					    title = StringField('Title', validators=[DataRequired(), Length(1, 255)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AddCorpusForm(FlaskForm):
 | 
				
			||||||
 | 
					    description = StringField('Description',
 | 
				
			||||||
 | 
					                              validators=[DataRequired(), Length(1, 255)])
 | 
				
			||||||
 | 
					    submit = SubmitField()
 | 
				
			||||||
 | 
					    title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class QueryForm(FlaskForm):
 | 
				
			||||||
    query = StringField('Query',
 | 
					    query = StringField('Query',
 | 
				
			||||||
                        validators=[DataRequired(), Length(1, 1024)])
 | 
					                        validators=[DataRequired(), Length(1, 1024)])
 | 
				
			||||||
    submit = SubmitField('Send query')
 | 
					    submit = SubmitField('Send query')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PJDisplayOptionsForm(FlaskForm):
 | 
					class DisplayOptionsForm(FlaskForm):
 | 
				
			||||||
    expert_mode = BooleanField('Expert mode')
 | 
					    expert_mode = BooleanField('Expert mode')
 | 
				
			||||||
    result_context = SelectField('Result context',
 | 
					    result_context = SelectField('Result context',
 | 
				
			||||||
                                 choices=[('', 'Choose your option'),
 | 
					                                 choices=[('', 'Choose your option'),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
from flask import request, render_template
 | 
					from flask import request, render_template
 | 
				
			||||||
from flask_login import login_required
 | 
					from flask_login import login_required
 | 
				
			||||||
from . import corpora
 | 
					from . import corpora
 | 
				
			||||||
from .pj_forms import PJDisplayOptionsForm, PJQueryForm, QueryDownloadForm
 | 
					from .pj_forms import DisplayOptionsForm, QueryForm, QueryDownloadForm
 | 
				
			||||||
from .. import db
 | 
					from .. import db
 | 
				
			||||||
from ..models import Corpus
 | 
					from ..models import Corpus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -13,11 +13,11 @@ def pj_analyse_corpus(corpus_id):
 | 
				
			|||||||
    if corpus.status == 'prepared':
 | 
					    if corpus.status == 'prepared':
 | 
				
			||||||
        corpus.status = 'start analysis'
 | 
					        corpus.status = 'start analysis'
 | 
				
			||||||
        db.session.commit()
 | 
					        db.session.commit()
 | 
				
			||||||
    display_options_form = PJDisplayOptionsForm(
 | 
					    display_options_form = DisplayOptionsForm(
 | 
				
			||||||
        prefix='display-options-form',
 | 
					        prefix='display-options-form',
 | 
				
			||||||
        result_context=request.args.get('context', 20),
 | 
					        result_context=request.args.get('context', 20),
 | 
				
			||||||
        results_per_page=request.args.get('results_per_page', 30))
 | 
					        results_per_page=request.args.get('results_per_page', 30))
 | 
				
			||||||
    query_form = PJQueryForm(prefix='query-form',
 | 
					    query_form = QueryForm(prefix='query-form',
 | 
				
			||||||
                             query=request.args.get('query'))
 | 
					                             query=request.args.get('query'))
 | 
				
			||||||
    query_download_form = QueryDownloadForm()
 | 
					    query_download_form = QueryDownloadForm()
 | 
				
			||||||
    return render_template('corpora/pj_analyse_corpus.html.j2',
 | 
					    return render_template('corpora/pj_analyse_corpus.html.j2',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user