' % _('Logo')
-
- get_session().display_message()
+ def appearance_logo(self):
+ r = TemplateIO(html=True)
+ r += htmltext('
')
+ r += htmltext('
%s
') % _('Logo')
+ r += get_session().display_message()
logo_url = get_logo_url()
if logo_url:
- '' % logo_url
+ r += htmltext('') % logo_url
- ''
- '
'
-
+ r += htmltext('') % _('Upload Logo')
+ r += htmltext('')
+ r += htmltext('
')
+ return r.getvalue()
def logo(self):
if not quota.can_logo():
diff --git a/extra/modules/bodiffusion.ptl b/extra/modules/bodiffusion.py
similarity index 78%
rename from extra/modules/bodiffusion.ptl
rename to extra/modules/bodiffusion.py
index b98409e..6a4da24 100644
--- a/extra/modules/bodiffusion.ptl
+++ b/extra/modules/bodiffusion.py
@@ -21,7 +21,7 @@ from sets import Set
from quixote import get_publisher, get_request, get_response, get_session, redirect
from quixote.directory import Directory
-from quixote.html import htmltext
+from quixote.html import TemplateIO, htmltext
from qommon.backoffice.menu import html_top
from qommon.admin.emails import EmailsDirectory
@@ -208,7 +208,7 @@ class DiffusionDirectory(Directory):
self.objectdef.store()
return redirect('.')
- def emailfrom [html] (self):
+ def emailfrom(self):
emails_cfg = get_cfg('emails', {})
form = Form(enctype='multipart/form-data')
form.add(EmailWidget, 'from', title=_('Sender Address'),
@@ -222,13 +222,15 @@ class DiffusionDirectory(Directory):
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append( ('emailfrom', _('Sender Address')) )
html_top('config', title = _('Sender Address'))
- '
%s
' % _('Sender Address')
- form.render()
+ r = TemplateIO(html=True)
+ r += htmltext('
%s
') % _('Sender Address')
+ r += form.render()
+ return r.getvalue()
else:
cfg_submit(form, 'emails', ['from'])
redirect('.')
- def emailnotify [html] (self):
+ def emailnotify(self):
emails_cfg = get_cfg('emails', {})
form = Form(enctype='multipart/form-data')
@@ -247,8 +249,10 @@ class DiffusionDirectory(Directory):
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append( ('emailfrom', _('Sender Address')) )
html_top('config', title = _('Sender Address'))
- '
%s
' % _('Sender Address')
- form.render()
+ r = TemplateIO(html=True)
+ r += htmltext('
%s
') % _('Sender Address')
+ r += form.render()
+ return r.getvalue()
else:
v = form.get_widget('notify').parse()
if v:
@@ -273,77 +277,80 @@ class DiffusionDirectory(Directory):
def html_top(self, section, *args, **kwargs):
html_top('forms/%s/diffusion' % self.objectdef.id, *args, **kwargs)
- def _q_index [html] (self):
+ def _q_index (self):
# XXX: it would be nice to be manage groups, to select an existing group
self.html_top(_('Diffusion'))
+ r = TemplateIO(html=True)
- '
'
+ r += _('None set')
+ r += htmltext(' (%s)') % _('set address')
+ r += htmltext('')
- '
%s' % _('Notification when a questionnaire is filled: ')
+ r += htmltext('
%s') % _('Notification when a questionnaire is filled: ')
if not self.objectdef.workflow_options:
self.objectdef.workflow_options = {}
if self.objectdef.workflow_options.get('done*mail-on-filled*to'):
self.objectdef.workflow_options.get('done*mail-on-filled*to')
- ' (%s)' % _('change address')
+ r += htmltext(' (%s)') % _('change address')
else:
- _('None set')
- ' (%s)' % _('set address')
- '
'
+ r += _('None set')
+ r += htmltext(' (%s)') % _('set address')
+ r += htmltext('')
- ''
+ r += htmltext('')
get_response().filter['sidebar'] = self.get_sidebar()
get_session().display_message()
if self.objectdef.roles:
- self.display_participants()
+ r += self.display_participants()
- def display_participants [html] (self):
+ return r.getvalue()
+
+ def display_participants(self):
users = []
many_users = False
search_result = False
@@ -400,15 +407,17 @@ class DiffusionDirectory(Directory):
# XXX: and now, convert from user_ids to User objects?
+ r = TemplateIO(html=True)
+
if user_ids:
# XXX: paragraph of explanation, and option to get a list of access
# codes instead of sending them out
- '
'
- _('%s participants.') % len(user_ids)
+ r += htmltext('
')
+ r += _('%s participants.') % len(user_ids)
if search_result:
- ' %s' % _('Back to full listing')
- '
'
+ r += htmltext(' %s') % _('Back to full listing')
+ r += htmltext('
')
if len(user_ids) < 500:
# reasonable number, load all of them, so it's possible to
@@ -420,62 +429,65 @@ class DiffusionDirectory(Directory):
all_users = sorted(user_ids)
user_are_objects = False
- '
'
- '
'
+ r += htmltext('
')
+ r += htmltext('
')
rightcol = False
for i, user in enumerate(all_users):
if user_are_objects:
user_id = user.id
- '
%s ' % user.display_name
+ r += htmltext('
%s ') % user.display_name
else:
user_id = user
- '
%s ') % user_id
+ r += htmltext('(%s)') % (user_id, _('remove'))
+ r += htmltext('
')
if not rightcol and (i+1) >= len(user_ids)/2.0:
rightcol = True
- '
'
- '
'
- '
'
- '
'
- '
'
- '
'
+ r += htmltext('
')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += htmltext('
')
# XXX: add pagination
elif user_ids is None: # unknown set
- '
'
- _('Unable to get a list of participants.')
- ' '
- _('System overloaded?')
+ r += htmltext('
')
+ r += _('Unable to get a list of participants.')
+ r += ' '
+ r += _('System overloaded?')
# XXX: + use search form on the right.
- '
'
+ r += htmltext('')
else:
- '
'
+ r += htmltext('
')
if search_result:
- _('There is currently no participants matching your query.')
+ r += _('There is currently no participants matching your query.')
else:
- _('There is currently no participants defined.')
- '
'
+ r += _('There is currently no participants defined.')
+ r += htmltext('')
+ return r.getvalue()
- def get_sidebar [html] (self):
+ def get_sidebar(self):
if not self.objectdef.roles:
return ''
- '
') % _('Search a participant')
search_form = Form(enctype='multipart/form-data', use_tokens=False)
search_form.add(StringWidget, 'email', title=_('Email'))
search_form.add_submit('submit', _('Search'))
- search_form.render()
+ r += search_form.render()
+ return r.getvalue()
def remove(self):
user_id = get_request().form.get('id')
@@ -491,7 +503,7 @@ class DiffusionDirectory(Directory):
user.store()
return redirect('.')
- def add [html] (self):
+ def add(self):
form = Form(enctype='multipart/form-data')
form.add(StringWidget, 'name', title=_('Name'), size=40, required=False)
form.add(EmailWidget, 'email', title=_('Email'), required=True)
@@ -509,7 +521,9 @@ class DiffusionDirectory(Directory):
get_response().breadcrumb.append( ('add', _('Add')) )
self.html_top(_('Add a Participant'))
- form.render()
+ r = TemplateIO(html=True)
+ r += form.render()
+ return r.getvalue()
def add_submit(self, form):
name = form.get_widget('name').parse()
@@ -536,7 +550,7 @@ class DiffusionDirectory(Directory):
return redirect('.')
- def p_import [html] (self):
+ def p_import(self):
if get_request().form.get('job'):
return self.participants_importing()
@@ -556,17 +570,19 @@ class DiffusionDirectory(Directory):
get_response().breadcrumb.append( ('import', _('Import')) )
self.html_top(_('Import a List of Participants'))
- '
%s
' % _('Importing a List of Participants')
- '
'
- _('The file should be in the CSV file format. Using your spreadsheet '\
- 'program (Calc, Excel...), click "Save as" and select the CSV format.')
- '
'
- '
'
- _('The file should have email addresses in the first column, and, '\
- 'optionnaly, names in the second column.')
- '
'
- get_session().display_message()
- form.render()
+ r = TemplateIO(html=True)
+ r += htmltext('
%s
') % _('Importing a List of Participants')
+ r += htmltext('
')
+ r += _('The file should be in the CSV file format. Using your spreadsheet '\
+ 'program (Calc, Excel...), click "Save as" and select the CSV format.')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += _('The file should have email addresses in the first column, and, '\
+ 'optionnaly, names in the second column.')
+ r += htmltext('
')
+ r += htmltext('%s') % _('Back')
+ r += htmltext('
')
+ return r.getvalue()
- def import_disabled [html] (self):
+ def import_disabled(self):
if get_request().form.get('job'):
return self.participants_disabling()
@@ -764,16 +786,18 @@ class DiffusionDirectory(Directory):
get_response().breadcrumb.append( ('import', _('Import')) )
self.html_top(_('Import a List of Participants to Disable'))
- '
%s
' % _('Importing a List of Participants to Disable')
- '
'
- _('The file should be in the CSV file format. Using your spreadsheet '\
- 'program (Calc, Excel...), click "Save as" and select the CSV format.')
- '
'
- '
'
- _('The file should consist of email addresses, one per line.')
- '
'
- get_session().display_message()
- form.render()
+ r = TemplateIO(html=True)
+ r += htmltext('
%s
') % _('Importing a List of Participants to Disable')
+ r += htmltext('
')
+ r += _('The file should be in the CSV file format. Using your spreadsheet '\
+ 'program (Calc, Excel...), click "Save as" and select the CSV format.')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += _('The file should consist of email addresses, one per line.')
+ r += htmltext('
' % _(
'You are about to irrevocably delete this questionnaire.')))
@@ -129,8 +129,10 @@ class FormDirectory(FieldsDirectory):
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append(('delete', _('Delete')))
html_top('forms', title = _('Delete Questionnaire'))
- '
%s %s
' % (_('Deleting Questionnaire:'), self.objectdef.name)
- form.render()
+ r = TemplateIO(html=True)
+ r += htmltext('
%s %s
') % (_('Deleting Questionnaire:'), self.objectdef.name)
+ r += form.render()
+ return r.getvalue()
else:
# XXX: should also remove participants role, and participants to no
# other forms
@@ -144,31 +146,35 @@ class FormDirectory(FieldsDirectory):
return t
return self._q_index_view()
- def _q_index_view [html] (self):
+ def _q_index_view(self):
self.html_top(self.objectdef.name)
get_response().add_javascript(['jquery.js', 'interface.js', 'biglist.js'])
+ r = TemplateIO(html=True)
- self.index_top()
+ r += self.index_top()
form = self.get_preview_form()
- '
'
+ r += htmltext('%s') % _('Enabled')
+ r += ' - '
+ r += htmltext('%s') % _('Disabled')
+ r += htmltext('')
if not self.objectdef.disabled:
- '
%s ' % _('Current Status:')
+ r += htmltext('
%s ') % _('Current Status:')
if self.objectdef.asec_status == 'soon-available':
- '%s' % _('Soon Available')
+ r += htmltext('%s') % _('Soon Available')
else:
- '%s ' % _('Soon Available')
- ' - '
+ r += htmltext('%s ') % _('Soon Available')
+ r += ' - '
if self.objectdef.asec_status == 'running':
- '%s' % _('Running')
+ r += htmltext('%s') % _('Running')
else:
if self.objectdef.fields:
- '%s ' % _('Running')
+ r += htmltext('%s ') % _('Running')
else:
- _('Running')
- ' - '
+ r += _('Running')
+ r += ' - '
if self.objectdef.asec_status == 'closed':
- '%s' % _('Closed')
+ r += htmltext('%s') % _('Closed')
else:
if self.objectdef.fields:
- '%s ' % _('Closed')
+ r += htmltext('%s ') % _('Closed')
else:
- _('Closed')
- '
'
+ r += _('Closed')
+ r += htmltext('')
- '
'
+ r += htmltext('
')
if not self.objectdef.fields:
- '
'
- _('There are not yet any fields for this questionnaire.')
- '
'
- '
'
- _('You should use the controls at the right of the page to add fields.')
- '
'
+ r += htmltext('
')
+ r += _('There are not yet any fields for this questionnaire.')
+ r += htmltext('
')
+ r += htmltext('
')
+ r += _('You should use the controls at the right of the page to add fields.')
+ r += htmltext('
')
- '
%s
' % _('Contents of your questionnaire')
+ r += htmltext('
%s
') % _('Contents of your questionnaire')
+ return r.getvalue()
- def get_new_field_form [html] (self, page_no):
+ def get_new_field_form(self, page_no):
+ r = TemplateIO(html=True)
if not self.objectdef.disabled:
if not hasattr(self.objectdef, str('asec_status')):
self.objectdef.asec_status = 'running'
if self.objectdef.asec_status == 'soon-available':
if self.objectdef.data_class().keys():
- '
')
+ return r.getvalue()
def get_fields_from_query(self):
field_ids = [x for x in get_request().form.keys()]
@@ -171,8 +177,9 @@ class FormResultDirectory(FormPage):
return fields
- def list [html] (self):
+ def list(self):
self.html_top('%s - %s' % (_('List of results'), self.formdef.name))
+ r = TemplateIO(html=True)
fields = self.get_fields_from_query()
qs = ''
if get_request().get_query():
@@ -181,11 +188,11 @@ class FormResultDirectory(FormPage):
get_response().breadcrumb.append( ('list', _('List of results')) )
if len(fields) == 1:
- '
%s
' % fields[0].label
+ r += htmltext('
%s
') % fields[0].label
else:
- '
%s
' % _('List of results')
+ r += htmltext('
%s
') % _('List of results')
- '
'
+ r += htmltext('
')
for result in self.formdef.data_class().select(order_by='id'):
had_data = False
for field in fields:
@@ -219,19 +226,21 @@ class FormResultDirectory(FormPage):
continue
if not had_data:
- '
'
+ r += htmltext('
')
had_data = True
if len(fields) > 1:
- '
%s ' % field.label
- ''
- value
- '
'
+ r += htmltext('
%s ') % field.label
+ r += htmltext('')
+ r += value
+ r += htmltext('
') % field.label
+ r += htmltext('')
+ r += htmltext('')
for result in self.formdef.data_class().select(order_by='id'):
had_data = False
for field in fields:
@@ -274,32 +283,35 @@ class FormResultDirectory(FormPage):
value = value.replace(str('[download]'), str(''))
if not had_data:
- '
'
+ r += htmltext('
')
had_data = True
- '
'
- value
- '
'
+ r += htmltext('
')
+ r += value
+ r += htmltext('
')
if had_data:
- '
'
- ''
- '
'
+ r += htmltext('')
+ r += htmltext('')
+ r += htmltext('
') % last_title
last_title = None
- t
+ r += t
if had_page:
- '
'
+ r += htmltext('')
+ return r.getvalue()
- def _q_index [html] (self):
+ def _q_index(self):
wcs.forms.root.html_top(self.formdef.name)
+ r = TemplateIO(html=True)
# XXX: need an option to decide if we want results to be displayed
#values = self.formdef.data_class().select()
@@ -85,18 +89,19 @@ class ResultsDirectory(Directory):
if str(self.formdef.workflow_id).endswith(str('+anonymous')):
# Verification Code
- '
'
- '
%s
' % _('Anonymous Verification Code Check')
+ r += htmltext('
')
+ r += htmltext('
%s
') % _('Anonymous Verification Code Check')
form = Form(action='check')
form.add(StringWidget, 'code', title=('Verification Code'), required=True)
- _('Enter your verification code to check it against the recorded ballot.')
+ r += _('Enter your verification code to check it against the recorded ballot.')
form.add_submit('submit', _('Submit'))
- form.render()
- _('Or search for it in the list of all the ballots:')
- ' %s' % _('complete listing')
- '
'
+ r += form.render()
+ r += _('Or search for it in the list of all the ballots:')
+ r += htmltext(' %s') % _('complete listing')
+ r += htmltext('
')
+ return r.getvalue()
- def check [html] (self):
+ def check(self):
if not str(self.formdef.workflow_id).endswith(str('+anonymous')):
raise errors.TraversalError()
wcs.forms.root.html_top(self.formdef.name)
@@ -107,36 +112,39 @@ class ResultsDirectory(Directory):
return redirect('.')
code = get_request().form.get('code')
+ r = TemplateIO(html=True)
import anonymity
if code not in anonymity.get_verification_codes(self.formdef):
- '
'
- _('No ballot has been found with such a verification code.')
- '
'
+ r += htmltext('
')
+ r += _('No ballot has been found with such a verification code.')
+ r += htmltext('
')
else:
for formdata in self.formdef.data_class().select():
if hasattr(formdata, str('verification_code')) and formdata.verification_code == code:
form_status = wcs.forms.root.PublicFormStatusPage(self.formdef, formdata)
- '
'
- _('The following ballot has been recorded:')
- '
'
- form_status.receipt(show_status=False, show_signature=False, form_url=None)
+ r += htmltext('
')
+ r += _('The following ballot has been recorded:')
+ r += htmltext('