diff options
-rw-r--r-- | jm2l/__init__.py | 1 | ||||
-rw-r--r-- | jm2l/forms.py | 42 | ||||
-rw-r--r-- | jm2l/models.py | 4 | ||||
-rw-r--r-- | jm2l/scripts/initializedb.py | 34 | ||||
-rw-r--r-- | jm2l/templates/Logistique/Logistique.mako | 5 | ||||
-rw-r--r-- | jm2l/templates/Profil/Sejour.mak | 23 | ||||
-rw-r--r-- | jm2l/templates/Staff/list.mako | 63 | ||||
-rw-r--r-- | jm2l/templates/Staff/tasks.mako | 7 | ||||
-rw-r--r-- | jm2l/templates/edit_event.mako | 31 | ||||
-rw-r--r-- | jm2l/templates/edit_tiers.mako | 12 | ||||
-rw-r--r-- | jm2l/templates/edit_tiers_categ.mako | 27 | ||||
-rw-r--r-- | jm2l/templates/helpers.mako | 29 | ||||
-rw-r--r-- | jm2l/templates/layout.mako | 43 | ||||
-rw-r--r-- | jm2l/templates/modals.mako | 2 | ||||
-rw-r--r-- | jm2l/views.py | 35 |
15 files changed, 228 insertions, 130 deletions
diff --git a/jm2l/__init__.py b/jm2l/__init__.py index 61ff343..c4ba2be 100644 --- a/jm2l/__init__.py +++ b/jm2l/__init__.py @@ -55,6 +55,7 @@ def main(global_config, **settings): # 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+)}') diff --git a/jm2l/forms.py b/jm2l/forms.py index 7cf076f..010cf28 100644 --- a/jm2l/forms.py +++ b/jm2l/forms.py @@ -47,17 +47,19 @@ ATELIER_DURATION = [ (15,u'Lighting talk ( 5 min)'), class StaffArea(MyBaseForm): - uid = HiddenField() name = TextField(u'Pôle') description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter] ) +class EditStaffArea(StaffArea): + uid = HiddenField() + class StaffTasks(MyBaseForm): name = TextField(u'Nom de la tâche') area_uid = SelectField(u'Pôle concerné', coerce=int ) - due_date = DateField(u'Date prévue', format='%d/%m/%Y') closed_by = SelectField(u'Assigné à', coerce=int ) + due_date = DateField(u'Date prévue', format='%d/%m/%Y') description = TextAreaField('Description', [validators.optional(), validators.Length(max=1000000)], filters=[strip_filter]) @@ -111,29 +113,13 @@ class AddIntervenant(MyBaseForm): u"son inscription sur le site.") add = SubmitField('Ajouter des intervenants') -class InterventionForm(MyBaseForm): +class ConfCreateForm(MyBaseForm): + event_type = HiddenField() for_year = HiddenField() start_time = HiddenField() end_time = HiddenField() - - name = TextField(u'Le nom de votre ', - [validators.DataRequired(u'Vous devez spécifier un nom pour votre intérvention'), - validators.Length(min=1, max=80, message='entre 1 et 80 car')], - filters=[strip_filter]) - - description = TextAreaField(u'Décrivez ici quelques détails à propos de votre intervention ', - [validators.Optional(), validators.Length(max=1000000)], - filters=[strip_filter] - ) -class ConfCreateForm(InterventionForm): - salle_uid = SelectField(u'Salle', coerce=int, - description=u"Choisissez ici la salle en fonction " - u"du nombres de personnes potentiellement intéressé par votre intervention "+ - u"l'organisation se réserve le droit de changer la salle (avec votre accord)." - - ) start_sel = SelectField(u'Début', coerce=int, description=u"C'est une heure indicative correspondant au mieux à vos préférences "+ u"personnelles. Vous pouvez prendre un créneau horaire déjà réservé si vous avez des contraintes " @@ -144,6 +130,22 @@ class ConfCreateForm(InterventionForm): description=u"Précisez ici la durée de votre intervention" ) + salle_uid = SelectField(u'Salle', coerce=int, + description=u"Choisissez ici la salle en fonction " + u"du nombres de personnes potentiellement intéressé par votre intervention "+ + u"l'organisation se réserve le droit de changer la salle (avec votre accord)." + + ) + + name = TextField(u'Le nom de votre ', + [validators.DataRequired(u'Vous devez spécifier un nom pour votre intérvention'), + validators.Length(min=1, max=80, message='entre 1 et 80 car')], + filters=[strip_filter]) + + description = TextAreaField(u'Décrivez ici quelques détails à propos de votre intervention ', + [validators.Optional(), validators.Length(max=1000000)], + filters=[strip_filter] + ) class ConfUpdateForm(ConfCreateForm): uid = HiddenField() diff --git a/jm2l/models.py b/jm2l/models.py index 2938f3a..f104228 100644 --- a/jm2l/models.py +++ b/jm2l/models.py @@ -46,6 +46,10 @@ class TasksArea(Base): name = Column(Unicode(80)) description = Column(UnicodeText) + @classmethod + def by_id(cls, id): + return DBSession.query(cls).filter(cls.uid == id).first() + class Tasks(Base): __tablename__ = 'staff_tasks' uid = Column(Integer, primary_key=True) diff --git a/jm2l/scripts/initializedb.py b/jm2l/scripts/initializedb.py index 5223b94..38776dd 100644 --- a/jm2l/scripts/initializedb.py +++ b/jm2l/scripts/initializedb.py @@ -4,7 +4,7 @@ import sys import transaction import time import lxml.etree as ET -from datetime import datetime + from sqlalchemy import engine_from_config from sqlalchemy import create_engine import unicodedata @@ -13,14 +13,13 @@ import urllib from slugify import slugify from sqlite3 import dbapi2 as sqlite from os import path - from pyramid.paster import ( get_appsettings, setup_logging, ) - from jm2l.models import * +from datetime import datetime def usage(argv): cmd = os.path.basename(argv[0]) @@ -39,5 +38,30 @@ def main(argv=sys.argv): DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: - admin = User(nom=u'jm2l', prenom='contact', slug='contact jm2l', password=u'jm2l', mail=u'contact@jm2l.linux-azur.org') - DBSession.add(admin)
\ No newline at end of file + admin = User(nom=u'jm2l', prenom='contact', + slug='contact jm2l', password=u'jm2l', + mail=u'contact@jm2l.linux-azur.org', + Staff=1 + ) + DBSession.add(admin) + + # Create 2015 year event + jm2l = JM2L_Year(year_uid=2015, + state="Ongoing", + description=u"%d, %dème édition des JM2L." % ( 2015, 9 ), + start_time=datetime.strptime("28-11-2015 10:00","%d-%m-%Y %H:%M"), + end_time=datetime.strptime("28-11-2015 19:00","%d-%m-%Y %H:%M") + ) + DBSession.add(jm2l) + + # Create 2015 Physic room event + phy_salle = SallePhy( name=u"Polytech salle 211", + description=u"Salle informatique, présence de postes de travail",) + DBSession.add(phy_salle) + DBSession.flush() + + # Create matching room place (Name could change each year) + salle = Salles(name=u"Mystère", description=u"Salle Mystère", + phy_salle_id = phy_salle.uid, + year_uid = jm2l.year_uid) + DBSession.add(salle)
\ No newline at end of file diff --git a/jm2l/templates/Logistique/Logistique.mako b/jm2l/templates/Logistique/Logistique.mako index 48c1b05..adb55ae 100644 --- a/jm2l/templates/Logistique/Logistique.mako +++ b/jm2l/templates/Logistique/Logistique.mako @@ -298,7 +298,10 @@ ListWrap = ["Co-voiturage",u"Hébergement","Matos"] ## Handle the Javascript Refresh to live update Current Page ## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= % if reload: - <% DicExch = Exchanges.get_overview( request.user.uid ) %> + <% + DicExch = Exchanges.get_overview( request.user.uid ) + context._kwargs['postpone_js'] = [] + %> ${Route_wrapper(DicExch)} ${Exchange_wrapper(Type, DicExch[Type])} %endif diff --git a/jm2l/templates/Profil/Sejour.mak b/jm2l/templates/Profil/Sejour.mak index f480a95..3fcd647 100644 --- a/jm2l/templates/Profil/Sejour.mak +++ b/jm2l/templates/Profil/Sejour.mak @@ -41,12 +41,18 @@ fieldset:disabled { % endfor </select> - <script type="text/javascript"> + <% + context._kwargs['postpone_js'].append( "$('#Arrival\\\\:Place').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Arrival\\\\:Day').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Arrival\\\\:Confidence').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Arrival\\\\:Hour').select2({width:'resolve'});" % jsitem ) + %> + ##<script type="text/javascript"> ## $("#Arrival\\:Place").select2({}); ## $("#Arrival\\:Day").select2({}); ## $("#Arrival\\:Confidence").select2({}); ## $("#Arrival\\:Hour").select2({}); - </script> + ##</script> </div> <p> <div class="control-group" style="background-color: #fafafa;padding: 10px 50px; width:60%"> @@ -114,13 +120,20 @@ fieldset:disabled { % endfor % endfor </select> - - <script type="text/javascript"> + + <% + context._kwargs['postpone_js'].append( "$('#Departure\\\\:Place').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Departure\\\\:Day').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Departure\\\\:Confidence').select2({width:'resolve'});" % jsitem ) + context._kwargs['postpone_js'].append( "$('#Departure\\\\:Hour').select2({width:'resolve'});" % jsitem ) + %> + + ##<script type="text/javascript"> ## $("#Departure\\:Place").select2({}); ## $("#Departure\\:Day").select2({}); ## $("#Departure\\:Confidence").select2({}); ## $("#Departure\\:Hour").select2({}); - </script> + ##</script> </div> <p> diff --git a/jm2l/templates/Staff/list.mako b/jm2l/templates/Staff/list.mako index f8ddb4a..b2cbe5d 100644 --- a/jm2l/templates/Staff/list.mako +++ b/jm2l/templates/Staff/list.mako @@ -1,35 +1,45 @@ # -*- 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="/Staff/poles"> + <i class="icon-plus-sign icon-white"></i> Ajouter un Pôle d'activité +</a> <h3>Liste des tâches JM2L Staff</h3> - <div class="tabbable" id="main_tab"> <ul class="nav nav-tabs" style="margin-bottom: 5px;"> - % for Num, Entity_Type in enumerate(tasks.keys()): + % for Num, Entity in enumerate(sorted(tasks.keys(), key=lambda x:x.name)): <li class="${["","active"][Num==0]}"> - <a href="#${Entity_Type}" id="Map_${Entity_Type}" data-toggle="tab">${Entity_Type}</a> + <a href="#${slugify(Entity.name)}" id="Map_Pole_${slugify(Entity.name)}" data-toggle="tab">${Entity.name}</a> </li> % endfor </ul> <div class="tab-content" style="padding:0 10px"> -% for Num, Entity_Type in enumerate(tasks.keys()): - <div class="tab-pane fade ${["","active "][Num==0]} in" id="${Entity_Type}"> +% for Num, Entity in enumerate(sorted(tasks.keys(), key=lambda x:x.name)): + <div class="tab-pane fade ${["","active "][Num==0]} in" id="${slugify(Entity.name)}"> + <a style="float:right;" class="btn btn-mini btn-info" role="button" href="/Staff/poles/${Entity.uid}"> + <i class="icon-pencil icon-white"></i> Editer le pôle + </a> + <h4>${Entity.name}</h4> + <div>${Entity.description | n}</div> <table width="100%" class="table table-striped table-bordered table-hover"> <thead> <tr> - <th colspan="2" style="text-align:center;">Nom + <th colspan="2" style="text-align:center;"> <a style="float:right;" class="btn btn-mini btn-info" role="button" href="/Staff/tasks"> <i class="icon-plus-sign icon-white"></i> Ajouter une tâche </a> + Liste des tâches </th> </tr> </thead> <tbody> - % for task in tasks[Entity_Type]: + % for task in tasks[Entity]: <tr> <td> % if task.closed: @@ -63,25 +73,18 @@ % endfor </div> -%if 0: -<ul id="tasks"> -% if tasks: - % for task in tasks: - <li> - <span class="name">${task.name}</span> - <div class="actions"> - [ <a href="/Staff/tasks/${task.uid}">edit</a> - <a href="/Staff/close/${task.uid}">close</a> ] - </div> - %if task.description: - ${task.description | n} - %endif - </li> - % endfor -% else: - <li>Il n'y a pas de tâches ouverte.</li> -% endif - <li class="last"> - <a href="/Staff/new">Créer une nouvelle tâche</a> - </li> -</ul> -%endif
\ No newline at end of file + +<%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>
\ No newline at end of file diff --git a/jm2l/templates/Staff/tasks.mako b/jm2l/templates/Staff/tasks.mako index df0c255..d3d9ded 100644 --- a/jm2l/templates/Staff/tasks.mako +++ b/jm2l/templates/Staff/tasks.mako @@ -15,6 +15,7 @@ <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> +<a style="float:right;" href="/Staff">Retour à la liste</a> % if 'uid' in form._fields.keys(): <h3>Editer une tâche</h3> % else: @@ -24,9 +25,9 @@ DicForm = { 'name': {'PlaceHolder':u"Nom de la tâche", "FieldStyle":"width:90%;" }, 'area_uid': {'PlaceHolder':u"Pôle", "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;" }, - 'due_date': {'PlaceHolder':u"27/11/2015", "FieldStyle":"width:8em;", 'ContainerStyle':"float:left;"}, - 'closed_by': {'PlaceHolder':u"Assigné à", "FieldStyle":"width:16em;" }, - 'description': {'PlaceHolder':u"Description", "FieldStyle":"width:95%;min-height:150px;" }, + 'closed_by': {'PlaceHolder':u"Assigné à", "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;" }, + 'due_date': {'PlaceHolder':u"27/11/2015", "FieldStyle":"width:8em;"}, + 'description': {'PlaceHolder':u"Description", "FieldStyle":"width:95%;min-height:150px;", "ckeditor":"1" }, } %> diff --git a/jm2l/templates/edit_event.mako b/jm2l/templates/edit_event.mako index a957b48..fee9f33 100644 --- a/jm2l/templates/edit_event.mako +++ b/jm2l/templates/edit_event.mako @@ -3,7 +3,8 @@ <%namespace name="helpers" file="jm2l:templates/helpers.mako"/> <%def name="jsAddOn()"> <script src="/vendor/ckeditor/ckeditor.js"></script> - <script src="/vendor/select2/js/select2.js"></script> + <script src="/vendor/select2/js/select2.js"></script> + <script src="/vendor/fileupload/js/jquery-uploader.min.js"></script> </%def> <%def name="cssAddOn()"> <link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" /> @@ -92,13 +93,12 @@ DicForm = { 'duration': {'PlaceHolder':u"Durée", 'ContainerStyle':"padding-right:15px;float:left;", "FieldStyle":"width:15em;"}, 'salle_uid': {'PlaceHolder':u"Salle", 'ContainerStyle':"padding-right:15px;", "FieldStyle":"width:15em;"}, 'name': {'PlaceHolder':u"Nom", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:95%;"}, - 'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:90%;height:500px;" }, + 'description': {'PlaceHolder':u"Description", 'ContainerStyle':"padding-right:5px;", "FieldStyle":"width:90%;height:500px;", "ckeditor":1 }, } %> ${helpers.DisplayForm(form, DicForm)} - - <button type="submit">Proposer</button> + <button type="submit">Proposer</button> </form> </fieldset> @@ -116,8 +116,9 @@ DicForm = { ${helpers.uploader("event", form.uid.data, u"un support de présentation" )} </fieldset> %else: - <br>NB: Vous devez proposer votre conférence avant de pouvoir + <p>NB: Vous devez proposer votre conférence avant de pouvoir téléverser votre support de présentation. + </p> % endif % if 'uid' in form._fields: @@ -174,7 +175,8 @@ TabFields = [ ## Then the submit for this form ${formAdd.add} </form> -</fieldset> +</fieldset> +<div class="clearfix"> </div> <p style="float:right;">Créé le ${event.created.strftime('%d %b %Y').decode('utf-8')}</p> %else: <p style="float:right;">Créé le @@ -205,13 +207,14 @@ TabFields = [ var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } ); </script> % else: - <% - for jsitem in form._fields.keys(): +<% +for jsitem in form._fields.keys(): + context._kwargs['postpone_js'].append( "$('#%s-help').popover();" % jsitem ) + if form._fields[jsitem].type=='SelectField': + context._kwargs['postpone_js'].append( "$('#%s').select2({width:'resolve'});" % jsitem ) +if formAdd: + for jsitem in formAdd._fields.keys(): context._kwargs['postpone_js'].append( "$('#%s-help').popover();" % jsitem ) - if form._fields[field].type=='SelectField': - context._kwargs['postpone_js'].append( "$('#%s').select2({width:'resolve'});" % jsitem ) - if formAdd: - for jsitem in formAdd._fields.keys(): - - %> +%> +${helpers.uploader_js()} % endif
\ No newline at end of file diff --git a/jm2l/templates/edit_tiers.mako b/jm2l/templates/edit_tiers.mako index f75b6e3..5b7a49c 100644 --- a/jm2l/templates/edit_tiers.mako +++ b/jm2l/templates/edit_tiers.mako @@ -1,10 +1,5 @@ <%inherit file="jm2l:templates/layout.mako"/>
<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
-<%def name="jsAddOn()">
- <script src="/vendor/select2/js/select2.js"></script>
- <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script>
- <script src="/vendor/ckeditor/ckeditor.js"></script>
-</%def>
<%def name="cssAddOn()">
<link rel="stylesheet" href="/vendor/select2/css/select2.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/vendor/fileupload/css/jquery.fileupload.css">
@@ -148,9 +143,15 @@ DicForm = { <br>
<br>
<br>
+
% if 'uid' in form._fields:
${helpers.uploader_js()}
% endif
+
+<%def name="jsAddOn()">
+ <script src="/vendor/select2/js/select2.js"></script>
+ <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script>
+ <script src="/vendor/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
var year_data = Array();
var editor = CKEDITOR.replace('description', { autoGrow_onStartup: true, language: 'fr' } );
@@ -195,3 +196,4 @@ jQuery(function() { });
});
</script>
+</%def>
\ No newline at end of file diff --git a/jm2l/templates/edit_tiers_categ.mako b/jm2l/templates/edit_tiers_categ.mako index ba2df09..34795a0 100644 --- a/jm2l/templates/edit_tiers_categ.mako +++ b/jm2l/templates/edit_tiers_categ.mako @@ -1,7 +1,20 @@ <%inherit file="jm2l:templates/layout.mako"/> <%namespace name="helpers" file="jm2l:templates/helpers.mako"/> <%def name="jsAddOn()"> - <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script> + <script src="/vendor/repeatable-fields/js/repeatable-fields.js"></script> +<script type="text/javascript"> +jQuery(function() { + jQuery('.repeat').each(function() { + jQuery(this).repeatable_fields({ + wrapper: 'table', + container: 'tbody', + row: 'tr', + cell: 'td', + }); + }); +}); +</script> + </%def> <h2>Gestion des catégories pour les entités</h2> @@ -101,15 +114,3 @@ <input type="submit" class="btn btn-primary" value="Enregistrer les modifications" /> </form> -<script type="text/javascript"> -jQuery(function() { - jQuery('.repeat').each(function() { - jQuery(this).repeatable_fields({ - wrapper: 'table', - container: 'tbody', - row: 'tr', - cell: 'td', - }); - }); -}); -</script> diff --git a/jm2l/templates/helpers.mako b/jm2l/templates/helpers.mako index c0d966b..aaa1274 100644 --- a/jm2l/templates/helpers.mako +++ b/jm2l/templates/helpers.mako @@ -36,15 +36,12 @@ TabJs = {'select':[], 'desc':[]} </label> % endif % if DicFormat.has_key(Field.name): - % if DicFormat[Field.name].has_key("PlaceHolder") and DicFormat[Field.name].has_key("FieldStyle"): - ${Field(placeholder=DicFormat[Field.name].get("PlaceHolder"), style=DicFormat[Field.name].get("FieldStyle"))} - % elif DicFormat[Field.name].has_key("PlaceHolder"): - ${Field(placeholder=DicFormat[Field.name].get("PlaceHolder"))} - % elif DicFormat[Field.name].has_key("FieldStyle"): - ${Field(style=DicFormat[Field.name].get("FieldStyle"))} - % else: - ${Field()} - % endif + <% + PlaceHolder = DicFormat[Field.name].get("PlaceHolder") + FieldStyle = DicFormat[Field.name].get("FieldStyle") + Class = [None,"ckeditor"][ DicFormat[Field.name].has_key("ckeditor") ] + %> + ${Field(placeholder=PlaceHolder, style=FieldStyle, class_=Class)} % else: ${Field()} % endif @@ -61,24 +58,12 @@ TabJs = {'select':[], 'desc':[]} </div> % endif % endfor -% if 0: - ## Then Auto Handle Javascript calls - <script> - % for jsitem in TabJs['select']: - $("#${jsitem}").select2({}); - % endfor - % for jsitem in TabJs['desc']: - $('#${jsitem}-help').popover(); - % endfor - </script> -% else: <% for jsitem in TabJs['select']: context._kwargs['postpone_js'].append( "$('#%s').select2({});" % jsitem ) for jsitem in TabJs['desc']: context._kwargs['postpone_js'].append( "$('#%s-help').popover();" % jsitem ) %> -% endif </%def> ## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -260,7 +245,7 @@ TabJs = {'select':[], 'desc':[]} {% } %} </script> %if 1: -##<script src="/vendor/fileupload/js/jquery-uploader.min.js"></script> +<script src="/vendor/fileupload/js/jquery-uploader.min.js"></script> <script src="/js/main.js"></script> % else: <script src="/static/jquery.min.js"></script> diff --git a/jm2l/templates/layout.mako b/jm2l/templates/layout.mako index 0a2c10e..4e1023b 100644 --- a/jm2l/templates/layout.mako +++ b/jm2l/templates/layout.mako @@ -45,9 +45,7 @@ DisplayYear = request.session.get('year', 2015) <small>${DisplayYear}</small> <span class="caret"></span></a> <ul class="dropdown-menu"> % for tmpyear in range(2015, 2005, -1): - % if tmpyear==2014: - <li class="disabled"><a href="#">Pas d'édition 2014</a></li> - % else: + % if tmpyear!=2014: <li><a href="/year/${tmpyear}">${tmpyear}</a></li> % endif % endfor @@ -64,6 +62,9 @@ DisplayYear = request.session.get('year', 2015) </a> <ul class="dropdown-menu"> % if request.user: + % if request.user.Staff: + <li><a href="/Staff">Partie Staff</a></li> + % endif <li><a href="/sign/out">Me déconnecter</a></li> % else: <li><a href="/participer-l-evenement#inscription">Je m'inscris</a></li> @@ -112,8 +113,42 @@ DisplayYear = request.session.get('year', 2015) ## Then Handle Javascript <script> % for jsitem in context._kwargs['postpone_js']: -${jsitem} +${jsitem | n} % endfor +$.each( $('.fileupload'), + function( NumCtrl, Ctrl ) { + $("#"+Ctrl.id).fileupload({ + // Uncomment the following to send cross-domain cookies: + //xhrFields: {withCredentials: true}, + //url: '/uploader/proceed/' + url: this.action + }); + // Enable iframe cross-domain access via redirect option: + $("#"+Ctrl.id).fileupload( + 'option', + 'redirect', + window.location.href.replace( + /\/[^\/]*$/, + '/cors/result.html?%s' + ) + ); + $("#"+Ctrl.id).addClass('fileupload-processing'); + $.ajax({ + // Uncomment the following to send cross-domain cookies: + //xhrFields: {withCredentials: true}, + //url: this.action, + url: $("#"+Ctrl.id).fileupload('option', 'url'), + //url: "uploader/proceed/", + dataType: 'json', + context: $("#"+Ctrl.id)[0] + }).always(function () { + $(this).removeClass('fileupload-processing'); + }).done(function (result) { + $(this).fileupload('option', 'done') + .call(this, $.Event('done'), {result: result}); //$(this)}); + }); + } +); </script> </body> </html> diff --git a/jm2l/templates/modals.mako b/jm2l/templates/modals.mako index 83470fb..e41cc4c 100644 --- a/jm2l/templates/modals.mako +++ b/jm2l/templates/modals.mako @@ -282,6 +282,6 @@ context._kwargs['postpone_js']=[] ## Then Handle Javascript <script> % for jsitem in context._kwargs['postpone_js']: -${jsitem} +${jsitem | n} % endfor </script> diff --git a/jm2l/views.py b/jm2l/views.py index 8cb5387..63d4b02 100644 --- a/jm2l/views.py +++ b/jm2l/views.py @@ -276,7 +276,7 @@ def list_view(request): tasks = DBSession.query( Tasks )\ .filter( Tasks.area_uid==grp.uid )\ .order_by(Tasks.closed, Tasks.due_date).all() - DicTask[grp.name] = tasks + DicTask[grp] = tasks return {'tasks': DicTask } @@ -312,10 +312,31 @@ def tasks(request): return {'form':form } +@view_config(route_name='handle_pole', renderer='jm2l:templates/Staff/pole.mako') +def tasks_area(request): + pole_id = request.matchdict.get('pole_id') + if pole_id: + Pole = TasksArea.by_id(int(pole_id)) + if not Pole: + raise HTTPNotFound() + form = EditStaffArea(request.POST, Pole, meta={'csrf_context': request.session}) + else: + Pole = TasksArea() + form = StaffArea(request.POST, Pole, meta={'csrf_context': request.session}) + if request.method == 'POST' and form.validate(): + form.populate_obj(Pole) + if 'uid' in form._fields.keys(): + DBSession.merge(Pole) + else: + DBSession.add(Pole) + return HTTPFound(location=request.route_url('list_task')) + return {'form':form } + @view_config(route_name='action_task') def action_task(request): action = request.matchdict.get('action') task_id = request.matchdict.get('task_id') + raise 'test' Task = Tasks.by_id(int(task_id)) if action=='close': Task.closed = True @@ -695,7 +716,7 @@ def edit_event(request): raise HTTPNotFound(u"Cette année n'est pas pris en charge") # Generate Timeslots for current year TimeSlots = list(enumerate( [ x.strftime('%a %d %b %H:%M') for x in - TheYear.AvailableTimeSlots ] )) + TheYear[0].AvailableTimeSlots ] )) if event_id: # We try to update an existing record @@ -711,8 +732,8 @@ def edit_event(request): if not (request.user.uid==1 or request.user in TheEvent.intervenants): return HTTPForbidden(u"Vous n'êtes pas identifié comme étant un participant à cette intervention.") # Compute some field value from selected event - if TheEvent.start_time in TheYear.AvailableTimeSlots: - start_sel = TheYear.AvailableTimeSlots.index(TheEvent.start_time) + if TheEvent.start_time in TheYear[0].AvailableTimeSlots: + start_sel = TheYear[0].AvailableTimeSlots.index(TheEvent.start_time) else: start_sel = len(TimeSlots) TimeSlots.append( (len(TimeSlots), TheEvent.start_time.strftime('%a %d %b %H:%M'))) @@ -778,7 +799,7 @@ def edit_event(request): if request.method == 'POST' and form.validate(): form.populate_obj(TheEvent) - TheEvent.start_time = TheYear.AvailableTimeSlots[form.start_sel.data] + TheEvent.start_time = TheYear[0].AvailableTimeSlots[form.start_sel.data] TheEvent.end_time = TheEvent.start_time + datetime.timedelta(minutes=form.duration.data) # Ok, time to put in database if not form._fields.has_key("uid"): @@ -814,7 +835,6 @@ def list_tiers(request): 'entities':Entities, 'logged_in':request.authenticated_userid } return MainTab - @view_config(route_name='show_entity', renderer="jm2l:templates/view_tiers.mako") def show_tiers(request): tiers_type = request.matchdict.get('tiers_type') @@ -831,6 +851,7 @@ def show_tiers(request): 'entity':TheTiers, 'logged_in':request.authenticated_userid } return MainTab +@view_config(route_name='add_entity', renderer="jm2l:templates/edit_tiers.mako") @view_config(route_name='edit_entity', renderer="jm2l:templates/edit_tiers.mako", permission='edit') def edit_tiers(request): @@ -892,7 +913,7 @@ def edit_tiers(request): DBSession.add(TheTiers) DBSession.flush() return HTTPFound(location=request.route_url('edit_entity', sep='/', - uid=str(TheTiers.uid), Nature=TheTiers.tiers_type)) + entity_id=str(TheTiers.slug), tiers_type=TheTiers.get_entity_type.entity_type)) DBSession.merge(TheTiers) return HTTPFound(location=request.route_url('entities')) MainTab = {'programme':'','presse':'', 'plan':'', 'participer':'', |