firstboot: Fix caching issue in collecting first_boot steps

- Created a django singal to indicate that a setup happened

- Clearing the cached list of firstboot_steps each time the above signal is sent

Closes #1193.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2018-01-22 11:51:37 +05:30 committed by Sunil Mohan Adapa
parent ebcbd6bfa5
commit 4826f70343
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
4 changed files with 24 additions and 7 deletions

View File

@ -14,15 +14,16 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Plinth module for first boot wizard
"""
from django.urls import reverse
import operator
from django.urls import reverse
from plinth import module_loader
from plinth.signals import post_setup
version = 1
@ -47,6 +48,17 @@ _all_first_boot_steps = None
_is_completed = None
def init():
"""Initialize the first boot module."""
post_setup.connect(_clear_first_boot_steps)
def _clear_first_boot_steps(sender, module_name, **kwargs):
"""Flush the cache of first boot steps so it is recreated."""
global _all_first_boot_steps
_all_first_boot_steps = None
def is_firstboot_url(path):
"""Return whether a path is a firstboot step URL.

View File

@ -141,10 +141,9 @@ class FirstBootView(FormView):
form_class = FirstBootForm
def get(self, request, *args, **kwargs):
"""Skip if this first boot step if it is not relavent."""
"""Skip this first boot step if it is not relevant."""
if not cfg.danube_edition:
first_boot.mark_step_done('pagekite_firstboot')
return HttpResponseRedirect(reverse(first_boot.next_step()))
return first_boot_skip(request)
return super().get(request, *args, **kwargs)

View File

@ -18,14 +18,17 @@
Plinth module with utilites for performing application setup operations.
"""
import apt
import logging
import threading
import time
import apt
import plinth
from plinth.signals import post_setup
from . import package
from .errors import PackageNotInstalledError
import plinth
logger = logging.getLogger(__name__)
@ -91,6 +94,8 @@ class Helper(object):
raise exception
else:
self.set_setup_version(self.module.version)
post_setup.send_robust(sender=self.__class__,
module_name=self.module_name)
finally:
self.is_finished = True
self.current_operation = None

View File

@ -25,6 +25,7 @@ from django.dispatch import Signal
service_enabled = Signal(providing_args=['service_id', 'enabled'])
pre_module_loading = Signal()
post_module_loading = Signal()
post_setup = Signal(providing_args=['module_name'])
pre_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
post_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
domainname_change = Signal(providing_args=['old_domainname', 'new_domainname'])