mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Introduce component architecture and menu component
- Introduce base class for all apps that will contain components. With
unittests.
- Introduce base classes for components. With unittests.
- Turn Menu class into an app component.
- Further cleanup Menu class.
- Update tests.
- Maintain a global list of menu items and look them up easily. Generalize
such that subsubmenus can later be merged into Menu class.
- Cleanup scope of main menu initialization.
- Use None instead of empty strings for various values. Ensure that
printing short_description does not show 'None' in output.
- Use enable/disable instead of promote/demote.
- Use menu component in all apps.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
61 files changed
+1527
-567
No files matched your search
@@ -22,8 +22,9 @@ import subprocess
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import app as app_module
|
||||
from plinth import menu
|
||||
from plinth import service as service_module
|
||||
from plinth.menu import main_menu
|
||||
|
||||
from .manifest import backup
|
||||
|
||||
@@ -46,11 +47,25 @@ manual_page = 'DateTime'
|
||||
|
||||
service = None
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class DateTimeApp(app_module.App):
|
||||
"""FreedomBox app for date and time."""
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
menu_item = menu.Menu('menu-datetime', name, None, 'fa-clock-o',
|
||||
'datetime:index', parent_url_name='system')
|
||||
self.add(menu_item)
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the date/time module."""
|
||||
menu = main_menu.get('system')
|
||||
menu.add_urlname(name, 'fa-clock-o', 'datetime:index')
|
||||
global app
|
||||
app = DateTimeApp()
|
||||
app.set_enabled(True)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
@@ -67,6 +82,7 @@ def setup(helper, old_version=None):
|
||||
is_external=True)
|
||||
service.enable()
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', app.enable)
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
Reference in new issue
Block a user