| @@ -56,12 +56,17 @@ def main(global_config, **settings): | |||||
| config.add_route('vote_logo', '/vote_logo/{num:\d+}') | config.add_route('vote_logo', '/vote_logo/{num:\d+}') | ||||
| # HTML Routes - Staff | # 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('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 | # HTML Routes - Public | ||||
| config.add_route('home', '/') | config.add_route('home', '/') | ||||
| config.add_route('presse', '/{year:\d+}/dossier-de-presse') | config.add_route('presse', '/{year:\d+}/dossier-de-presse') | ||||
| @@ -73,7 +78,8 @@ def main(global_config, **settings): | |||||
| ## Events | ## Events | ||||
| config.add_route('event', '/event/{year:\d+}/{event_id:([\w-]+)?}') | 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-]+)?}') | config.add_route('edit_event', '/MesJM2L/{year:\d+}/{intervention:\w+}{sep:/*}{event_id:([\w-]+)?}') | ||||
| ## Entities | ## Entities | ||||
| @@ -79,6 +79,13 @@ class TiersMember(MyBaseForm): | |||||
| year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016))) | year_uid = SelectField(u'Année', coerce=int, choices=zip(range(2006,2016),range(2006,2016))) | ||||
| user_uid = TextField(u'user') | user_uid = TextField(u'user') | ||||
| role = TextField(u'Role') | 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 TiersChoice(MyBaseForm): | ||||
| class Meta: | class Meta: | ||||
| @@ -96,6 +103,13 @@ class AddIntervenant(MyBaseForm): | |||||
| event_uid = HiddenField() | event_uid = HiddenField() | ||||
| intervenant = SelectField(u'Intervenant', coerce=int ) | 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): | class ConfCreateForm(MyBaseForm): | ||||
| event_type = HiddenField() | event_type = HiddenField() | ||||
| @@ -133,6 +147,29 @@ class ConfCreateForm(MyBaseForm): | |||||
| class ConfUpdateForm(ConfCreateForm): | class ConfUpdateForm(ConfCreateForm): | ||||
| uid = HiddenField() | 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): | class PlaceCreateForm(MyBaseForm): | ||||
| place_type = SelectField('Type', choices=PLACE_TYPE) | place_type = SelectField('Type', choices=PLACE_TYPE) | ||||
| @@ -342,7 +379,9 @@ class TiersForm(MyBaseForm): | |||||
| description = u"Vous pouvez insérer les détails" | description = u"Vous pouvez insérer les détails" | ||||
| ) | ) | ||||
| membership = FieldList(FormField(TiersMember)) | |||||
| membership = FieldList(FormField(TiersMember)) | |||||
| roles = FieldList(FormField(TiersRole)) | |||||
| class UpdateTiersForm(TiersForm): | class UpdateTiersForm(TiersForm): | ||||
| uid = HiddenField() | uid = HiddenField() | ||||
| @@ -345,6 +345,7 @@ class Salles(Base): | |||||
| created = Column(DateTime, default=datetime.datetime.now) | created = Column(DateTime, default=datetime.datetime.now) | ||||
| last_change = Column(DateTime, default=datetime.datetime.now) | last_change = Column(DateTime, default=datetime.datetime.now) | ||||
| phy = relationship(SallePhy) | |||||
| @classmethod | @classmethod | ||||
| def by_id(cls, uid): | def by_id(cls, uid): | ||||
| return DBSession.query(cls).filter(cls.salle_id == uid).first() | return DBSession.query(cls).filter(cls.salle_id == uid).first() | ||||
| @@ -0,0 +1,90 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| <%inherit file="jm2l:templates/layout.mako"/> | |||||
| <% | |||||
| from slugify import slugify | |||||
| %> | |||||
| <a style="float:right;" class="btn btn-mini btn-info" role="button" href="/Salles"> | |||||
| <i class="icon-plus-sign icon-white"></i> Ajouter une Salle | |||||
| </a> | |||||
| <h3>Gestion des salles JM2L</h3> | |||||
| <div class="row-fluid"> | |||||
| <div class="span10 offset1"> | |||||
| <div class="tabbable" id="main_tab"> | |||||
| <ul class="nav nav-tabs" style="margin-bottom: 5px;"> | |||||
| % for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)): | |||||
| <li class="${["","active"][Num==0]}"> | |||||
| <a href="#${Entity.year_uid}" id="Map_Pole_${Entity.year_uid}" data-toggle="tab">${Entity.year_uid}</a> | |||||
| </li> | |||||
| % endfor | |||||
| </ul> | |||||
| <div class="tab-content" style="padding:0 10px"> | |||||
| % for Num, Entity in enumerate(sorted(DicSalle.keys(), key=lambda x:x.year_uid)): | |||||
| <div class="tab-pane fade ${["","active "][Num==0]} in" id="${Entity.year_uid}"> | |||||
| <h4>${Entity.year_uid}</h4> | |||||
| <table class="table table-striped table-bordered table-hover"> | |||||
| <thead> | |||||
| <tr> | |||||
| <th colspan="2" style="text-align:center;"> | |||||
| Liste des salles | |||||
| </th> | |||||
| </tr> | |||||
| </thead> | |||||
| <tbody> | |||||
| % if len(DicSalle[Entity])==0: | |||||
| <tr> | |||||
| <td style="text-align:center;"> | |||||
| <i>Il n'y a pas de salle définie pour l'année ${Entity.year_uid}</i> | |||||
| </td> | |||||
| </tr> | |||||
| % endif | |||||
| % for Salle in DicSalle[Entity]: | |||||
| <tr> | |||||
| <td> | |||||
| ${Salle.place_type or ""} <a href="/Salles/${Salle.salle_id}">${Salle.name or ""}</a> | |||||
| ${len(Salle.allevents)} : [ | |||||
| % for e in Salle.allevents: | |||||
| <a href="/event/${e.for_year}/${e.slug}">${e.uid}</a>, | |||||
| % endfor | |||||
| ] | |||||
| <div class="pull-right"> | |||||
| % if Salle.phy_salle_id: | |||||
| [ <a href="/PhySalles/${Salle.phy_salle_id}">${Salle.phy.name}</a> ${Salle.phy.nb_places} places ] | |||||
| % else: | |||||
| [ <a href="/PhySalles">Créer</a> ] | |||||
| % endif | |||||
| </div> | |||||
| </td> | |||||
| </tr> | |||||
| % if Salle.description: | |||||
| <tr> | |||||
| <td><div>${Salle.description | n}</div></td> | |||||
| </tr> | |||||
| % endif | |||||
| % endfor | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| % endfor | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <%def name="jsAddOn()"> | |||||
| <script> | |||||
| $('a[data-toggle="tab"]') | |||||
| .on('shown', function(e) { | |||||
| //stateObj = { tab: $(e.target).attr('href').substr(1) }; | |||||
| //history.replaceState(stateObj, "", "/Staff" + $(e.target).attr('href') ); | |||||
| location.hash = $(e.target).attr('href'); | |||||
| }); | |||||
| if (location.hash !== '') { | |||||
| $('a[href="' + location.hash + '"]').tab('show'); | |||||
| } | |||||
| </script> | |||||
| </%def> | |||||
| @@ -0,0 +1,58 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| <%inherit file="jm2l:templates/layout.mako"/> | |||||
| <%namespace name="helpers" file="jm2l:templates/helpers.mako"/> | |||||
| <%def name="jsAddOn()"> | |||||
| <script src="/js/jm2l.js"></script> | |||||
| <script src="/vendor/ckeditor/ckeditor.js"></script> | |||||
| <script src="/vendor/select2/js/select2.js"></script> | |||||
| </%def> | |||||
| <%def name="cssAddOn()"> | |||||
| <link rel="stylesheet" href="/css/jm2l.css" /> | |||||
| <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" /> | |||||
| </%def> | |||||
| <div class="row-fluid"> | |||||
| <div class="span10 offset1"> | |||||
| <a class="btn" href="${request.route_path('list_salles')}"> | |||||
| <i class="icon-arrow-left"></i> Retour à la liste | |||||
| </a> | |||||
| % if 'salle_id' in form._fields.keys(): | |||||
| <a class="btn btn-danger btn-mini pull-right" href="${request.route_path('action_salle', action='delete', salle_id=form.salle_id.data)}"> | |||||
| <i class="icon-remove icon-white"></i> Supprimer cette salle | |||||
| </a> | |||||
| %endif | |||||
| % if 'salle_id' in form._fields.keys(): | |||||
| <h3>Editer une Salle</h3> | |||||
| % else: | |||||
| <h3>Ajouter une Salle</h3> | |||||
| %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(): | |||||
| <form action="/Salles/${form.salle_id.data}" method="post"> | |||||
| ${form.salle_id()} | |||||
| %else: | |||||
| <form action="/Salles" method="post"> | |||||
| %endif | |||||
| ${helpers.DisplayForm(form, DicForm)} | |||||
| <br> | |||||
| <center> | |||||
| <button type="submit" class="btn btn-large btn-primary" /> | |||||
| <i class="icon-ok icon-white"></i> Enregistrer | |||||
| </button> | |||||
| </center> | |||||
| </form> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,61 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| <%inherit file="jm2l:templates/layout.mako"/> | |||||
| <%namespace name="helpers" file="jm2l:templates/helpers.mako"/> | |||||
| <%def name="jsAddOn()"> | |||||
| <script src="/js/jm2l.js"></script> | |||||
| <script src="/vendor/ckeditor/ckeditor.js"></script> | |||||
| <script src="/vendor/select2/js/select2.js"></script> | |||||
| </%def> | |||||
| <%def name="cssAddOn()"> | |||||
| <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css"> | |||||
| <link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui.css"> | |||||
| <link rel="stylesheet" href="/css/jm2l.css" /> | |||||
| <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" /> | |||||
| <!-- CSS adjustments for browsers with JavaScript disabled --> | |||||
| <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-noscript.css"></noscript> | |||||
| <noscript><link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript> | |||||
| </%def> | |||||
| <div class="row-fluid"> | |||||
| <div class="span10 offset1"> | |||||
| <a class="btn" href="${request.route_path('list_salles')}"> | |||||
| <i class="icon-arrow-left"></i> Retour à la liste | |||||
| </a> | |||||
| % if 'uid' in form._fields.keys(): | |||||
| <h3>Editer une Salle Physique</h3> | |||||
| % else: | |||||
| <h3>Ajouter une Salle Physique</h3> | |||||
| %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(): | |||||
| <form action="/PhySalles/${form.uid.data}" method="post"> | |||||
| ${form.uid()} | |||||
| %else: | |||||
| <form action="/PhySalles" method="post"> | |||||
| %endif | |||||
| ${helpers.DisplayForm(form, DicForm)} | |||||
| <br> | |||||
| <center> | |||||
| <button type="submit" class="btn btn-large btn-primary" /> | |||||
| <i class="icon-ok icon-white"></i> Enregistrer | |||||
| </button> | |||||
| </center> | |||||
| </form> | |||||
| % if 'uid' in form._fields.keys(): | |||||
| <center> | |||||
| ${helpers.uploader("salle", form.uid.data, u"Attachement" )} | |||||
| </center> | |||||
| %endif | |||||
| </div> | |||||
| </div> | |||||
| @@ -99,12 +99,31 @@ DicForm = { | |||||
| % endif | % endif | ||||
| % if 'uid' in form._fields: | % if 'uid' in form._fields: | ||||
| <fieldset> | |||||
| <legend>Indiquez l'entité dont vous faites la promotion :</legend> | |||||
| <p> | |||||
| <form action="/MesJM2L/${form.for_year.data}/${form.event_type.data}/link_tiers" method="POST"> | |||||
| ${formAddT.event_uid} | |||||
| <input type="hidden" id="tiers" name="tiers" style="width:20em;" | |||||
| class="form-control select2-offscreen" tabindex="-1"> | |||||
| </input> | |||||
| <button type="submit" class="btn btn-primary" /> | |||||
| <i class="icon-plus icon-white"></i> Ajouter cette entitée | |||||
| </button> | |||||
| </form> | |||||
| NB : Notez que les entités séléctionnées apparaissent dans les exposants. | |||||
| </p> | |||||
| </fieldset> | |||||
| <fieldset> | <fieldset> | ||||
| <legend>Ajouter vos co-intervenants</legend> | <legend>Ajouter vos co-intervenants</legend> | ||||
| <p> | <p> | ||||
| Vous avez la possibilité d'être plusieurs pour un même évenement.<br> | Vous avez la possibilité d'être plusieurs pour un même évenement.<br> | ||||
| Chacun des intervenants doit être inscrit sur le site. | Chacun des intervenants doit être inscrit sur le site. | ||||
| <form action="/MesJM2L/${form.for_year.data}/${form.event_type.data}/link" method="POST"> | |||||
| <form action="/MesJM2L/${form.for_year.data}/${form.event_type.data}/link_user" method="POST"> | |||||
| ${formAdd.event_uid} | ${formAdd.event_uid} | ||||
| <input type="hidden" id="intervenant" name="intervenant" style="width:20em;" | <input type="hidden" id="intervenant" name="intervenant" style="width:20em;" | ||||
| class="form-control select2-offscreen" tabindex="-1"> | class="form-control select2-offscreen" tabindex="-1"> | ||||
| @@ -134,6 +153,21 @@ DicForm = { | |||||
| <script src="/vendor/select2/js/select2.js"></script> | <script src="/vendor/select2/js/select2.js"></script> | ||||
| <script> | <script> | ||||
| jQuery(function() { | jQuery(function() { | ||||
| $("#tiers").select2( | |||||
| { | |||||
| placeholder: 'Entrez ici votre entitée', | |||||
| minimumInputLength: 2, allowClear: true, | |||||
| ajax: { | |||||
| quietMillis: 250, url: "/json-tiers", dataType: 'json', | |||||
| data: function (term, page) { | |||||
| return { pageSize: 8, pageNum: page, searchTerm: term }; | |||||
| }, | |||||
| results: function (data, page) { | |||||
| var more = (page * 8) < data.Total; | |||||
| return { results: data.Results, more: more }; | |||||
| } | |||||
| } | |||||
| }); | |||||
| $("#intervenant").select2( | $("#intervenant").select2( | ||||
| { | { | ||||
| placeholder: 'Entrez ici un Nom ou un Prénom', | placeholder: 'Entrez ici un Nom ou un Prénom', | ||||
| @@ -24,8 +24,9 @@ DicForm = { | |||||
| 'name': {'PlaceHolder':u"Nom", 'ContainerStyle':"padding-right:5px;float:left;width:35em;", "FieldStyle":"width:31em;"}, | 'name': {'PlaceHolder':u"Nom", 'ContainerStyle':"padding-right:5px;float:left;width:35em;", "FieldStyle":"width:31em;"}, | ||||
| 'tiers_type': {'PlaceHolder':u"Nature", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:15em;"}, | 'tiers_type': {'PlaceHolder':u"Nature", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:15em;"}, | ||||
| 'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;padding-top: 20px;", "FieldStyle":"width:90%;min-height:150px;" }, | 'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;padding-top: 20px;", "FieldStyle":"width:90%;min-height:150px;" }, | ||||
| 'website': {'PlaceHolder':u"Site web", 'ContainerStyle':"padding-right:15px;", 'ContainerStyle':"width:30em;"}, | |||||
| 'membership': {'Ignore':True} | |||||
| 'website': {'PlaceHolder':u"Site web", 'ContainerStyle':"padding-right:15px;padding-top: 20px;", 'FieldStyle':"width:30em;"}, | |||||
| 'membership': {'Ignore':True }, | |||||
| 'roles': {'Ignore':True } | |||||
| } | } | ||||
| %> | %> | ||||
| @@ -33,18 +34,18 @@ DicForm = { | |||||
| % if 'uid' in form._fields: | % if 'uid' in form._fields: | ||||
| <fieldset> | <fieldset> | ||||
| <legend>Acteurs</legend> | |||||
| <legend>Ses acteurs</legend> | |||||
| <div class="repeat"> | <div class="repeat"> | ||||
| <table class="wrapper table table-striped table-bordered" width="100%"> | |||||
| <table class="wrapper table" width="100%"> | |||||
| <thead> | <thead> | ||||
| <tr class="row"> | <tr class="row"> | ||||
| <th style="width:5em;text-align:center;">Année</th> | <th style="width:5em;text-align:center;">Année</th> | ||||
| <th style="width:22em;">Personne</th> | |||||
| <th style="width:22em;">Rôle</th> | |||||
| <th style="width:10em;">Action</th> | |||||
| <th style="width:22em;text-align:center;">Personne</th> | |||||
| <th style="width:22em;text-align:center;">Rôle</th> | |||||
| <th style="width:10em;text-align:center;">Action</th> | |||||
| </tr> | </tr> | ||||
| </thead> | </thead> | ||||
| <tbody class="container"> | |||||
| <tbody class="container" id="tab_member"> | |||||
| <tr class="row template" style="line-height:2.2em;"> | <tr class="row template" style="line-height:2.2em;"> | ||||
| <td> | <td> | ||||
| <select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid" | <select class="form-control" style="width:5em;" name="membership-{{row-count-placeholder}}-year_uid" | ||||
| @@ -77,7 +78,7 @@ DicForm = { | |||||
| <input type="hidden" class="form-control" name="membership-${num}-year_uid" | <input type="hidden" class="form-control" name="membership-${num}-year_uid" | ||||
| id="membership-${num}-year_uid" | id="membership-${num}-year_uid" | ||||
| value="${dicdata.get('year_uid')}" style="width:4em;" /> | value="${dicdata.get('year_uid')}" style="width:4em;" /> | ||||
| <div id="content-${num}-year_uid">${dicdata.get('year_uid')}</div> | |||||
| <div id="content-member-${num}-year_uid">${dicdata.get('year_uid')}</div> | |||||
| </td> | </td> | ||||
| <td style="text-align:center;"> | <td style="text-align:center;"> | ||||
| <input type="hidden" class="form-control" name="membership-${num}-user_uid" | <input type="hidden" class="form-control" name="membership-${num}-user_uid" | ||||
| @@ -86,17 +87,17 @@ DicForm = { | |||||
| tmpUser = DBUser.by_id(dicdata.get('user_uid')) | tmpUser = DBUser.by_id(dicdata.get('user_uid')) | ||||
| %> | %> | ||||
| % if tmpUser: | % if tmpUser: | ||||
| <div id="content-${num}-user_uid">${tmpUser.prenom} ${tmpUser.nom}</div> | |||||
| <div id="content-member-${num}-user_uid">${tmpUser.prenom} ${tmpUser.nom}</div> | |||||
| % endif | % endif | ||||
| </td> | </td> | ||||
| <td style="text-align:center;"> | <td style="text-align:center;"> | ||||
| <input type="text" class="form-control" name="membership-${num}-role" style="display:none" | |||||
| <input type="text" class="form-control" name="membership-${num}-role" style="display:none;width:95%;" | |||||
| id="membership-${num}-role" | id="membership-${num}-role" | ||||
| value="${dicdata.get('role', 'Aucun')}" /> | value="${dicdata.get('role', 'Aucun')}" /> | ||||
| <div id="content-${num}-role"><i>${dicdata.get('role', 'Aucun')}</i></div> | |||||
| <div id="content-member-${num}-role"><i>${dicdata.get('role', 'Aucun')}</i></div> | |||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| <a class="btn btn-mini btn-primary" href="javascript:edit(${num})"> | |||||
| <a class="btn btn-mini btn-primary" href="#" onclick="return edit_member(this, ${num});"> | |||||
| <i class="icon-pencil icon-white"></i> Edit. | <i class="icon-pencil icon-white"></i> Edit. | ||||
| </a> | </a> | ||||
| <span class="remove btn btn-mini btn-danger"> | <span class="remove btn btn-mini btn-danger"> | ||||
| @@ -117,6 +118,85 @@ DicForm = { | |||||
| </div> | </div> | ||||
| </fieldset> | </fieldset> | ||||
| % endif | % endif | ||||
| % if 'uid' in form._fields: | |||||
| <fieldset> | |||||
| <legend>Ses rôles</legend> | |||||
| <div class="repeat"> | |||||
| <table class="wrapper table" width="100%"> | |||||
| <thead> | |||||
| <tr class="row"> | |||||
| <th style="width:5em;text-align:center;">Année</th> | |||||
| <th style="width:22em;text-align:center;">Rôle</th> | |||||
| <th style="width:10em;text-align:center;">Action</th> | |||||
| </tr> | |||||
| </thead> | |||||
| <tbody class="container" id="tab_role"> | |||||
| <tr class="row template" style="line-height:2.2em;"> | |||||
| <td> | |||||
| <select class="form-control" style="width:5em;" name="roles-{{row-count-placeholder}}-year_uid" | |||||
| id="roles-{{row-count-placeholder}}-year_uid"> | |||||
| % for year in range(2015, 2005, -1): | |||||
| <% | |||||
| if year in [2014]: | |||||
| continue | |||||
| %> \ | |||||
| <option value="${year}">${year}</option> | |||||
| %endfor | |||||
| </select> | |||||
| </td> | |||||
| <td style="text-align: center;"> | |||||
| <select class="form-control" name="roles-{{row-count-placeholder}}-tiers_role" /> | |||||
| <option value="Exposant">Exposant</option> | |||||
| <option value="Sponsor">Sponsor</option> | |||||
| <option value="Donateur">Donateur</option> | |||||
| </select> | |||||
| </td> | |||||
| <td> | |||||
| <span class="remove btn btn-mini btn-danger"> | |||||
| <i class="icon-remove-sign icon-white"></i> Suppr. | |||||
| </span> | |||||
| </td> | |||||
| </tr> | |||||
| % for num, dicdata in enumerate(form._fields.get("roles").data): | |||||
| <tr class="row" style="padding:5px;line-height:2.2em;"> | |||||
| <td style="text-align:center;"> | |||||
| <input type="hidden" class="form-control" name="roles-${num}-year_uid" | |||||
| id="roles-${num}-year_uid" | |||||
| value="${dicdata.get('year_uid')}" style="width:4em;" /> | |||||
| <div id="content-role-${num}-year_uid">${dicdata.get('year_uid')}</div> | |||||
| </td> | |||||
| <td style="text-align:center;"> | |||||
| <input type="hidden" class="form-control" name="roles-${num}-tiers_role" | |||||
| id="roles-${num}-tiers_role" | |||||
| value="${dicdata.get('tiers_role', 'Aucun')}" /> | |||||
| <div id="content-role-${num}-tiers_role"><i>${dicdata.get('tiers_role', 'Aucun')}</i></div> | |||||
| </td> | |||||
| <td> | |||||
| <a class="btn btn-mini btn-primary" href="#" onclick="return edit_role(this, ${num});"> | |||||
| <i class="icon-pencil icon-white"></i> Edit. | |||||
| </a> | |||||
| <span class="remove btn btn-mini btn-danger"> | |||||
| <i class="icon-remove-sign icon-white"></i> Suppr. | |||||
| </span> | |||||
| </td> | |||||
| </tr> | |||||
| % endfor | |||||
| </tbody> | |||||
| <tfoot> | |||||
| <tr> | |||||
| <td colspan="5" style="text-align:center;line-height: 3em;"> | |||||
| <span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Ajouter</span> | |||||
| </td> | |||||
| </tr> | |||||
| </tfoot> | |||||
| </table> | |||||
| </div> | |||||
| </fieldset> | |||||
| % endif | |||||
| % if 'uid' in form._fields: | % if 'uid' in form._fields: | ||||
| <button class="btn btn-primary" type="submit">Enregistrer</button> | <button class="btn btn-primary" type="submit">Enregistrer</button> | ||||
| % else: | % else: | ||||
| @@ -126,12 +206,12 @@ DicForm = { | |||||
| % if 'uid' in form._fields: | % if 'uid' in form._fields: | ||||
| % if request.user: | % if request.user: | ||||
| <fieldset> | <fieldset> | ||||
| <legend>Support liés</legend> | |||||
| <legend>Les supports liés</legend> | |||||
| <div style="float:right;width:60%"> | <div style="float:right;width:60%"> | ||||
| <p> En plus de vos support de présentation classique. | <p> En plus de vos support de présentation classique. | ||||
| Pensez aussi aux affiches, aux flyers, aux stickers, | Pensez aussi aux affiches, aux flyers, aux stickers, | ||||
| au bulletin d'adhésion à une association, à la documentation technique... | au bulletin d'adhésion à une association, à la documentation technique... | ||||
| Tous ce qui peut être utile, de près ou de loin à la promotion de votre évenement. | |||||
| Tous ce qui peut être utile, de près ou de loin à sa promotion. | |||||
| </p> | </p> | ||||
| </div> | </div> | ||||
| ${helpers.uploader("tiers", form.uid.data, u"fichiers" )} | ${helpers.uploader("tiers", form.uid.data, u"fichiers" )} | ||||
| @@ -153,9 +233,13 @@ DicForm = { | |||||
| <script src="/vendor/ckeditor/ckeditor.js"></script> | <script src="/vendor/ckeditor/ckeditor.js"></script> | ||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||
| var year_data = Array(); | var year_data = Array(); | ||||
| var role_data = Array(); | |||||
| var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } ); | var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } ); | ||||
| for (var i=2005;i<2016;i++) | for (var i=2005;i<2016;i++) | ||||
| year_data.push( {id:i, text:i.toString()}); | year_data.push( {id:i, text:i.toString()}); | ||||
| role_data.push({id:'Exposant', text:'Exposant'}); | |||||
| role_data.push({id:'Sponsor', text:'Sponsor'}); | |||||
| role_data.push({id:'Donateur', text:'Donateur'}); | |||||
| $("#tiers_type").select2({}); | $("#tiers_type").select2({}); | ||||
| @@ -173,42 +257,49 @@ jQuery(function() { | |||||
| { | { | ||||
| is_ready: function(container, therow) { | is_ready: function(container, therow) { | ||||
| var numrow=$(container).attr('data-rf-row-count'); | var numrow=$(container).attr('data-rf-row-count'); | ||||
| $("#membership-"+ (numrow-1) +"-user_uid").select2( | |||||
| { | |||||
| placeholder: 'Entrez ici un Nom ou un Prénom', | |||||
| minimumInputLength: 2, allowClear: true, | |||||
| ajax: { | |||||
| quietMillis: 250, url: "/json-users", dataType: 'json', | |||||
| data: function (term, page) { | |||||
| return { pageSize: 8, pageNum: page, searchTerm: term }; | |||||
| }, | |||||
| results: function (data, page) { | |||||
| var more = (page * 8) < data.Total; | |||||
| return { results: data.Results, more: more }; | |||||
| if ($(container).attr("id")=="tab_member") { | |||||
| $("#membership-"+ (numrow-1) +"-user_uid").select2( | |||||
| { | |||||
| placeholder: 'Entrez ici un Nom ou un Prénom', | |||||
| minimumInputLength: 2, allowClear: true, | |||||
| ajax: { | |||||
| quietMillis: 250, url: "/json-users", dataType: 'json', | |||||
| data: function (term, page) { | |||||
| return { pageSize: 8, pageNum: page, searchTerm: term }; | |||||
| }, | |||||
| results: function (data, page) { | |||||
| var more = (page * 8) < data.Total; | |||||
| return { results: data.Results, more: more }; | |||||
| } | |||||
| } | } | ||||
| } | |||||
| }); | |||||
| $("#membership-"+ (numrow-1) +"-year_uid").select2({}); | |||||
| }); | |||||
| $("#membership-"+ (numrow-1) +"-year_uid").select2({}); | |||||
| } | |||||
| if ($(container).attr("id")=="tab_role") { | |||||
| $("#roles-"+ (numrow-1) +"-year_uid").select2({}); | |||||
| $("#roles-"+ (numrow-1) +"-tiers_role").select2({}); | |||||
| } | |||||
| } | } | ||||
| }); | }); | ||||
| }); | }); | ||||
| }); | }); | ||||
| function edit(num) { | |||||
| $("#content-"+ num +"-year_uid").hide(); | |||||
| function edit_member(srcobj, num) { | |||||
| $(srcobj).addClass("disabled"); | |||||
| $("#content-member-"+ num +"-year_uid").hide(); | |||||
| $("#membership-"+ num +"-year_uid").select2({ | $("#membership-"+ num +"-year_uid").select2({ | ||||
| width:'80px', | width:'80px', | ||||
| data: year_data | data: year_data | ||||
| }); | }); | ||||
| $('select').select2(); | |||||
| $("#content-"+ num +"-user_uid").hide(); | |||||
| //$('select').select2(); | |||||
| $("#content-member-"+ num +"-user_uid").hide(); | |||||
| $("#membership-"+ num +"-user_uid").select2( | $("#membership-"+ num +"-user_uid").select2( | ||||
| { | { | ||||
| width:'250px', | width:'250px', | ||||
| placeholder: 'Entrez ici un Nom ou un Prénom', | placeholder: 'Entrez ici un Nom ou un Prénom', | ||||
| minimumInputLength: 2, allowClear: true, | minimumInputLength: 2, allowClear: true, | ||||
| initSelection: function(element, callback){ | initSelection: function(element, callback){ | ||||
| callback({id: element.val(), text: $("#content-"+ num +"-user_uid").text() }) | |||||
| callback({id: element.val(), text: $("#content-member-"+ num +"-user_uid").text() }) | |||||
| }, | }, | ||||
| ajax: { | ajax: { | ||||
| quietMillis: 250, url: "/json-users", dataType: 'json', | quietMillis: 250, url: "/json-users", dataType: 'json', | ||||
| @@ -221,8 +312,25 @@ function edit(num) { | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| $("#content-"+ num +"-role").hide(); | |||||
| $("#content-member-"+ num +"-role").hide(); | |||||
| $("#membership-"+ num +"-role").show(); | $("#membership-"+ num +"-role").show(); | ||||
| return false; | |||||
| }; | |||||
| function edit_role(srcobj, num) { | |||||
| $(srcobj).addClass("disabled"); | |||||
| $("#roles-"+ num +"-year_uid").select2({ | |||||
| width:'80px', | |||||
| data: year_data | |||||
| }); | |||||
| $("#roles-"+ num +"-tiers_role").select2({ | |||||
| width:'100%', | |||||
| data: role_data | |||||
| }); | |||||
| $("#content-role-"+ num +"-year_uid").hide(); | |||||
| $("#content-role-"+ num +"-tiers_role").hide(); | |||||
| $("#roles-"+ num +"-tiers_role").show(); | |||||
| return false; | |||||
| }; | }; | ||||
| </script> | </script> | ||||
| </%def> | </%def> | ||||
| @@ -233,7 +233,7 @@ HandleControls(); | |||||
| function handlevote() { | function handlevote() { | ||||
| currentIndex = $('div.active').index() + 1; | currentIndex = $('div.active').index() + 1; | ||||
| $('.carousel-vote a').attr('href', "/vote_logo/" + currentIndex ) | $('.carousel-vote a').attr('href', "/vote_logo/" + currentIndex ) | ||||
| if (currentIndex==${request.user.vote_logo}) { | |||||
| if (currentIndex==${request.user.vote_logo or 0}) { | |||||
| $('.carousel-vote a').removeClass('btn-primary').addClass('btn-success') | $('.carousel-vote a').removeClass('btn-primary').addClass('btn-success') | ||||
| $('.carousel-vote a').html("<i class='icon-ok icon-white'></i> Mon préféré ! "); | $('.carousel-vote a').html("<i class='icon-ok icon-white'></i> Mon préféré ! "); | ||||
| } else { | } else { | ||||
| @@ -38,6 +38,13 @@ ${The_entity_type.entity_subtype} | |||||
| <p>Cette entité n'a pas de description.</p> | <p>Cette entité n'a pas de description.</p> | ||||
| % endif | % endif | ||||
| </div> | </div> | ||||
| <div class="footborderbox"> | |||||
| % if entity.website: | |||||
| <div style="float:right;"> | |||||
| <a href="${entity.website}">${entity.website}</a> | |||||
| </div> | |||||
| % endif | |||||
| </div> | |||||
| % if 0: | % if 0: | ||||
| % for media in entity.PhotosLinks: | % for media in entity.PhotosLinks: | ||||
| @@ -87,7 +94,7 @@ ${The_entity_type.entity_subtype} | |||||
| </div> | </div> | ||||
| </p> | </p> | ||||
| % endfor | % endfor | ||||
| <br/><br/> | |||||
| <p style="float:right;">Créé le ${entity.created.strftime('%d %b %Y').decode('utf-8')}</p> | <p style="float:right;">Créé le ${entity.created.strftime('%d %b %Y').decode('utf-8')}</p> | ||||
| <br/> | <br/> | ||||
| <hr/> | <hr/> | ||||
| @@ -11,7 +11,7 @@ import magic | |||||
| import subprocess | import subprocess | ||||
| import cStringIO as StringIO | import cStringIO as StringIO | ||||
| # Database access imports | # Database access imports | ||||
| from .models import User, Place, Tiers, Event | |||||
| from .models import User, Place, Tiers, Event, SallePhy | |||||
| MIN_FILE_SIZE = 1 # bytes | MIN_FILE_SIZE = 1 # bytes | ||||
| MAX_FILE_SIZE = 500000000 # bytes | MAX_FILE_SIZE = 500000000 # bytes | ||||
| @@ -84,11 +84,7 @@ class MediaPath(): | |||||
| if media_table=='place': | if media_table=='place': | ||||
| slug = Place.by_id(linked_id).slug | slug = Place.by_id(linked_id).slug | ||||
| if media_table=='salle': | if media_table=='salle': | ||||
| phyid = Salles.by_id(linked_id).phy_salle_id | |||||
| if phyid: | |||||
| slug = SallePhy.by_id(phyid) | |||||
| else: | |||||
| slug = linked_id | |||||
| slug = SallePhy.by_id(linked_id).slug | |||||
| p = IMAGEPATH + [ media_table ] + [ slug ] | p = IMAGEPATH + [ media_table ] + [ slug ] | ||||
| elif media_table=='presse': | elif media_table=='presse': | ||||
| # Use Year in linked_id | # Use Year in linked_id | ||||
| @@ -364,6 +364,74 @@ def action_task_area(request): | |||||
| DBSession.delete(Pole) | DBSession.delete(Pole) | ||||
| return HTTPFound(location=request.route_url('list_task')) | return HTTPFound(location=request.route_url('list_task')) | ||||
| @view_config(route_name='list_salles', renderer='jm2l:templates/Salles/list.mako') | |||||
| def list_salles(request): | |||||
| DicSalle = {} | |||||
| years = DBSession.query( JM2L_Year ).all() | |||||
| for year in years: | |||||
| salles = DBSession.query( Salles )\ | |||||
| .filter( Salles.year_uid==year.year_uid )\ | |||||
| .order_by(Salles.name).all() | |||||
| DicSalle[year] = salles | |||||
| return {'DicSalle': DicSalle } | |||||
| @view_config(route_name='handle_salle', renderer='jm2l:templates/Salles/salle.mako') | |||||
| def handle_salle(request): | |||||
| salle_id = request.matchdict.get('salle_id') | |||||
| if salle_id: | |||||
| Salle = Salles.by_id(int(salle_id)) | |||||
| if not Salle: | |||||
| raise HTTPNotFound() | |||||
| form = EditSalleForm(request.POST, Salle, meta={'csrf_context': request.session}) | |||||
| else: | |||||
| Salle = Salles() | |||||
| form = SalleForm(request.POST, Salle, meta={'csrf_context': request.session}) | |||||
| form.year_uid.choices = map(tuple, DBSession.query(JM2L_Year.year_uid, JM2L_Year.year_uid).all()) | |||||
| form.phy_salle_id.choices = map(tuple, DBSession.query(SallePhy.uid, SallePhy.name).all()) | |||||
| if request.method == 'POST' and form.validate(): | |||||
| form.populate_obj(Salle) | |||||
| if 'uid' in form._fields.keys(): | |||||
| DBSession.merge(Salle) | |||||
| else: | |||||
| DBSession.add(Salle) | |||||
| return HTTPFound(location=request.route_url('list_salles')) | |||||
| return {'form':form } | |||||
| @view_config(route_name='handle_salle_phy', renderer='jm2l:templates/Salles/salle_phy.mako') | |||||
| def handle_salle_phy(request): | |||||
| salle_id = request.matchdict.get('salle_id') | |||||
| if salle_id: | |||||
| Salle = SallePhy.by_id(int(salle_id)) | |||||
| if not Salle: | |||||
| raise HTTPNotFound() | |||||
| form = EditSallePhyForm(request.POST, Salle, meta={'csrf_context': request.session}) | |||||
| else: | |||||
| Salle = SallePhy() | |||||
| form = SallePhyForm(request.POST, Salle, meta={'csrf_context': request.session}) | |||||
| if request.method == 'POST' and form.validate(): | |||||
| form.populate_obj(Salle) | |||||
| Salle.slug = slugify(Salle.name) | |||||
| if 'uid' in form._fields.keys(): | |||||
| DBSession.merge(Salle) | |||||
| else: | |||||
| DBSession.add(Salle) | |||||
| return HTTPFound(location=request.route_url('list_salles')) | |||||
| return {'form':form } | |||||
| @view_config(route_name='action_salle') | |||||
| def action_salle(request): | |||||
| action = request.matchdict.get('action') | |||||
| salle_id = request.matchdict.get('salle_id') | |||||
| Salle = Salles.by_id(int(salle_id)) | |||||
| if not Salle: | |||||
| raise HTTPNotFound() | |||||
| if action=='delete': | |||||
| request.session.flash(('info', u'La Salle a été supprimée !')) | |||||
| DBSession.delete(Salle) | |||||
| return HTTPFound(location=request.route_url('list_salles')) | |||||
| ## =-=- Here, We handle HTTP requests - User Logged Part -=-= | ## =-=- Here, We handle HTTP requests - User Logged Part -=-= | ||||
| @view_config(route_name='exchange', renderer="jm2l:templates/Logistique/Logistique.mako") | @view_config(route_name='exchange', renderer="jm2l:templates/Logistique/Logistique.mako") | ||||
| def exchange(request): | def exchange(request): | ||||
| @@ -757,9 +825,9 @@ def show_event(request): | |||||
| 'event':TheEvent, 'logged_in':request.authenticated_userid } | 'event':TheEvent, 'logged_in':request.authenticated_userid } | ||||
| return MainTab | return MainTab | ||||
| @view_config(route_name='link_event') | |||||
| def link_event(request): | |||||
| """ Create user if not exist, add it to current event """ | |||||
| @view_config(route_name='link_event_user') | |||||
| def link_event_user(request): | |||||
| """ Get user and add it to current event """ | |||||
| year = int(request.matchdict.get('year', -1)) | year = int(request.matchdict.get('year', -1)) | ||||
| form = AddIntervenant(request.POST, meta={'csrf_context': request.session}) | form = AddIntervenant(request.POST, meta={'csrf_context': request.session}) | ||||
| intervention = request.matchdict.get('intervention', None) | intervention = request.matchdict.get('intervention', None) | ||||
| @@ -778,6 +846,34 @@ def link_event(request): | |||||
| return HTTPFound(location=request.route_url('edit_event', sep='/', | return HTTPFound(location=request.route_url('edit_event', sep='/', | ||||
| year=str(year), intervention=intervention, event_id=str(TargetEvent.uid))) | year=str(year), intervention=intervention, event_id=str(TargetEvent.uid))) | ||||
| @view_config(route_name='link_event_tiers') | |||||
| def link_event_tiers(request): | |||||
| """ Create user if not exist, add it to current event """ | |||||
| year = int(request.matchdict.get('year', -1)) | |||||
| form = AddTiers(request.POST, meta={'csrf_context': request.session}) | |||||
| intervention = request.matchdict.get('intervention', None) | |||||
| TargetEvent = Event.by_id(form.event_uid.data) | |||||
| Exist = Tiers.by_id(form.tiers.data) | |||||
| if not Exist: | |||||
| request.session.flash(('error',u"Une erreur s'est produite lors de l'ajout de votre entitée !")) | |||||
| return HTTPFound(location=request.route_url('edit_event', sep='/', | |||||
| year=str(year), intervention=intervention, event_id=str(TargetEvent.uid))) | |||||
| else: | |||||
| TargetTiers = Exist | |||||
| if len(DBSession.query(Role_Tiers)\ | |||||
| .filter(Role_Tiers.year_uid==year)\ | |||||
| .filter(Role_Tiers.tiers_role=="Exposant")\ | |||||
| .filter(Role_Tiers.tiers_uid==TargetTiers.uid)\ | |||||
| .all())==0: | |||||
| tev = Role_Tiers(year_uid=year, tiers_role="Exposant", tiers_uid=TargetTiers.uid) | |||||
| DBSession.add(tev) | |||||
| return HTTPFound(location=request.route_url('edit_event', sep='/', | |||||
| year=str(year), intervention=intervention, event_id=str(TargetEvent.uid))) | |||||
| @view_config(route_name='edit_event', renderer="jm2l:templates/edit_event.mako") | @view_config(route_name='edit_event', renderer="jm2l:templates/edit_event.mako") | ||||
| def edit_event(request): | def edit_event(request): | ||||
| year = int(request.matchdict.get('year', -1)) | year = int(request.matchdict.get('year', -1)) | ||||
| @@ -836,6 +932,16 @@ def edit_event(request): | |||||
| # Put some users on form | # Put some users on form | ||||
| formAdd.intervenant.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) | formAdd.intervenant.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) | ||||
| for u in Users] | for u in Users] | ||||
| # Each event can get severals entities | |||||
| formAddT = AddTiers(event_uid=TheEvent.uid) | |||||
| # Build list of entities | |||||
| # Get entities from db | |||||
| TmpTiers = DBSession.query(Tiers)\ | |||||
| .order_by('name').limit(10) | |||||
| # Put some entities on form | |||||
| formAddT.tiers.choices = [(u.uid, "%s %s" % (u.nom, u.prenom)) | |||||
| for u in Users] | |||||
| else: | else: | ||||
| TheEvent = Event() | TheEvent = Event() | ||||
| # prepare the form for creation | # prepare the form for creation | ||||
| @@ -849,6 +955,11 @@ def edit_event(request): | |||||
| duration=60 | duration=60 | ||||
| # No intervenant | # No intervenant | ||||
| formAdd = None | formAdd = None | ||||
| formAddT = None | |||||
| SalleDispo = DBSession.query(Salles)\ | |||||
| .filter(Salles.year_uid==year)\ | |||||
| .order_by('name') | |||||
| if intervention=="Conference": | if intervention=="Conference": | ||||
| form.duration.choices =[ | form.duration.choices =[ | ||||
| @@ -861,27 +972,27 @@ def edit_event(request): | |||||
| form.duration.choices.append( (duration,u'Conférence (%d min)' % duration) ) | form.duration.choices.append( (duration,u'Conférence (%d min)' % duration) ) | ||||
| if not form._fields.has_key("uid"): | if not form._fields.has_key("uid"): | ||||
| form.duration.data=60 | form.duration.data=60 | ||||
| SalleDispo = SalleDispo.filter(Salles.place_type=='Conference') | |||||
| elif intervention=="Stand": | elif intervention=="Stand": | ||||
| form.duration.choices =[ | form.duration.choices =[ | ||||
| (8*60, u'Toute la journée'), | (8*60, u'Toute la journée'), | ||||
| (4*60, u'une demi-journée') | (4*60, u'une demi-journée') | ||||
| ] | ] | ||||
| SalleDispo = SalleDispo.filter(Salles.place_type=='Stand') | |||||
| elif intervention=="Atelier": | elif intervention=="Atelier": | ||||
| form.duration.choices = map( lambda d:(d, u'Atelier (%dh%.2d)' % (d/60, d%60) ), \ | form.duration.choices = map( lambda d:(d, u'Atelier (%dh%.2d)' % (d/60, d%60) ), \ | ||||
| [60, 90, 120, 150, 180, 210, 240] ) | [60, 90, 120, 150, 180, 210, 240] ) | ||||
| if not duration in map(lambda (d,y): d, form.duration.choices): | if not duration in map(lambda (d,y): d, form.duration.choices): | ||||
| form.duration.choices.append( (duration,u'Atelier (%dh%.2d)' % (duration/60, duration%60) ) ) | form.duration.choices.append( (duration,u'Atelier (%dh%.2d)' % (duration/60, duration%60) ) ) | ||||
| SalleDispo = SalleDispo.filter(Salles.place_type=='Ateliers') | |||||
| elif intervention=="Table_Ronde": | elif intervention=="Table_Ronde": | ||||
| form.duration.choices = map( lambda d:(d, u'Table ronde (%dh%.2d)' % (d/60, d%60) ), \ | form.duration.choices = map( lambda d:(d, u'Table ronde (%dh%.2d)' % (d/60, d%60) ), \ | ||||
| [60, 90, 120, 150] ) | [60, 90, 120, 150] ) | ||||
| if not duration in map(lambda (d,y): d, form.duration.choices): | if not duration in map(lambda (d,y): d, form.duration.choices): | ||||
| form.duration.choices.append( (duration,u'Table ronde (%dh%.2d)' % (duration/60, duration%60) ) ) | |||||
| form.duration.choices.append( (duration,u'Table ronde (%dh%.2d)' % (duration/60, duration%60) ) ) | |||||
| SalleDispo = SalleDispo.filter(Salles.place_type=='Conference') | |||||
| else: | else: | ||||
| return HTTPForbidden(u"Pas encore disponible.") | return HTTPForbidden(u"Pas encore disponible.") | ||||
| SalleDispo = DBSession.query(Salles)\ | |||||
| .filter(Salles.year_uid==year)\ | |||||
| .order_by('name') | |||||
| form.salle_uid.choices = [(s.salle_id, s.name) for s in SalleDispo] | form.salle_uid.choices = [(s.salle_id, s.name) for s in SalleDispo] | ||||
| form.start_sel.choices = TimeSlots | form.start_sel.choices = TimeSlots | ||||
| @@ -900,14 +1011,14 @@ def edit_event(request): | |||||
| uev.user_uid = request.user.uid | uev.user_uid = request.user.uid | ||||
| TheEvent.interventions.append( uev ) | TheEvent.interventions.append( uev ) | ||||
| DBSession.flush() | DBSession.flush() | ||||
| request.session.flash(('sucess','Votre intervention a été créee !')) | |||||
| request.session.flash(('sucess',u'Votre intervention a été créee !')) | |||||
| return HTTPFound(location=request.route_url('edit_event', sep='/', | return HTTPFound(location=request.route_url('edit_event', sep='/', | ||||
| year=str(year), intervention=intervention, event_id=str(TheEvent.slug))) | year=str(year), intervention=intervention, event_id=str(TheEvent.slug))) | ||||
| else: | else: | ||||
| DBSession.merge(TheEvent) | DBSession.merge(TheEvent) | ||||
| MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'', | MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'', | ||||
| 'event':TheEvent, 'form':form, 'formAdd':formAdd, | |||||
| 'event':TheEvent, 'form':form, 'formAdd':formAdd, 'formAddT':formAddT, | |||||
| 'logged_in':request.authenticated_userid } | 'logged_in':request.authenticated_userid } | ||||
| return MainTab | return MainTab | ||||
| @@ -979,18 +1090,30 @@ def edit_tiers(request): | |||||
| #test_form = TiersForm(request.POST, TheTiers, meta={'csrf_context': request.session}) | #test_form = TiersForm(request.POST, TheTiers, meta={'csrf_context': request.session}) | ||||
| if request.method == 'POST' and form.validate(): | if request.method == 'POST' and form.validate(): | ||||
| print request.POST | |||||
| ToDelete = list() | ToDelete = list() | ||||
| ToDeleteR = list() | |||||
| # First, we remove entries no more present | # First, we remove entries no more present | ||||
| for obj in form.membership.object_data: | for obj in form.membership.object_data: | ||||
| MatchEntry = filter( lambda x: x.object_data and x.object_data._sa_instance_state == obj._sa_instance_state, | MatchEntry = filter( lambda x: x.object_data and x.object_data._sa_instance_state == obj._sa_instance_state, | ||||
| form.membership.entries ) | form.membership.entries ) | ||||
| if not MatchEntry: | if not MatchEntry: | ||||
| ToDelete.append(obj) | ToDelete.append(obj) | ||||
| # For roles too | |||||
| for obj in form.roles.object_data: | |||||
| MatchEntry = filter( lambda x: x.object_data and x.object_data._sa_instance_state == obj._sa_instance_state, | |||||
| form.roles.entries ) | |||||
| if not MatchEntry: | |||||
| ToDeleteR.append(obj) | |||||
| # We should remove it as it's not in original data | # We should remove it as it's not in original data | ||||
| for obj in ToDelete: | for obj in ToDelete: | ||||
| TheTiers.membership.remove(obj) | TheTiers.membership.remove(obj) | ||||
| DBSession.delete(obj) | DBSession.delete(obj) | ||||
| # For roles too | |||||
| for obj in ToDeleteR: | |||||
| TheTiers.roles.remove(obj) | |||||
| DBSession.delete(obj) | |||||
| # Then, it's time to consider new entries | # Then, it's time to consider new entries | ||||
| for entry in form.membership.entries: | for entry in form.membership.entries: | ||||
| if entry.object_data is None: | if entry.object_data is None: | ||||
| @@ -998,6 +1121,14 @@ def edit_tiers(request): | |||||
| entry.object_data = TmpUser | entry.object_data = TmpUser | ||||
| TheTiers.membership.append(TmpUser) | TheTiers.membership.append(TmpUser) | ||||
| form.membership.object_data = TheTiers.membership | form.membership.object_data = TheTiers.membership | ||||
| # For roles too | |||||
| for entry in form.roles.entries: | |||||
| if entry.object_data is None: | |||||
| TmpRole = Role_Tiers() | |||||
| entry.object_data = TmpRole | |||||
| TheTiers.roles.append(TmpRole) | |||||
| form.roles.object_data = TheTiers.roles | |||||
| form.populate_obj(TheTiers) | form.populate_obj(TheTiers) | ||||
| # Handle Remove of accents | # Handle Remove of accents | ||||
| TheTiers.slug = slugify(form.name.data) | TheTiers.slug = slugify(form.name.data) | ||||