From 1c338e538a7e7fbd00d6f1eaec4e43d15a2b9b8f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 8 May 2014 09:05:50 +0530 Subject: [PATCH] Convert firewall page to template --- modules/installed/system/firewall.py | 93 +++---------------- .../installed/system/templates/firewall.html | 64 +++++++++++++ 2 files changed, 77 insertions(+), 80 deletions(-) create mode 100644 modules/installed/system/templates/firewall.html diff --git a/modules/installed/system/firewall.py b/modules/installed/system/firewall.py index aa09c86dd..e736627f1 100644 --- a/modules/installed/system/firewall.py +++ b/modules/installed/system/firewall.py @@ -49,91 +49,24 @@ class Firewall(PagePlugin): """Serve introcution page""" del kwargs # Unused - # XXX: Use templates here instead of generating HTML - main = _(''' -

Firewall is a network security system that controls the incoming -and outgoing network traffic on your {box_name}. Keeping a firewall -enabled and properly configured reduces risk of security threat from -the Internet.

- -

The following the current status:

-''').format(box_name=cfg.box_name) - if not self.get_installed_status(): - status = _(''' -

Firewall is not installed. Please install it. Firewall comes -pre-installed with {box_name}. On any Debian based system (such as -{box_name}) you may install it using the command 'aptitude install -firewalld'

''').format(box_name=cfg.box_name) - - return util.render_template(title=_("Firewall"), - main=main + status) + return util.render_template(template='firewall', + title=_("Firewall"), + firewall_status='not_installed') if not self.get_enabled_status(): - status = _(''' -

Firewall daemon is not running. Please run it. Firewall comes -enabled by default on {box_name}. On any Debian based system (such as -{box_name}) you may run it using the command 'service firewalld start' -or in case of system with systemd 'systemctl start firewalld'

-''').format(box_name=cfg.box_name) + return util.render_template(template='firewall', + title=_("Firewall"), + firewall_status='not_running') - return util.render_template(title=_("Firewall"), - main=main + status) + internal_enabled_services = self.get_enabled_services(zone='internal') + external_enabled_services = self.get_enabled_services(zone='external') - internal_enabled_sevices = self.get_enabled_services(zone='internal') - external_enabled_sevices = self.get_enabled_services(zone='external') - - services_info = '' - - footnote = ''' -

The operation of the firewall is automatic. When you enable a -service it is automatically permitted in the firewall and you disable -a service is automatically disabled in the firewall.

''' - - return util.render_template(title=_("Firewall"), main=main + - services_info + footnote) + return util.render_template( + template='firewall', title=_('Firewall'), + services=service_module.SERVICES.values(), + internal_enabled_services=internal_enabled_services, + external_enabled_services=external_enabled_services) def get_installed_status(self): """Return whether firewall is installed""" diff --git a/modules/installed/system/templates/firewall.html b/modules/installed/system/templates/firewall.html new file mode 100644 index 000000000..8cd5aff67 --- /dev/null +++ b/modules/installed/system/templates/firewall.html @@ -0,0 +1,64 @@ +{% extends "login_nav.html" %} + +{% block main_block %} + +

Firewall is a network security system that controls the incoming +and outgoing network traffic on your {{ cfg.box_name }}. Keeping a +firewall enabled and properly configured reduces risk of security +threat from the Internet.

+ +

The following the current status:

+ +{% if firewall_status = 'not_installed' %} +

Firewall is not installed. Please install it. Firewall comes +pre-installed with {{ cfg.box_name }}. On any Debian based system +(such as {{ cfg.box_name }}) you may install it using the command 'aptitude +install firewalld'

+ +{% elif firewall_status = 'not_running' %} + +

Firewall daemon is not running. Please run it. Firewall comes +enabled by default on {{ cfg.box_name }}. On any Debian based system +(such as {{ cfg.box_name }}) you may run it using the command 'service +firewalld start' or in case of a system with systemd 'systemctl start +firewalld'

+ +{% else %} + + + +

The operation of the firewall is automatic. When you enable a +service it is automatically permitted in the firewall and you disable +a service is automatically disabled in the firewall.

+ +{% endif %} + +{% endblock %}