search: Add most of the choices for advanced search
This commit is contained in:
parent
40a5d54c49
commit
4f6586e3f6
|
@ -1,7 +1,8 @@
|
|||
from flask_login import current_user
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField
|
||||
from wtforms.fields.datetime import DateField
|
||||
from wtforms.validators import InputRequired, Optional
|
||||
from wtforms.fields import StringField, SubmitField, SelectField, SelectMultipleField, DateField
|
||||
from app.models.forum import Forum
|
||||
|
||||
|
||||
# TODO: compléter le formulaire de recherche avancée
|
||||
|
@ -9,5 +10,40 @@ class SearchForm(FlaskForm):
|
|||
q = StringField('Rechercher', validators=[InputRequired()])
|
||||
|
||||
class AdvancedSearchForm(SearchForm):
|
||||
date = DateField('Date', validators=[Optional()])
|
||||
def generate_choices():
|
||||
choices = {'Forum': [
|
||||
'Actualités',
|
||||
'Aide et questions',
|
||||
'Forum des projets',
|
||||
'Vie communautaire',
|
||||
], 'Programmes': [
|
||||
'Jeux',
|
||||
'Utilitaires',
|
||||
'Logiciels'
|
||||
], 'Utilisateurs': [
|
||||
'Tous'
|
||||
], 'Tutoriels': [
|
||||
'Basic',
|
||||
'C/C++',
|
||||
'Arduino',
|
||||
'Python'
|
||||
], 'Sprites': [
|
||||
'Personnages',
|
||||
'Environnements',
|
||||
'Objets',
|
||||
'Interfaces'
|
||||
]}
|
||||
# Forum reserved for admins and moderators
|
||||
f = Forum.query.filter_by(url='/admin').first()
|
||||
if (current_user.is_authenticated and current_user.can_access_forum(f)):
|
||||
choices['Forum'].append('Administration')
|
||||
# Forum reserved to members of CreativeCalc
|
||||
f = Forum.query.filter_by(url='/creativecalc').first()
|
||||
if (current_user.is_athenticated and current_user.can_access_forum(f)):
|
||||
choices['Forum'].append('CreativeCalc')
|
||||
return choices
|
||||
|
||||
sortBy = SelectField('Trier', choices={'date': ['croissant', 'décroissant'],'alphabétique': ['croissant', 'décroissant']}, validators=[Optional()])
|
||||
date = DateField('Date de publication', validators=[Optional()])
|
||||
scope = SelectMultipleField('', choices=generate_choices, validators=[Optional()])
|
||||
submit = SubmitField('Affiner la recherche')
|
||||
|
|
Loading…
Reference in New Issue