From d8ca5c80a5f98cb62e65392c3026286e07576eb0 Mon Sep 17 00:00:00 2001
From: tr4ck3ur
Date: Sat, 4 Apr 2015 04:42:51 +0200
Subject: [PATCH] Added Salle Physical Salle Management Added Role Form for
entities
---
jm2l/__init__.py | 16 ++-
jm2l/forms.py | 41 +++++-
jm2l/models.py | 1 +
jm2l/templates/Salles/list.mako | 90 ++++++++++++++
jm2l/templates/Salles/salle.mako | 58 +++++++++
jm2l/templates/Salles/salle_phy.mako | 61 +++++++++
jm2l/templates/edit_event.mako | 36 +++++-
jm2l/templates/edit_tiers.mako | 180 +++++++++++++++++++++------
jm2l/templates/layout.mako | 2 +-
jm2l/templates/view_tiers.mako | 9 +-
jm2l/upload.py | 8 +-
jm2l/views.py | 153 +++++++++++++++++++++--
12 files changed, 593 insertions(+), 62 deletions(-)
create mode 100644 jm2l/templates/Salles/list.mako
create mode 100644 jm2l/templates/Salles/salle.mako
create mode 100644 jm2l/templates/Salles/salle_phy.mako
diff --git a/jm2l/__init__.py b/jm2l/__init__.py
index 0301231..fbe0db6 100644
--- a/jm2l/__init__.py
+++ b/jm2l/__init__.py
@@ -56,12 +56,17 @@ def main(global_config, **settings):
config.add_route('vote_logo', '/vote_logo/{num:\d+}')
# HTML Routes - Staff
- config.add_route('list_task', '/Staff')
- config.add_route('handle_pole', '/Staff/poles{sep:/*}{pole_id:(\d+)?}')
- config.add_route('handle_task', '/Staff/tasks{sep:/*}{task_id:(\d+)?}')
- config.add_route('action_task', '/Staff/{action:(\w+)}/{task_id:(\d+)}')
+ config.add_route('list_task', '/Staff')
+ config.add_route('handle_pole', '/Staff/poles{sep:/*}{pole_id:(\d+)?}')
+ config.add_route('handle_task', '/Staff/tasks{sep:/*}{task_id:(\d+)?}')
+ config.add_route('action_task', '/Staff/{action:(\w+)}/{task_id:(\d+)}')
config.add_route('action_task_area', '/Staff/pole/{action:(\w+)}/{pole_id:(\d+)}')
+ config.add_route('list_salles', '/ListSalles')
+ 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+)}')
+
# HTML Routes - Public
config.add_route('home', '/')
config.add_route('presse', '/{year:\d+}/dossier-de-presse')
@@ -73,7 +78,8 @@ def main(global_config, **settings):
## Events
config.add_route('event', '/event/{year:\d+}/{event_id:([\w-]+)?}')
- config.add_route('link_event', '/MesJM2L/{year:\d+}/{intervention:\w+}/link')
+ config.add_route('link_event_user', '/MesJM2L/{year:\d+}/{intervention:\w+}/link_user')
+ config.add_route('link_event_tiers', '/MesJM2L/{year:\d+}/{intervention:\w+}/link_tiers')
config.add_route('edit_event', '/MesJM2L/{year:\d+}/{intervention:\w+}{sep:/*}{event_id:([\w-]+)?}')
## Entities
diff --git a/jm2l/forms.py b/jm2l/forms.py
index 51a40a4..5c625fb 100644
--- a/jm2l/forms.py
+++ b/jm2l/forms.py
@@ -79,6 +79,13 @@ class TiersMember(MyBaseForm):
year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016)))
user_uid = TextField(u'user')
role = TextField(u'Role')
+
+class TiersRole(MyBaseForm):
+ class Meta:
+ csrf = False
+
+ year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016)))
+ tiers_role = SelectField(u'Role', choices=TIERS_ROLE)
class TiersChoice(MyBaseForm):
class Meta:
@@ -96,6 +103,13 @@ class AddIntervenant(MyBaseForm):
event_uid = HiddenField()
intervenant = SelectField(u'Intervenant', coerce=int )
+class AddTiers(MyBaseForm):
+ class Meta:
+ csrf = False
+
+ event_uid = HiddenField()
+ tiers = SelectField(u'Entité', coerce=int )
+
class ConfCreateForm(MyBaseForm):
event_type = HiddenField()
@@ -133,6 +147,29 @@ class ConfCreateForm(MyBaseForm):
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','Conference'),
+ ('Stand','Stand'), ('Ateliers','Ateliers'), ('Autres','Autres') ])
+ name = TextField('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 = TextField('Nom de la salle', [validators.Length(min=1, max=40)],
+ filters=[strip_filter])
+ nb_places = TextField('Nombre de places', [validators.Length(max=4)])
+ description = TextAreaField('Description',
+ filters=[strip_filter])
+
+class EditSallePhyForm(SallePhyForm):
+ uid = HiddenField()
+
class PlaceCreateForm(MyBaseForm):
place_type = SelectField('Type', choices=PLACE_TYPE)
@@ -342,7 +379,9 @@ class TiersForm(MyBaseForm):
description = u"Vous pouvez insérer les détails"
)
- membership = FieldList(FormField(TiersMember))
+ membership = FieldList(FormField(TiersMember))
+
+ roles = FieldList(FormField(TiersRole))
class UpdateTiersForm(TiersForm):
uid = HiddenField()
diff --git a/jm2l/models.py b/jm2l/models.py
index c57783b..481658b 100644
--- a/jm2l/models.py
+++ b/jm2l/models.py
@@ -345,6 +345,7 @@ class Salles(Base):
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
+ phy = relationship(SallePhy)
@classmethod
def by_id(cls, uid):
return DBSession.query(cls).filter(cls.salle_id == uid).first()
diff --git a/jm2l/templates/Salles/list.mako b/jm2l/templates/Salles/list.mako
new file mode 100644
index 0000000..1bfd62b
--- /dev/null
+++ b/jm2l/templates/Salles/list.mako
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+<%inherit file="jm2l:templates/layout.mako"/>
+<%
+from slugify import slugify
+%>
+
+ Ajouter une Salle
+
+Gestion des salles JM2L
+
+
+
+
+
+
+ % for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)):
+ -
+ ${Entity.year_uid}
+
+ % endfor
+
+
+
+
+% for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)):
+
+
${Entity.year_uid}
+
+
+
+
+ Liste des salles
+ |
+
+
+
+ % if len(DicSalle[Entity])==0:
+
+
+ Il n'y a pas de salle définie pour l'année ${Entity.year_uid}
+ |
+
+ % endif
+ % for Salle in DicSalle[Entity]:
+
+
+ ${Salle.place_type or ""} ${Salle.name or ""}
+ ${len(Salle.allevents)} : [
+ % for e in Salle.allevents:
+ ${e.uid},
+ % endfor
+ ]
+
+ % if Salle.phy_salle_id:
+ [ ${Salle.phy.name} ${Salle.phy.nb_places} places ]
+ % else:
+ [ Créer ]
+ % endif
+
+ |
+
+ % if Salle.description:
+
+ ${Salle.description | n} |
+
+ % endif
+ % endfor
+
+
+
+% endfor
+
+
+
+
+
+<%def name="jsAddOn()">
+
+%def>
diff --git a/jm2l/templates/Salles/salle.mako b/jm2l/templates/Salles/salle.mako
new file mode 100644
index 0000000..d033aec
--- /dev/null
+++ b/jm2l/templates/Salles/salle.mako
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+<%inherit file="jm2l:templates/layout.mako"/>
+<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
+<%def name="jsAddOn()">
+
+
+
+%def>
+<%def name="cssAddOn()">
+
+
+%def>
+
+
+
+
+
+ Retour à la liste
+
+% if 'salle_id' in form._fields.keys():
+
+ Supprimer cette salle
+
+%endif
+% if 'salle_id' in form._fields.keys():
+
Editer une Salle
+% else:
+
Ajouter une Salle
+%endif
+<%
+DicForm = {
+ 'year_uid': {'PlaceHolder':u"Année", "FieldStyle":"width:7em;", "ContainerStyle":"float:left;" },
+ 'phy_salle_id': {'PlaceHolder':u"Salle Physique", "FieldStyle":"width:20em;", "ContainerStyle":"float:left;" },
+ 'place_type': {'PlaceHolder':u"Type d'évenement","FieldStyle":"width:15em;" },
+ 'name': {'PlaceHolder':u"Nom de la salle", "FieldStyle":"width:90%;" },
+ 'description': {'PlaceHolder':u"Description", "ContainerStyle":"width:95%;min-height:150px;padding-top: 12px;", "ckeditor":"1" },
+ }
+%>
+
+% if 'salle_id' in form._fields.keys():
+
+
+
+
diff --git a/jm2l/templates/Salles/salle_phy.mako b/jm2l/templates/Salles/salle_phy.mako
new file mode 100644
index 0000000..a7c1f47
--- /dev/null
+++ b/jm2l/templates/Salles/salle_phy.mako
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+<%inherit file="jm2l:templates/layout.mako"/>
+<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
+<%def name="jsAddOn()">
+
+
+
+%def>
+<%def name="cssAddOn()">
+
+
+
+
+
+
+
+%def>
+
+
+
+
+
+ Retour à la liste
+
+% if 'uid' in form._fields.keys():
+
Editer une Salle Physique
+% else:
+
Ajouter une Salle Physique
+%endif
+<%
+DicForm = {
+ 'name': {'PlaceHolder':u"Nom de la salle", "FieldStyle":"width:25em;", "ContainerStyle":"float:left;" },
+ 'nb_places': {'PlaceHolder':u"Nombre de places", "FieldStyle":"width:10em;" },
+ 'description': {'PlaceHolder':u"Description", "ContainerStyle":"width:95%;min-height:150px;padding-top: 12px;", "ckeditor":"1" },
+ }
+%>
+
+% if 'uid' in form._fields.keys():
+
+% if 'uid' in form._fields.keys():
+
+ ${helpers.uploader("salle", form.uid.data, u"Attachement" )}
+
+%endif
+
+
+
diff --git a/jm2l/templates/edit_event.mako b/jm2l/templates/edit_event.mako
index 6faa5d4..d1ace7f 100644
--- a/jm2l/templates/edit_event.mako
+++ b/jm2l/templates/edit_event.mako
@@ -99,12 +99,31 @@ DicForm = {
% endif
% if 'uid' in form._fields:
+
+
+
+
+
+