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:
Sunil Mohan Adapa committed 2019-06-07 11:48:04 -07:00
1 parent 0eee8ddf65
commit b96d901071
61 files changed
+1527 -567

No files matched your search

+18 -3
View File
@@ -23,7 +23,8 @@ import subprocess
from django.utils.translation import ugettext_lazy as _
from plinth import action_utils, actions
from plinth.menu import main_menu
from plinth import app as app_module
from plinth import menu
version = 2
@@ -47,11 +48,25 @@ name = _('Users and Groups')
# All FreedomBox user groups
groups = dict()
app = None
class UsersApp(app_module.App):
"""FreedomBox app for users and groups management."""
def __init__(self):
"""Create components for the app."""
super().__init__()
menu_item = menu.Menu('menu-users', name, None, 'fa-users',
'users:index', parent_url_name='system')
self.add(menu_item)
def init():
"""Intialize the user module."""
menu = main_menu.get('system')
menu.add_urlname(name, 'fa-users', 'users:index')
global app
app = UsersApp()
app.set_enabled(True)
def setup(helper, old_version=None):