Misc Fixes

This commit is contained in:
2020-08-08 01:17:55 +02:00
parent ad9883ae09
commit 588ce76eee
6 changed files with 577 additions and 498 deletions
+11
View File
@@ -36,3 +36,14 @@ If no error occurs, the webserver should be available on http://localhost:8080/
pserve development.ini
Enjoy !
sudo apt install virtualenv git python3-virtualenv
sudo mkdir -p /srv/jm2l
cd /srv/jm2l/
cd /srv
sudo chown luna jm2l
cd jm2l/
virtualenv -p python3 .venv_jm2l
+15 -8
View File
@@ -4,9 +4,11 @@ except ImportError:
from cgi import escape
# from wtforms import widgets
from wtforms.widgets import HTMLString, html_params
from wtforms.widgets import html_params
from wtforms.fields.core import Field
from wtforms.compat import text_type, izip
from markupsafe import Markup
class MySelect(object):
"""
@@ -19,6 +21,7 @@ class MySelect(object):
call on rendering; this method must yield tuples of
`(value, label, selected)`.
"""
def __init__(self, multiple=False):
self.multiple = multiple
@@ -40,7 +43,7 @@ class MySelect(object):
if last_group:
html.append(self.render_optgroup(last_group, None))
html.append('</select>')
return HTMLString(''.join(html))
return Markup(''.join(html))
@classmethod
def render_option(cls, value, label, selected, **kwargs):
@@ -51,17 +54,19 @@ class MySelect(object):
options = dict(kwargs, value=value)
if selected:
options['selected'] = True
return HTMLString('<option %s>%s</option>' % (html_params(**options), escape(text_type(label), quote=False)))
return Markup('<option %s>%s</option>' % (html_params(**options), escape(text_type(label), quote=False)))
@classmethod
def render_optgroup(cls, previous_label, label, **kwargs):
options = dict(kwargs)
if previous_label is None:
return HTMLString('<optgroup %s label="%s">' % (html_params(**options), escape(text_type(label), quote=False)))
return Markup(
'<optgroup %s label="%s">' % (html_params(**options), escape(text_type(label), quote=False)))
elif label is None:
return HTMLString('</optgroup>')
return Markup('</optgroup>')
else:
return HTMLString('</optgroup><optgroup %s label="%s">' % (html_params(**options), escape(text_type(label), quote=False)))
return Markup(
'</optgroup><optgroup %s label="%s">' % (html_params(**options), escape(text_type(label), quote=False)))
class MyOption(object):
@@ -71,6 +76,7 @@ class MyOption(object):
This is just a convenience for various custom rendering situations, and an
option by itself does not constitute an entire field.
"""
def __call__(self, field, **kwargs):
return MySelect.render_option(field._value(), field.label.text, field.checked, **kwargs)
@@ -85,6 +91,7 @@ class MySelectFieldBase(Field):
This isn't a field, but an abstract base class for fields which want to
provide this functionality.
"""
def __init__(self, label=None, validators=None, option_widget=None, **kwargs):
super(MySelectFieldBase, self).__init__(label, validators, **kwargs)
@@ -128,11 +135,11 @@ class MySelectField(MySelectFieldBase):
# We should consider choiceA as an optgroup label
group_label = choiceA
for value, label in choiceB:
yield (group_label, value, label, self.coerce(value) == self.data)
yield group_label, value, label, self.coerce(value) == self.data
else:
value, label = choiceA, choiceB
# Not an optgroup, let's fallback to classic usage
yield (None, value, label, self.coerce(value) == self.data)
yield None, value, label, self.coerce(value) == self.data
def process_data(self, value):
try:
+44 -44
View File
@@ -20,15 +20,16 @@ from mako.template import Template
from .models import User
from jm2l.const import CurrentYear
from .models import JM2L_Year
import logging
def add_renderer_globals(event):
event['mytrip'] = Sejour_helpers(event)
event['myorga'] = Orga_helpers(event)
event['SelectedYear'] = CurrentYear
event['CurrentYear'] = CurrentYear
# @sched.scheduled_job('cron', day_of_week='sun', hour=22, minute=07)
def mailer_tasks(config):
# Send the Welcome Mail
@@ -60,6 +61,7 @@ def mailer_tasks(config):
mailer.send_immediately(message)
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
@@ -80,7 +82,7 @@ def main(global_config, **settings):
authorization_policy=authorization_policy
)
config.add_subscriber(add_renderer_globals, BeforeRender)
# config.registry['mailer'] = mailer_factory_from_settings(settings)
config.registry['mailer'] = mailer_factory_from_settings(settings)
config.registry['event_date'] = JM2L_Year.get_latest_jm2l_startdate()
sched = BackgroundScheduler()
sched.add_job(mailer_tasks, 'cron', day_of_week='fri', hour=18, args=[config])
@@ -100,70 +102,70 @@ def main(global_config, **settings):
config.add_static_view('resources', 'resources', cache_max_age=3600)
# ICal Routes
config.add_route('progr_iCal', '/{year:\d+}/JM2L.ics')
config.add_route('progr_dyn_iCal', '/{year:\d+}/JM2L_dyn.ics')
config.add_route('progr_iCal', r'/{year:\d+}/JM2L.ics')
config.add_route('progr_dyn_iCal', r'/{year:\d+}/JM2L_dyn.ics')
# JSON Routes
config.add_route('users_json', '/json-users')
config.add_route('tiers_json', '/json-tiers')
config.add_route('progr_json', '/{year:\d+}/le-prog-json')
config.add_route('timeline_json', '/{year:\d+}/timeline-json')
config.add_route('progr_json', r'/{year:\d+}/le-prog-json')
config.add_route('timeline_json', r'/{year:\d+}/timeline-json')
# Session setting Routes
config.add_route('year', '/year/{year:\d+}')
config.add_route('vote_logo', '/vote_logo/{num:\d+}')
config.add_route('year', r'/year/{year:\d+}')
config.add_route('vote_logo', r'/vote_logo/{num:\d+}')
# HTML Routes - Staff
config.add_route('Live', '/Live')
config.add_route('list_expenses', '/{year:\d+}/Staff/compta')
config.add_route('list_task', '/{year:\d+}/Staff')
config.add_route('handle_pole', '/{year:\d+}/Staff/poles{sep:/*}{pole_id:(\d+)?}')
config.add_route('handle_task', '/{year:\d+}/Staff/tasks{sep:/*}{task_id:(\d+)?}')
config.add_route('action_task', '/{year:\d+}/Staff/{action:(\w+)}/{task_id:(\d+)}')
config.add_route('action_task_area', '/{year:\d+}/Staff/pole/{action:(\w+)}/{pole_id:(\d+)}')
config.add_route('list_expenses', r'/{year:\d+}/Staff/compta')
config.add_route('list_task', r'/{year:\d+}/Staff')
config.add_route('handle_pole', r'/{year:\d+}/Staff/poles{sep:/*}{pole_id:(\d+)?}')
config.add_route('handle_task', r'/{year:\d+}/Staff/tasks{sep:/*}{task_id:(\d+)?}')
config.add_route('action_task', r'/{year:\d+}/Staff/{action:(\w+)}/{task_id:(\d+)}')
config.add_route('action_task_area', r'/{year:\d+}/Staff/pole/{action:(\w+)}/{pole_id:(\d+)}')
config.add_route('list_salles', '/ListSalles')
config.add_route('list_salles_phy', '/ListSallesPhy')
config.add_route('handle_salle', '/Salles{sep:/*}{salle_id:(\d+)?}')
config.add_route('handle_salle_phy', '/PhySalles{sep:/*}{salle_id:(\d+)?}')
config.add_route('action_salle', '/Salles/{action:(\w+)}/{salle_id:(\d+)}')
config.add_route('pict_salle', '/salle_picture/{salle_id:(\d+)}')
config.add_route('handle_salle', r'/Salles{sep:/*}{salle_id:(\d+)?}')
config.add_route('handle_salle_phy', r'/PhySalles{sep:/*}{salle_id:(\d+)?}')
config.add_route('action_salle', r'/Salles/{action:(\w+)}/{salle_id:(\d+)}')
config.add_route('pict_salle', r'/salle_picture/{salle_id:(\d+)}')
config.add_route('list_users', '/{year:\d+}/ListParticipant')
config.add_route('list_users_csv', '/{year:\d+}/ListParticipant.csv')
config.add_route('list_orga', '/{year:\d+}/ListOrga')
config.add_route('list_users', r'/{year:\d+}/ListParticipant')
config.add_route('list_users_csv', r'/{year:\d+}/ListParticipant.csv')
config.add_route('list_orga', r'/{year:\d+}/ListOrga')
# HTML Routes - Public
config.add_route('home', '/{year:(\d+/)?}')
config.add_route('edit_index', '/{year:\d+}/edit')
config.add_route('presse', '/{year:\d+}/dossier-de-presse')
config.add_route('edit_presse', '/{year:\d+}/dossier-de-presse/edit')
config.add_route('programme', '/{year:\d+}/le-programme')
config.add_route('home', r'/{year:(\d+/)?}')
config.add_route('edit_index', r'/{year:\d+}/edit')
config.add_route('presse', r'/{year:\d+}/dossier-de-presse')
config.add_route('edit_presse', r'/{year:\d+}/dossier-de-presse/edit')
config.add_route('programme', r'/{year:\d+}/le-programme')
config.add_route('plan', 'nous-rejoindre')
config.add_route('participer', 'participer-l-evenement')
config.add_route('captcha', '/captcha')
## Events
config.add_route('event', '/event/{year:\d+}/{event_id:([\w-]+)?}')
config.add_route('link_event_user', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_user')
config.add_route('delete_link_u', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_user')
config.add_route('link_event_tiers', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_tiers')
config.add_route('delete_link_t', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_tiers')
config.add_route('edit_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}')
config.add_route('delete_event', '/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}/delete')
config.add_route('event', r'/event/{year:\d+}/{event_id:([\w-]+)?}')
config.add_route('link_event_user', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_user')
config.add_route('delete_link_u', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_user')
config.add_route('link_event_tiers', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/link_tiers')
config.add_route('delete_link_t', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}/delete_link_tiers')
config.add_route('edit_event', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}')
config.add_route('delete_event', r'/MesJM2L/{year:\d+}/{intervention:[\s\w]+}{sep:/*}{event_id:([\w-]+)?}/delete')
## Entities
config.add_route('entities', '/entities') # {sep:/*}{Nature:\w+?}')
config.add_route('add_entity', '/entity')
config.add_route('delete_entity', '/entity/{entity_id:(\d+)}/delete')
config.add_route('show_entity', '/entity/{tiers_type:(\w+)}/{entity_id:([\w-]+)?}')
config.add_route('edit_entity', '/entity/{tiers_type:(\w+)}/{entity_id:([\w-]+)}/edit')
config.add_route('delete_entity', r'/entity/{entity_id:(\d+)}/delete')
config.add_route('show_entity', r'/entity/{tiers_type:(\w+)}/{entity_id:([\w-]+)?}')
config.add_route('edit_entity', r'/entity/{tiers_type:(\w+)}/{entity_id:([\w-]+)}/edit')
config.add_route('edit_entity_cat', '/categorie/entity')
## Users
config.add_route('pict_user', '/user_picture')
config.add_route('show_user', '/user/{user_slug:([\w-]+)?}')
config.add_route('badge_user', '/user/{user_slug:([\w-]+)?}/badge')
config.add_route('show_user', r'/user/{user_slug:([\w-]+)?}')
config.add_route('badge_user', r'/user/{user_slug:([\w-]+)?}/badge')
config.add_route('all_badges', '/badges')
config.add_route('place_print', '/place_print')
config.add_route('stand_print', '/stand_print')
@@ -175,10 +177,10 @@ def main(global_config, **settings):
config.add_route('miam', '/MonMiam')
config.add_route('sejour', '/MonSejour')
config.add_route('orga', '/MonOrga')
config.add_route('modal', '/{year:\d+}/modal/{modtype:\w+}/{id:(\d+)}')
config.add_route('modal', r'/{year:\d+}/modal/{modtype:\w+}/{id:(\d+)}')
# Handle exchanges
config.add_route('exchange', '/{year:\d+}/exchange/{modtype:\w+}/{id:(\d+)}/{action:\w+}')
config.add_route('exchange', r'/{year:\d+}/exchange/{modtype:\w+}/{id:(\d+)}/{action:\w+}')
# Handle authentication
config.add_route('register', '/register')
@@ -186,10 +188,8 @@ def main(global_config, **settings):
config.add_route('bymail', '/sign/jm2l/{hash}')
# Handle Multimedia and Uploads
config.add_route('media_view', '/image/{media_table:\w+}/{uid:\d+}/{name:.+}')
config.add_route('media_upload', '/uploader/{media_table:\w+}/{uid:\d+}/proceed{sep:/*}{name:.*}')
config.add_route('media_view', r'/image/{media_table:\w+}/{uid:\d+}/{name:.+}')
config.add_route('media_upload', r'/uploader/{media_table:\w+}/{uid:\d+}/proceed{sep:/*}{name:.*}')
config.scan()
return config.make_wsgi_app()
+21 -19
View File
@@ -3,15 +3,14 @@
import random
from PIL import Image, ImageDraw, ImageFont, ImageFilter
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import io
# from io import StringIO
import math
from pyramid.view import view_config
from .words import TabMots
from pyramid.response import Response
class Captcha_Img(object):
def __init__(self, width, height):
self.width = width
@@ -36,6 +35,7 @@ class Captcha_Img(object):
self._image = img
return self._image
class _PyCaptcha_WarpBase(object):
"""Abstract base class for image warping. Subclasses define a
function that maps points in the output image to points in the input image.
@@ -58,10 +58,10 @@ class _PyCaptcha_WarpBase(object):
# Create a list of arrays with transformed points
xRows = []
yRows = []
for j in xrange(yPoints):
for j in range(int(yPoints)):
xRow = []
yRow = []
for i in xrange(xPoints):
for i in range(int(xPoints)):
x, y = f(i * r, j * r)
# Clamp the edges so we don't get black undefined areas
@@ -76,8 +76,8 @@ class _PyCaptcha_WarpBase(object):
# Create the mesh list, with a transformation for
# each square between points on the grid
mesh = []
for j in xrange(yPoints-1):
for i in xrange(xPoints-1):
for j in range(int(yPoints - 1)):
for i in range(int(xPoints - 1)):
mesh.append((
# Destination rectangle
(i * r, j * r,
@@ -91,6 +91,7 @@ class _PyCaptcha_WarpBase(object):
return image.transform(image.size, Image.MESH, mesh, self.filtering)
class _PyCaptcha_SineWarp(_PyCaptcha_WarpBase):
"""Warp the image using a random composition of sine waves"""
@@ -111,13 +112,14 @@ class _PyCaptcha_SineWarp(_PyCaptcha_WarpBase):
(math.sin((y + o[0]) * p) * a + x,
math.sin((x + o[1]) * p) * a + y))
@view_config(route_name='captcha')
def DoCaptcha(request):
ImgSize = (230, 100)
WorkImg = Image.new( 'RGBA', ImgSize, (255, 255, 255, 0) )
Xmax, Ymax = WorkImg.size
work_img = Image.new('RGBA', ImgSize, (255, 255, 255, 0))
Xmax, Ymax = work_img.size
# Write something on it
draw = ImageDraw.Draw(WorkImg)
draw = ImageDraw.Draw(work_img)
# use a truetype font
# font = ImageFont.truetype("/var/lib/defoma/gs.d/dirs/fonts/LiberationMono-Regular.ttf", 40)
@@ -130,25 +132,25 @@ def DoCaptcha(request):
OrX, OrY = (ImgSize[0] - Xt) / 2, (ImgSize[1] - Yt) / 2
draw.text((OrX, OrY), text, font=font, fill="#000000")
# Apply a Blur
# WorkImg=WorkImg.filter(ImageFilter.BLUR)
# work_img=work_img.filter(ImageFilter.BLUR)
# Apply a DETAIL
WorkImg=WorkImg.filter(ImageFilter.DETAIL)
work_img = work_img.filter(ImageFilter.DETAIL)
# randomize parameters for perspective
ax, ay = (random.uniform(0.9, 1.2), random.uniform(0.9, 1.2))
tx, ty = (random.uniform(0, 0.0003), random.uniform(0, 0.0003))
bx, by = (random.uniform(0.5, 0.8), random.uniform(0, 0.2))
# Apply perspective to Captcha
WorkImg= WorkImg.transform(ImgSize, Image.PERSPECTIVE, (ax, bx, -25, by, ay, -10, tx, ty))
work_img = work_img.transform(ImgSize, Image.PERSPECTIVE, (ax, bx, -25, by, ay, -10, tx, ty))
# Apply SinWarp to Captcha
tr = Captcha_Img(Xmax, Ymax)
tr._image = WorkImg
WorkImg = tr.render()
tr._image = work_img
work_img = tr.render()
# Apply a Smooth on it
WorkImg=WorkImg.filter(random.choice([ImageFilter.SMOOTH, ImageFilter.SMOOTH_MORE]))
work_img = work_img.filter(random.choice([ImageFilter.SMOOTH, ImageFilter.SMOOTH_MORE]))
# Save Result
request.session['Captcha'] = text
# session.save()
ImgHandle = StringIO.StringIO()
WorkImg.save(ImgHandle,'png')
ImgHandle = io.BytesIO()
work_img.save(ImgHandle, 'png')
ImgHandle.seek(0)
return Response(app_iter=ImgHandle, content_type='image/png')
+70 -12
View File
@@ -1,28 +1,45 @@
# -*- coding: utf8 -*-
import random
import string
from wtforms import Form, BooleanField, StringField, TextAreaField, SelectField
from wtforms import SubmitField, validators, FieldList, PasswordField
# import .ExtWforms
from .ExtWtforms import MySelectField
from wtforms import HiddenField, DecimalField, DateTimeField, FormField, DateField
from wtforms.validators import ValidationError
strip_filter = lambda x: x.strip() if x else None
from wtforms.csrf.session import SessionCSRF
from datetime import timedelta
from jm2l.const import CurrentYear
# What about an helper function
#def strip_filter(x)
# if x is no
strip_filter = lambda x: x.strip() if x else None
# get random string password with letters, digits, and symbols
def get_random_string(length):
csrf_characters = string.ascii_letters + string.digits + string.punctuation
csrf = ''.join(random.choice(password_characters) for i in range(length))
return csrf
class MyBaseForm(Form):
class Meta:
csrf = True
csrf_class = SessionCSRF
csrf_secret = b'lJDQtOAMC2qe89doIn8u3Mch_DgeLSKO'
# csrf_secret = b'lJDQtOAMC2qe89doIn8u3Mch_DgeLSKO'
csrf_secret = get_random_string(32)
csrf_time_limit = timedelta(minutes=60)
class BlogCreateForm(MyBaseForm):
title = StringField('Entry title', [validators.Length(min=1, max=255)],
filters=[strip_filter])
body = TextAreaField('Entry body', [validators.Length(min=1)],
filters=[strip_filter])
class BlogUpdateForm(BlogCreateForm):
id = HiddenField()
@@ -56,9 +73,11 @@ class StaffArea(MyBaseForm):
)
year_uid = HiddenField('year', default=str(CurrentYear))
class EditStaffArea(StaffArea):
uid = HiddenField()
class StaffTasks(MyBaseForm):
name = StringField(u'Nom de la tâche', [validators.Required()])
area_uid = SelectField(u'Pôle concerné', coerce=int)
@@ -68,34 +87,42 @@ class StaffTasks(MyBaseForm):
filters=[strip_filter])
year_uid = HiddenField('year', default=str(CurrentYear))
class EditStaffTasks(StaffTasks):
uid = HiddenField()
class DossPresse(MyBaseForm):
year_uid = HiddenField()
doss_presse = TextAreaField('Dossier de Presse', [validators.optional(), validators.Length(max=1000000)],
filters=[strip_filter])
class IndexForm(MyBaseForm):
year_uid = HiddenField()
description = TextAreaField('Index', [validators.optional(), validators.Length(max=1000000)],
filters=[strip_filter])
class TiersMember(MyBaseForm):
class Meta:
csrf = False
year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,CurrentYear+1),range(2006,CurrentYear+1)))
year_uid = SelectField(u'Année', coerce=int,
choices=zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1)))
user_uid = StringField(u'user')
role = StringField(u'Role')
class TiersRole(MyBaseForm):
class Meta:
csrf = False
year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,CurrentYear+1),range(2006,CurrentYear+1)))
year_uid = SelectField(u'Année', coerce=int,
choices=zip(range(2006, CurrentYear + 1), range(2006, CurrentYear + 1)))
tiers_role = SelectField(u'Role', choices=TIERS_ROLE)
class TiersChoice(MyBaseForm):
class Meta:
csrf = False
@@ -105,6 +132,7 @@ class TiersChoice(MyBaseForm):
tiers_uid = StringField(u'Entité')
role = StringField(u'Role')
class AddIntervenant(MyBaseForm):
class Meta:
csrf = False
@@ -112,6 +140,7 @@ class AddIntervenant(MyBaseForm):
event_uid = HiddenField()
intervenant = SelectField(u'Intervenant', coerce=int)
class AddTiers(MyBaseForm):
class Meta:
csrf = False
@@ -119,8 +148,8 @@ class AddTiers(MyBaseForm):
event_uid = HiddenField()
tiers = SelectField(u'Entité', coerce=int)
class ConfCreateForm(MyBaseForm):
class ConfCreateForm(MyBaseForm):
event_type = HiddenField()
for_year = HiddenField()
start_time = HiddenField()
@@ -153,23 +182,28 @@ class ConfCreateForm(MyBaseForm):
filters=[strip_filter]
)
class ConfUpdateForm(ConfCreateForm):
uid = HiddenField()
class SalleForm(MyBaseForm):
year_uid = SelectField(u'Année', coerce=int)
phy_salle_id = SelectField('Salle Physique', coerce=int)
place_type = SelectField('Type', choices=[('Conference', u'Conférence'),
('Stand','Stand'), ('Atelier','Atelier'), ('Table ronde','Table ronde'),
('Stand', 'Stand'), ('Atelier', 'Atelier'),
('Table ronde', 'Table ronde'),
('MAO', 'MAO'), ('Repas', 'Repas / Snack'), ('Autres', 'Autres')])
name = StringField('Nom de la salle', [validators.Length(min=1, max=40)],
filters=[strip_filter])
description = TextAreaField('Description',
filters=[strip_filter])
class EditSalleForm(SalleForm):
salle_id = HiddenField()
class SallePhyForm(MyBaseForm):
name = StringField('Nom de la salle', [validators.Length(min=1, max=40)],
filters=[strip_filter])
@@ -177,11 +211,12 @@ class SallePhyForm(MyBaseForm):
description = TextAreaField('Description',
filters=[strip_filter])
class EditSallePhyForm(SallePhyForm):
uid = HiddenField()
class PlaceCreateForm(MyBaseForm):
class PlaceCreateForm(MyBaseForm):
place_type = SelectField('Type', choices=PLACE_TYPE)
display_name = StringField(u'Nom affiché', [validators.Length(min=1, max=20)],
@@ -205,6 +240,7 @@ class PlaceCreateForm(MyBaseForm):
created_by = HiddenField()
class PlaceUpdateForm(PlaceCreateForm):
place_id = HiddenField()
@@ -213,6 +249,7 @@ def captcha_check(form, field):
if form.meta.csrf_context.get('Captcha') != field.data:
raise ValidationError(u"la vérification captcha est invalide.")
class UserPasswordForm(MyBaseForm):
uid = HiddenField()
password = PasswordField("Mot de passe", [
@@ -223,8 +260,8 @@ class UserPasswordForm(MyBaseForm):
)
confirm = PasswordField('Confirmez')
class UserRegisterForm(MyBaseForm):
class UserRegisterForm(MyBaseForm):
nom = StringField(u'Nom', [
validators.Length(max=80, message=u"80 car. maximum"),
validators.required(message=u"Ce champ est obligatoire")],
@@ -248,6 +285,7 @@ class UserRegisterForm(MyBaseForm):
filters=[strip_filter]
)
class ProfilForm(MyBaseForm):
id = HiddenField()
user_id = HiddenField()
@@ -276,7 +314,8 @@ class ProfilForm(MyBaseForm):
)
phone = StringField(u'Mobile', [validators.optional(), validators.Length(max=10),
validators.Regexp("\d+", message=u"Le numéro de téléphone mobile ne doit contenir que des chiffres")],
validators.Regexp("\d+",
message=u"Le numéro de téléphone mobile ne doit contenir que des chiffres")],
filters=[strip_filter],
description=u"Un numéro de mobile valide. Afin de pouvoir rester en" +
u"contact avec les personne de l'organisation, et pour vos échanges. " +
@@ -359,13 +398,14 @@ class DateStartConfidenceForm(MyBaseForm):
filters=[strip_filter])
start_time = HiddenField()
class ItineraireForm(Form):
start_place = SelectField(u'En partant de', coerce=int)
arrival_place = SelectField(u'et à destination de', coerce=int)
itin_id = HiddenField()
class AddItineraireForm(Form):
class AddItineraireForm(Form):
itin = FormField(ItineraireForm)
distance = DecimalField(u'Distance', [validators.Length(min=1, max=4)],
filters=[strip_filter])
@@ -382,6 +422,7 @@ class AddItineraireForm(Form):
tr_avion = BooleanField(u'en avion')
description = TextAreaField(u'Description de l\'itinéraire')
class AddMember(MyBaseForm):
tiers_uid = HiddenField()
nom = StringField(u'Nom', [validators.Length(max=80)],
@@ -404,6 +445,7 @@ class AddMember(MyBaseForm):
u"son inscription sur le site.")
add = SubmitField('Ajouter des membres')
class TiersForm(MyBaseForm):
name = StringField(u'Nom', [validators.Length(max=100)],
filters=[strip_filter],
@@ -429,6 +471,7 @@ class TiersForm(MyBaseForm):
roles = FieldList(FormField(TiersRole))
class UpdateTiersForm(TiersForm):
uid = HiddenField()
tiers_id = HiddenField()
@@ -443,9 +486,11 @@ class ExchCateg(MyBaseForm):
description = TextAreaField('Description',
filters=[strip_filter])
class UpdateExchangeForm(MyBaseForm):
exch_id = HiddenField()
class AskCForm(ItineraireForm):
ConfidenceLevel = [
("0", u"exactement à"),
@@ -466,8 +511,10 @@ class AskCForm(ItineraireForm):
arrival_place = SelectField(u'et à destination de', coerce=int)
itin_id = HiddenField()
class AskHForm(MyBaseForm):
DayChoice = [("4",u"Jeudi à Vendredi"), ("5",u"Vendredi à Samedi"), ("6",u"Samedi à Dimanche"), ("0",u"Dimanche à Lundi")]
DayChoice = [("4", u"Jeudi à Vendredi"), ("5", u"Vendredi à Samedi"), ("6", u"Samedi à Dimanche"),
("0", u"Dimanche à Lundi")]
Day_start = SelectField(u'Pour la nuit de', choices=DayChoice)
start_time = HiddenField()
description = TextAreaField(u'Description de vos contraintes éventuelles', filters=[strip_filter],
@@ -475,6 +522,7 @@ class AskHForm(MyBaseForm):
+ u"les contraintes à prendre en compte. N'hésitez pas à donner des détails."
)
class AskMForm(MyBaseForm):
DayChoice = [("4", "Jeudi"), ("5", "Vendredi"), ("6", "Samedi"), ("0", "Dimanche"), ("1", "Lundi")]
Day_start = SelectField(u"à partir de", choices=DayChoice)
@@ -499,6 +547,7 @@ class AskMForm(MyBaseForm):
+ u"échanger. N'hésitez pas à donner des détails."
)
class PropCForm(ItineraireForm):
ConfidenceLevel = [
("0", u"exactement à"),
@@ -519,8 +568,10 @@ class PropCForm(ItineraireForm):
arrival_place = SelectField(u'et à destination de', coerce=int)
itin_id = HiddenField()
class PropHForm(MyBaseForm):
DayChoice = [("4",u"Jeudi à Vendredi"), ("5",u"Vendredi à Samedi"), ("6",u"Samedi à Dimanche"), ("0",u"Dimanche à Lundi")]
DayChoice = [("4", u"Jeudi à Vendredi"), ("5", u"Vendredi à Samedi"), ("6", u"Samedi à Dimanche"),
("0", u"Dimanche à Lundi")]
Day_start = SelectField(u'Pour la nuit de', choices=DayChoice)
start_time = HiddenField()
exch_categ = SelectField(u'Type de couchage', coerce=int,
@@ -532,6 +583,7 @@ class PropHForm(MyBaseForm):
place_id = SelectField(u'Emplacement', coerce=int,
description=u"Indiquez ici une des adresses que vous avez proposé")
class PropMForm(MyBaseForm):
DayChoice = [("4", "Jeudi"), ("5", "Vendredi"), ("6", "Samedi"), ("0", "Dimanche"), ("1", "Lundi")]
Day_start = SelectField(u"à partir de", choices=DayChoice)
@@ -556,20 +608,26 @@ class PropMForm(MyBaseForm):
+ u"proposer. N'hésitez pas à donner des détails."
)
class UpdateAskCForm(AskCForm, UpdateExchangeForm):
pass
class UpdateAskHForm(AskHForm, UpdateExchangeForm):
pass
class UpdateAskMForm(AskMForm, UpdateExchangeForm):
pass
class UpdatePropCForm(PropCForm, UpdateExchangeForm):
pass
class UpdatePropHForm(PropHForm, UpdateExchangeForm):
pass
class UpdatePropMForm(PropMForm, UpdateExchangeForm):
pass
+2 -1
View File
@@ -35,7 +35,8 @@ requires = [
'reportlab',
'passlib',
'argon2_cffi',
'paginate'
'paginate',
'markupsafe'
]
setup(name='JM2L',