diff --git a/jm2l/__init__.py b/jm2l/__init__.py index b1c3ce3..4c5920c 100644 --- a/jm2l/__init__.py +++ b/jm2l/__init__.py @@ -70,6 +70,7 @@ def main(global_config, **settings): # 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') diff --git a/jm2l/forms.py b/jm2l/forms.py index e7e6551..70f68ec 100644 --- a/jm2l/forms.py +++ b/jm2l/forms.py @@ -75,6 +75,11 @@ class DossPresse(MyBaseForm): 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 diff --git a/jm2l/static/css/jm2l.css b/jm2l/static/css/jm2l.css index e47fa75..60f22ba 100644 --- a/jm2l/static/css/jm2l.css +++ b/jm2l/static/css/jm2l.css @@ -205,8 +205,8 @@ a { border: 1px solid #d4d4d4; } .ShowEntities td img { - width: 60px; - height: 60px; + width: 100%; + height: 100%; } .ShowEntities td:hover { diff --git a/jm2l/templates/NewIndex.mako b/jm2l/templates/NewIndex.mako index 6385003..29bbf5a 100644 --- a/jm2l/templates/NewIndex.mako +++ b/jm2l/templates/NewIndex.mako @@ -49,8 +49,16 @@ % else: + % if request.user.Staff: + Editer cette page - + % endif Le programme des évenements ${year} % endif +
+
+ ${ content | n } +
+
diff --git a/jm2l/templates/Staff/EditIndex.mako b/jm2l/templates/Staff/EditIndex.mako new file mode 100644 index 0000000..c062be8 --- /dev/null +++ b/jm2l/templates/Staff/EditIndex.mako @@ -0,0 +1,30 @@ +<%inherit file="jm2l:templates/layout.mako"/> +<%namespace name="helpers" file="jm2l:templates/helpers.mako"/> +<%def name="jsAddOn()"> + + + +<%def name="cssAddOn()"> + + + +

Accueil ${DisplayYear}

+<% +DicForm = { + 'year_uid': {'PlaceHolder':u"Mon Nom", "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;"}, + 'description': {'PlaceHolder':u"Description", "FieldStyle":"width:95%;min-height:600px;", "ckeditor":"1"}, + } +%> +
+
+ ${helpers.DisplayForm(form, DicForm)} +
+
+ +
+ +
+
+
diff --git a/jm2l/templates/Staff/EditPresse.mako b/jm2l/templates/Staff/EditPresse.mako index 2c44b3e..2af70de 100644 --- a/jm2l/templates/Staff/EditPresse.mako +++ b/jm2l/templates/Staff/EditPresse.mako @@ -22,13 +22,15 @@ DicForm = {
${helpers.DisplayForm(form, DicForm)} - +
+
+ +
+
+
${helpers.uploader("presse", form.year_uid.data, u"Fichier" )} - -

- -##${helpers.uploader_js()} \ No newline at end of file +
diff --git a/jm2l/views.py b/jm2l/views.py index d0f538d..4f2f979 100644 --- a/jm2l/views.py +++ b/jm2l/views.py @@ -230,18 +230,32 @@ def index_page(request): year = request.matchdict.get('year') if year: year=int(year[:-1]) + content = DBSession.query(JM2L_Year).filter(JM2L_Year.year_uid==year).first() + if content: + content = content.description if 2004ère" } + return {'year': year, 'content':content, 'edition':u"1ère" } elif year==2015: - return {'year': year, 'edition':u"9ème" } + return {'year': year, 'content':content, 'edition':u"9ème" } else: edition = year - 2005 - return {'year': year, 'edition':u"%dème" % edition } + return {'year': year, 'content':content, 'edition':u"%dème" % edition } else: raise HTTPNotFound() return {'year': CurrentYear, 'edition':u"9ème"} +@view_config(route_name='edit_index', renderer="jm2l:templates/Staff/EditIndex.mako") +def edit_index(request): + year = int(request.matchdict.get('year', None)) + content = DBSession.query(JM2L_Year).filter(JM2L_Year.year_uid==year).first() + form = IndexForm(request.POST, content, meta={'csrf_context': request.session}) + if request.method == 'POST' and form.validate(): + form.populate_obj(content) + return HTTPFound(location=request.route_url('home', year="%d/" % year)) + MainTab = {'home':'active', "logged_in":request.authenticated_userid, + 'form':form, 'DisplayYear':year} + return MainTab @view_config(route_name='programme', renderer="jm2l:templates/Public/Programme.mako") def programme(request):