From 176e7ecae361fc77d7a5eb6ac186501b3d348109 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 19 Dec 2019 15:07:11 -0800 Subject: [PATCH] help: Refactor to move app into __init__.py for consistency Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/help/__init__.py | 47 ++++++++++++++++++++++++++++-- plinth/modules/help/help.py | 51 +-------------------------------- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/plinth/modules/help/__init__.py b/plinth/modules/help/__init__.py index 030aaf76a..c1f215a32 100644 --- a/plinth/modules/help/__init__.py +++ b/plinth/modules/help/__init__.py @@ -18,11 +18,52 @@ FreedomBox app for help pages. """ -from . import help # pylint: disable-msg=W0622 -from .help import init +from django.utils.translation import ugettext_lazy as _ -__all__ = ['help', 'init'] +from plinth import menu +from plinth.app import App version = 1 is_essential = True +app = None + + +class HelpApp(App): + """FreedomBox app for showing help.""" + + app_id = 'help' + + def __init__(self): + """Create components for the app.""" + super().__init__() + menu_item = menu.Menu('menu-help', _('Documentation'), None, 'fa-book', + 'help:index', parent_url_name='index') + self.add(menu_item) + menu_item = menu.Menu('menu-help-manual', _('Manual'), None, + 'fa-info-circle', 'help:manual', + parent_url_name='help:index', order=10) + self.add(menu_item) + menu_item = menu.Menu('menu-help-support', _('Get Support'), None, + 'fa-life-ring', 'help:support', + parent_url_name='help:index', order=20) + self.add(menu_item) + menu_item = menu.Menu('menu-help-feedback', _('Submit Feedback'), None, + 'fa-comments', 'help:feedback', + parent_url_name='help:index', order=25) + self.add(menu_item) + menu_item = menu.Menu('menu-help-contribute', _('Contribute'), None, + 'fa-wrench', 'help:contribute', + parent_url_name='help:index', order=30) + self.add(menu_item) + menu_item = menu.Menu('menu-help-about', _('About'), None, 'fa-star', + 'help:about', parent_url_name='help:index', + order=100) + self.add(menu_item) + + +def init(): + """Initialize the Help module""" + global app + app = HelpApp() + app.set_enabled(True) diff --git a/plinth/modules/help/help.py b/plinth/modules/help/help.py index f16893dc9..0316dd26c 100644 --- a/plinth/modules/help/help.py +++ b/plinth/modules/help/help.py @@ -30,57 +30,8 @@ from django.template.response import TemplateResponse from django.urls import reverse from django.utils.translation import get_language_from_request from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_lazy -from plinth import __version__, actions -from plinth import app as app_module -from plinth import cfg, menu - -app = None - - -class HelpApp(app_module.App): - """FreedomBox app for showing help.""" - - app_id = 'help' - - def __init__(self): - """Create components for the app.""" - super().__init__() - menu_item = menu.Menu('menu-help', ugettext_lazy('Documentation'), - None, 'fa-book', 'help:index', - parent_url_name='index') - self.add(menu_item) - menu_item = menu.Menu('menu-help-manual', ugettext_lazy('Manual'), - None, 'fa-info-circle', 'help:manual', - parent_url_name='help:index', order=10) - self.add(menu_item) - menu_item = menu.Menu('menu-help-support', - ugettext_lazy('Get Support'), None, - 'fa-life-ring', 'help:support', - parent_url_name='help:index', order=20) - self.add(menu_item) - menu_item = menu.Menu('menu-help-feedback', - ugettext_lazy('Submit Feedback'), None, - 'fa-comments', 'help:feedback', - parent_url_name='help:index', order=25) - self.add(menu_item) - menu_item = menu.Menu('menu-help-contribute', - ugettext_lazy('Contribute'), None, 'fa-wrench', - 'help:contribute', parent_url_name='help:index', - order=30) - self.add(menu_item) - menu_item = menu.Menu('menu-help-about', ugettext_lazy('About'), None, - 'fa-star', 'help:about', - parent_url_name='help:index', order=100) - self.add(menu_item) - - -def init(): - """Initialize the Help module""" - global app - app = HelpApp() - app.set_enabled(True) +from plinth import __version__, actions, cfg def index(request):