Port showform template to Jinja2

This commit is contained in:
Jan Dittberner 2015-11-11 00:50:28 +01:00
parent 1c86f707fa
commit 43ade2d35e
3 changed files with 69 additions and 167 deletions

View file

@ -1,7 +1,8 @@
from __future__ import unicode_literals
from flask.ext.babel import gettext as _
from flask.ext.wtf import Form
from wtforms import IntegerField, StringField
from wtforms import IntegerField, StringField, RadioField
from wtforms.validators import (
AnyOf, DataRequired, Email, Length, Optional, Regexp
)
@ -27,8 +28,10 @@ class DeveloperData(Form):
username = StringField('username', validators=[PlainText()])
nonddemail = StringField('nonddemail', validators=[Email()])
aliothusername = StringField('aliothusername', validators=[PlainText()])
mode = StringField(
'mode', default='html',validators=[AnyOf(['json', 'html'])]
mode = RadioField(
'mode', default='html', choices=[
('json', _('JSON')), ('html', _('HTML'))
], validators=[AnyOf(['json', 'html'])]
)
forumsid = IntegerField('forumsid', default=None, validators=[Optional()])
wikihomepage = StringField('wikihomepage', default=None, validators=[

View file

@ -35,6 +35,69 @@ with this program. If not, see <https://www.gnu.org/licenses/>.
</label><br />
{{ form.email }}<br />
</div>
<div id="showallfield" class="hidden">
<input type="checkbox" id="showall" name="showall"/>
<label for="showall">{{ _('Show all form fields') }}</label><br />
</div>
<div id="namefield"{% if form.name.errors %} class="witherrors"{% endif %}>
<label for="name">{{ _('Name:') }}{% if form.name.errors %}<br />
<span class="errormsg">{{ form.name.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.name }}
</div>
<div id="gpgfpfield"{% if form.gpgfp.errors %} class="witherrors"{% endif %}>
<label for="gpgfp">{{ _('GPG fingerprint:') }}{% if form.gpgfp.errors %}<br />
<span class="errormsg">{{ form.gpgfp.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.gpgfp }}
</div>
<div id="usernamefield"{% if form.username.errors %} class="witherrors"{% endif %}>
<label for="username">{{ _('Debian user name:') }}{% if form.username.errors %}<br />
<span class="errormsg">{{ form.username.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.username }}
</div>
<div id="nonddemailfield"{% if form.nonddemail.errors %} class="witherrors"{% endif %}>
<label for="nonddemail">{{ _('Non Debian email address:') }}{% if form.nonddemail.errors %}<br />
<span class="errormsg">{{ form.nonddemail.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.nonddemail }}
</div>
<div id="aliothusernamefield"{% if form.aliothusername.errors %} class="witherrors"{% endif %}>
<label for="aliothusername">{{ _('Alioth user name:') }}{% if form.aliothusername.errors %}<br />
<span class="errormsg">{{ form.aliothusername.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.aliothusername }}
</div>
<div id="wikihomepagefield"{% if form.wikihomepage.errors %} class="witherrors"{% endif %}>
<label for="wikihomepage">{{ _('Wiki user name:') }}{% if form.wikihomepage.errors %}<br />
<span class="errormsg">{{ form.wikihomepage.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.wikihomepage }}
</div>
<div id="forumsidfield"{% if form.forumsid.errors %} class="witherrors"{% endif %}>
<label for="forumsid">{{ _('Forum user id:') }}{% if form.forumsid.erros %}<br />
<span class="errormsg">{{ form.forumsid.errors|join(', ') }}</span>
{% endif %}
</label><br />
{{ form.forumsid }}
</div>
<div id="modefield"{% if form.mode.errors %} class="witherrors"{% endif %}>
<label for="mode">{{ _('Output format:') }}{% if form.mode.errors %}<br />
<span class="errormsg">{{ form.mode.errors|join(', ') }}</span>
{% endif %}
</label><br />
{% for subfield in form.mode %}
{{ subfield.label }}&#160;{{ subfield }}
{% endfor %}<br />
<input type="submit" value="{{ _('Build Debian Member Portfolio URLs') }}" />
</div>
</fieldset>
</form>
{% endblock %}

View file

@ -1,164 +0,0 @@
## -- coding: utf-8 -- \
<%inherit file="base.mako" />
<%doc>
Template for the data input form.
Copyright © 2009-2014 Jan Dittberner <jan@dittberner.info>
This file is part of the Debian Member Portfolio service.
Debian Member Portfolio service is free software: you can redistribute it
and/or modify it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Debian Member Portfolio service is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
General Public License for more details.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.
</%doc>
<%def name="titleaddon()">
- ${_('Enter your personal information')}
</%def>
<%def name="extrahead()">${h.javascript_link('/javascript/jquery/jquery.js',
h.url(controller='showformscripts', action='index'))}</%def>
${h.form(h.url(action='urllist', controller='portfolio'), method='get')}
<fieldset id="portfolio">
<legend>${_('Debian Member Portfolio')}</legend>
<div id="emailfield" \
% if 'email' in c.messages['errors']:
class="witherrors" \
% endif
>
<label for="email">${_('Email address:')}
% if 'email' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['email'] | h}</span>
% endif
</label><br />
${h.text('email',
h.escape(request.params.get('email', None)), id='email')}<br />
</div>
<div id="showallfield" class="hidden">
${h.checkbox('showall', value='1', checked=False, id='showall')}
<label for="showall">${_(u'Show all form fields')}</label><br />
</div>
<div id="namefield" \
% if 'name' in c.messages['errors']:
class="witherrors" \
% endif
>
<label for="name">${_('Name:')}
% if 'name' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['name'] | h}</span>
% endif
</label><br />
${h.text('name',
h.escape(request.params.get('name', None)), id='name')}<br />
</div>
<div id="gpgfpfield">
<label for="gpgfp">${_('GPG fingerprint:')}
% if 'gpgfp' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['gpgfp'] | h}</span>
% endif
</label><br />
${h.text('gpgfp',
h.escape(request.params.get('gpgfp', None)),
id='gpgfp')}<br />
</div>
<div id="usernamefield" \
% if 'username' in c.messages['errors']:
class="witherrors" \
% endif
>
<label for="username">${_('Debian user name:')}
% if 'username' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['username'] | h}</span>
% endif
</label><br />
${h.text('username',
h.escape(request.params.get('username', None)),
id='username')}<br />
</div>
<div id="nonddemailfield" \
% if 'nonddemail' in c.messages['errors']:
class="witherrors" \
% endif
>
<label for="nonddemail">${_('Non Debian email address:') | h}
% if 'nonddemail' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['nonddemail'] | h}</span>
% endif
</label><br />
${h.text('nonddemail',
h.escape(request.params.get('nonddemail', None)),
id='nonddemail')}<br />
</div>
<div id="aliothusernamefield" \
% if 'aliothusername' in c.messages['errors']:
class="witherrors"
% endif
>
<label for="aliothusername">${_('Alioth user name:')}
% if 'aliothusername' in c.messages['errors']:
<br />
<span
class="errormsg">${c.messages['errors']['aliothusername'] | h}</span>
% endif
</label><br />
${h.text('aliothusername',
h.escape(request.params.get('username', None)),
id='aliothusername')}<br />
</div>
<div id="wikihomepagefield" \
% if 'wikihomepage' in c.messages['errors']:
class="witherrors"
% endif
>
<label for="wikihomepage">${_('Wiki user name:')}
% if 'wikihomepage' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['wikihomepage'] | h}</span>
% endif
</label><br />
${h.text('wikihomepage',
h.escape(request.params.get('wikihomepage', None)),
id='wikihomepage')}<br />
</div>
<div id="forumsidfield" \
% if 'forumsid' in c.messages['errors']:
class="witherrors"
% endif
>
<label for="forumsid">${_('Forum user id:')}
% if 'forumsid' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['forumsid'] | h}</span>
% endif
</label><br />
${h.text('forumsid',
h.escape(request.params.get('forumsid', None)),
id='forumsid')}<br />
</div>
<div id="modefield">
<label for="mode_html">${_('Output format:')}
% if 'mode' in c.messages['errors']:
<br />
<span class="errormsg">${c.messages['errors']['mode'] | h}</span>
% endif
</label><br />
${_('HTML')}&#160;${h.radio('mode', 'html',
checked=(request.params.get('mode',
'html') == 'html'))}&#160;${_('JSON')}&#160;${h.radio('mode',
'json', checked=(request.params.get('mode', 'html') == 'json'))}<br />
${h.submit('submit', value=_('Build Debian Member Portfolio URLs'))}
</div>
</fieldset>
${h.end_form()}