accessibility page; announces subscription pages and form (not functional)
This commit is contained in:
parent
b08ecb38d6
commit
32ba0ff426
|
@ -1,5 +1,5 @@
|
|||
from quixote import get_publisher
|
||||
|
||||
from quixote import get_publisher, get_request, redirect
|
||||
from quixote.directory import Directory
|
||||
from quixote.html import htmltext
|
||||
|
||||
import os
|
||||
|
@ -8,18 +8,84 @@ import wcs
|
|||
import wcs.root
|
||||
from wcs import template
|
||||
from wcs import errors
|
||||
from wcs.form import *
|
||||
|
||||
from wcs.categories import Category
|
||||
from wcs.formdef import FormDef
|
||||
|
||||
OldRootDirectory = wcs.root.RootDirectory
|
||||
|
||||
class AnnouncesDirectory(Directory):
|
||||
_q_exports = ['', 'subscribe', 'email', 'atom']
|
||||
|
||||
def _q_index (self):
|
||||
raise NotImplementedError
|
||||
|
||||
def subscribe [html] (self):
|
||||
template.html_top(_('Receiving Announces'))
|
||||
|
||||
'<p>'
|
||||
_('FIXME')
|
||||
'</p>'
|
||||
|
||||
'<ul>'
|
||||
' <li><a href="email">%s</a></li>' % _('Email')
|
||||
' <li><a href="sms">%s</a></li>' % _('SMS')
|
||||
'</ul>'
|
||||
|
||||
'<p>'
|
||||
_('There is also a feed available:')
|
||||
'<a class="feed-link" href="atom">%s</a>' % _('Announces Feed')
|
||||
'</p>'
|
||||
|
||||
def email [html] (self):
|
||||
template.html_top(_('Receiving Announces by email'))
|
||||
|
||||
form = Form(enctype='multipart/form-data')
|
||||
if get_request().user:
|
||||
if get_request().user.email:
|
||||
_('You are logged in and your email is %s, ok to subscribe ?') % \
|
||||
get_request().user.email
|
||||
form.add_submit('submit', _('Subscribe'))
|
||||
else:
|
||||
_("You are logged in but you didn't enter any email address.")
|
||||
form.add(EmailWidget, 'email', title = _('Email'), required = True)
|
||||
form.add_submit('submit', _('Subscribe'))
|
||||
form.add_submit('submit-remember', _('Subscribe and add this email to my profile'))
|
||||
else:
|
||||
'<p>'
|
||||
_('FIXME will only be used for this purpose etc.')
|
||||
'</p>'
|
||||
form.add(EmailWidget, 'email', title = _('Email'), required = True)
|
||||
form.add_submit('submit', _('Subscribe'))
|
||||
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
|
||||
if form.get_submit() == 'cancel':
|
||||
return redirect('subscribe')
|
||||
|
||||
if form.is_submitted() and not form.has_errors():
|
||||
raise NotImplementedError
|
||||
else:
|
||||
form.render()
|
||||
|
||||
def atom(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
||||
|
||||
class AlternateRootDirectory(OldRootDirectory):
|
||||
_q_exports = ['', 'admin', 'backoffice', 'forms', 'login', 'logout', 'liberty', 'token', 'saml',
|
||||
('informations-editeur', 'informations_editeur')]
|
||||
('informations-editeur', 'informations_editeur'), 'index2',
|
||||
('announces', 'announces_dir'),
|
||||
'accessibility',
|
||||
'help']
|
||||
|
||||
announces_dir = AnnouncesDirectory()
|
||||
|
||||
def _q_index [html] (self):
|
||||
template.html_top(default_org = _('Ma ville au quotidien'))
|
||||
template.html_top()
|
||||
|
||||
'<div id="gauche">'
|
||||
self.services()
|
||||
|
@ -30,6 +96,41 @@ class AlternateRootDirectory(OldRootDirectory):
|
|||
self.announces()
|
||||
'</div>'
|
||||
|
||||
def index2 [html] (self):
|
||||
template.html_top(default_org = _('Ma ville au quotidien'))
|
||||
|
||||
'<div id="gauche">'
|
||||
self.services2()
|
||||
self.consultations()
|
||||
'</div>'
|
||||
'<div id="droite">'
|
||||
self.links()
|
||||
self.announces()
|
||||
'</div>'
|
||||
|
||||
def services2 [html] (self):
|
||||
## Services
|
||||
self.consultations_category = None
|
||||
for category in Category.select(order_by = 'name'):
|
||||
if category.url_name == 'consultations':
|
||||
self.consultations_category = category
|
||||
continue
|
||||
'<div id="services">'
|
||||
'<h3>%s</h3>' % category.name
|
||||
|
||||
'<ul>'
|
||||
formdefs = FormDef.select(lambda x: (
|
||||
x.category_id == category.id and not x.disabled),
|
||||
order_by = 'name')
|
||||
for formdef in formdefs:
|
||||
'<li>'
|
||||
'<a href="%s/">%s</a>' % (formdef.url_name, formdef.name)
|
||||
'</li>'
|
||||
'</ul>'
|
||||
'</div>'
|
||||
|
||||
|
||||
|
||||
|
||||
def services [html] (self):
|
||||
## Services
|
||||
|
@ -112,12 +213,15 @@ class AlternateRootDirectory(OldRootDirectory):
|
|||
item.get_field_value('Texte')
|
||||
'</p>'
|
||||
'</div>'
|
||||
|
||||
'<p class="subscribe">'
|
||||
'<a href="announces/subscribe">%s</a>' % _('Receiving those Announces')
|
||||
'</p>'
|
||||
'</div>'
|
||||
|
||||
|
||||
def informations_editeur [html] (self):
|
||||
template.html_top(_('Editor Informations'))
|
||||
article_html = str(os.path.join(get_publisher().app_dir, 'articles/editor_info.html'))
|
||||
def page_view [html] (self, filename, title):
|
||||
template.html_top(title)
|
||||
article_html = str(os.path.join(get_publisher().app_dir, 'articles/%s.html') % filename)
|
||||
if os.path.exists(str(article_html)):
|
||||
'<div class="article">'
|
||||
htmltext(file(article_html).read())
|
||||
|
@ -125,5 +229,13 @@ class AlternateRootDirectory(OldRootDirectory):
|
|||
else:
|
||||
raise errors.TraversalError()
|
||||
|
||||
def informations_editeur [html] (self):
|
||||
return self.page_view('editor_info', _('Editor Informations'))
|
||||
|
||||
def accessibility(self):
|
||||
return self.page_view('accessibility', _('Accessibility Statement'))
|
||||
|
||||
def help(self):
|
||||
raise NotImplementedError
|
||||
|
||||
wcs.root.RootDirectory = AlternateRootDirectory
|
||||
|
|
Reference in New Issue