Pārlūkot izejas kodu

Added Home page editor

master
tr4ck3ur des JM2L pirms 9 gadiem
vecāks
revīzija
45513f713a
7 mainītis faili ar 72 papildinājumiem un 12 dzēšanām
  1. +1
    -0
      jm2l/__init__.py
  2. +5
    -0
      jm2l/forms.py
  3. +2
    -2
      jm2l/static/css/jm2l.css
  4. +8
    -0
      jm2l/templates/NewIndex.mako
  5. +30
    -0
      jm2l/templates/Staff/EditIndex.mako
  6. +9
    -7
      jm2l/templates/Staff/EditPresse.mako
  7. +17
    -3
      jm2l/views.py

+ 1
- 0
jm2l/__init__.py Parādīt failu

@@ -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')


+ 5
- 0
jm2l/forms.py Parādīt failu

@@ -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


+ 2
- 2
jm2l/static/css/jm2l.css Parādīt failu

@@ -205,8 +205,8 @@ a {
border: 1px solid #d4d4d4;
}
.ShowEntities td img {
width: 60px;
height: 60px;
width: 100%;
height: 100%;
}

.ShowEntities td:hover {


+ 8
- 0
jm2l/templates/NewIndex.mako Parādīt failu

@@ -49,8 +49,16 @@
</div>
</div>
% else:
% if request.user.Staff:
<a href="/${year}/edit">Editer cette page</a> -
% endif
<a href="/${year}/le-programme">Le programme des évenements ${year}</a>
% endif
<div class="row-fluid">
<div class="span10 offset1">
${ content | n }
</div>
</div>

<div class="row-fluid">
<div class="span12">


+ 30
- 0
jm2l/templates/Staff/EditIndex.mako Parādīt failu

@@ -0,0 +1,30 @@
<%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>
</%def>
<%def name="cssAddOn()">
<link rel="stylesheet" href="/css/jm2l.css" />
<!-- CSS adjustments for browsers with JavaScript disabled -->
</%def>
<h3 class="page-title">Accueil ${DisplayYear}</h3>
<%
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"},
}
%>
<div>
<form action="" method="POST">
${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>
<br>

+ 9
- 7
jm2l/templates/Staff/EditPresse.mako Parādīt failu

@@ -22,13 +22,15 @@ DicForm = {
<div>
<form action="" method="POST">
${helpers.DisplayForm(form, DicForm)}
<input class="btn btn-primary" type="submit" value="Enregistrer">
<br>
<center>
<button type="submit" class="btn btn-large btn-primary" />
<i class="icon-ok icon-white"></i> Enregistrer
</button>
</center>

</form>
</div>
<center>
${helpers.uploader("presse", form.year_uid.data, u"Fichier" )}

<br><br>
<script>
## var editor = CKEDITOR.replace( 'doss_presse', { autoGrow_onStartup: true, language: 'fr' } );
</script>
##${helpers.uploader_js()}
</center>

+ 17
- 3
jm2l/views.py Parādīt failu

@@ -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<year<=CurrentYear:
if year==2006:
return {'year': year, 'edition':u"1<sup>ère</sup>" }
return {'year': year, 'content':content, 'edition':u"1<sup>ère</sup>" }
elif year==2015:
return {'year': year, 'edition':u"9<sup>ème</sup>" }
return {'year': year, 'content':content, 'edition':u"9<sup>ème</sup>" }
else:
edition = year - 2005
return {'year': year, 'edition':u"%d<sup>ème</sup>" % edition }
return {'year': year, 'content':content, 'edition':u"%d<sup>ème</sup>" % edition }
else:
raise HTTPNotFound()
return {'year': CurrentYear, 'edition':u"9<sup>ème</sup>"}

@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):


||||||
x
 
000:0
Notiek ielāde…
Atcelt
Saglabāt