]>
git.ipfire.org Git - people/ms/westferry.git/blob - src/westferry/handlers/demo.py
913cd65a699836537fc84193dc64964633212aaf
2 ###############################################################################
4 # Westferry - The IPFire web user interface #
5 # Copyright (C) 2015 IPFire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 from ..i18n
import N_
, _
27 class BaseHandler(base
.BaseHandler
):
30 _
= self
.locale
.translate
32 m
= ui
.menus
.Menu(self
, _("Demo"))
35 m
.add_handler(OverviewHandler
)
38 m
.add_handler(FormsHandler
)
43 class OverviewHandler(BaseHandler
):
45 title
= N_("Overview")
48 self
.render("demo/index.html")
51 class FormsHandler(BaseHandler
):
56 _
= self
.locale
.translate
59 tab
= self
.tabs
.add_tab("example-1", _("Example 1"))
61 # Add a form to the tab
62 form
= tab
.add_form("example-1")
63 form
.submit_text
= _("Order")
66 e
= form
.add_text_input("first_name", label
=_("First Name"), placeholder
="John")
67 e
.help = _("Please enter your first name")
70 e
= form
.add_text_input("last_name", label
=_("Last Name"), placeholder
="Doe")
71 e
.help = _("Please enter your last name")
73 # We create a fieldset for the address
74 fs1
= form
.add_fieldset(label
=_("Address"))
75 fs1
.help = _("Please enter your address")
77 e
= fs1
.add_text_input("street", label
=_("Street"))
78 e
= fs1
.add_text_input("city", label
=_("City"))
79 e
= fs1
.add_text_input("post_code", label
=_("Postcode"))
81 # Fieldset without label
82 fs2
= form
.add_fieldset()
85 e
= fs2
.add_text_input("donation", label
=_("Donation"),
86 placeholder
=_("Donation"), suffix
="€")
89 e
= fs2
.add_multiline_text_input("notes", label
=_("Notes"))
91 # Subscribe to newsletter?
92 e
= fs2
.add_yesno_input("subscribe_to_newsletter", description
=_("Subscribe to newsletter?"))