]> git.ipfire.org Git - people/ms/westferry.git/blob - src/westferry/handlers/system.py
system: Add proof-of-concept for automatic form data saving
[people/ms/westferry.git] / src / westferry / handlers / system.py
1 #!/usr/bin/python3
2 ###############################################################################
3 # #
4 # Westferry - The IPFire web user interface #
5 # Copyright (C) 2021 IPFire development team #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21
22 from . import base
23 from .. import ui
24 from ..i18n import N_
25
26 class BaseHandler(base.BaseHandler):
27 @property
28 def menu(self):
29 _ = self.locale.translate
30
31 menu = ui.menus.Menu(self, _("System"))
32
33 # Summary
34 menu.add_handler(SummaryHandler)
35
36 # Settings
37 menu.add_handler(SettingsHandler)
38
39 return menu
40
41
42 class SummaryHandler(BaseHandler):
43 title = N_("Summary")
44 url = r"/system"
45
46
47
48
49 class SettingsHandler(BaseHandler):
50 title = N_("Settings")
51 url = r"/system/settings"
52
53 def initialize(self):
54 # Create a tab with general settings
55 self._make_general()
56
57 def _make_general(self):
58 _ = self.locale.translate
59
60 tab = self.tabs.add_tab("general", _("General"))
61
62 # Add a form
63 form = tab.add_form()
64
65 form.add_text_input("hostname", _("Hostname"), object=self.backend.system)