diff --git a/actions/snapshot b/actions/snapshot index 051100ec0..39e6aaf2c 100755 --- a/actions/snapshot +++ b/actions/snapshot @@ -79,7 +79,8 @@ def _set_default_config(): 'snapper', 'set-config', 'TIMELINE_CREATE=yes', 'TIMELINE_LIMIT_HOURLY=10', 'TIMELINE_LIMIT_MONTHLY=2', 'TIMELINE_LIMIT_WEEKLY=2', 'TIMELINE_LIMIT_YEARLY=0', - 'TIMELINE_LIMIT_DAILY=3', 'NUMBER_MIN_AGE=1296000' + 'TIMELINE_LIMIT_DAILY=3', 'NUMBER_MIN_AGE=1296000', 'NUMBER_LIMIT=0', + 'NUMBER_LIMIT_IMPORTANT=4-10' ] subprocess.run(command, check=True) diff --git a/plinth/modules/snapshot/__init__.py b/plinth/modules/snapshot/__init__.py index b37e2f782..66fee3ace 100644 --- a/plinth/modules/snapshot/__init__.py +++ b/plinth/modules/snapshot/__init__.py @@ -25,7 +25,7 @@ from django.utils.translation import ugettext_lazy as _ from plinth import actions from plinth.menu import main_menu -version = 2 +version = 3 managed_packages = ['snapper'] @@ -61,12 +61,23 @@ def setup(helper, old_version=None): def get_configuration(): output = actions.superuser_run('snapshot', ['get-config']) output = json.loads(output) + + def get_boolean_choice(status): + return ('yes', 'Enabled') if status else ('no', 'Disabled') + return { - 'enable_timeline_snapshots': output['TIMELINE_CREATE'] == 'yes', - 'hourly_limit': output['TIMELINE_LIMIT_HOURLY'], - 'daily_limit': output['TIMELINE_LIMIT_DAILY'], - 'weekly_limit': output['TIMELINE_LIMIT_WEEKLY'], - 'yearly_limit': output['TIMELINE_LIMIT_YEARLY'], - 'monthly_limit': output['TIMELINE_LIMIT_MONTHLY'], - 'number_min_age': round(int(output['NUMBER_MIN_AGE']) / 86400), + 'enable_timeline_snapshots': + get_boolean_choice(output['TIMELINE_CREATE'] == 'yes'), + 'hourly_limit': + output['TIMELINE_LIMIT_HOURLY'], + 'daily_limit': + output['TIMELINE_LIMIT_DAILY'], + 'weekly_limit': + output['TIMELINE_LIMIT_WEEKLY'], + 'yearly_limit': + output['TIMELINE_LIMIT_YEARLY'], + 'monthly_limit': + output['TIMELINE_LIMIT_MONTHLY'], + 'number_min_age': + round(int(output['NUMBER_MIN_AGE']) / 86400), } diff --git a/plinth/modules/snapshot/forms.py b/plinth/modules/snapshot/forms.py index 23ec8fc0e..48be5f3cc 100644 --- a/plinth/modules/snapshot/forms.py +++ b/plinth/modules/snapshot/forms.py @@ -23,26 +23,27 @@ from django.utils.translation import ugettext_lazy as _ class SnapshotForm(forms.Form): - enable_timeline_snapshots = forms.BooleanField( - label=_('Enable Timeline Snapshots'), required=False, help_text=_( - 'Uncheck this to disable timeline snapshots ' - '(hourly, daily, monthly and yearly).')) + enable_timeline_snapshots = forms.ChoiceField( + label=_('Timeline Snapshots'), + help_text=_('Enable or disable timeline snapshots ' + '(hourly, daily, monthly and yearly).'), + choices=[('yes', 'Enabled'), ('no', 'Disabled')]) hourly_limit = forms.IntegerField( - label=_('Hourly Snapshots Limit'), min_value=0, help_text=_( - 'Keep a maximum of this many hourly snapshots.')) + label=_('Hourly Snapshots Limit'), min_value=0, + help_text=_('Keep a maximum of this many hourly snapshots.')) daily_limit = forms.IntegerField( - label=_('Daily Snapshots Limit'), min_value=0, help_text=_( - 'Keep a maximum of this many daily snapshots.')) + label=_('Daily Snapshots Limit'), min_value=0, + help_text=_('Keep a maximum of this many daily snapshots.')) weekly_limit = forms.IntegerField( - label=_('Weekly Snapshots Limit'), min_value=0, help_text=_( - 'Keep a maximum of this many weekly snapshots.')) + label=_('Weekly Snapshots Limit'), min_value=0, + help_text=_('Keep a maximum of this many weekly snapshots.')) monthly_limit = forms.IntegerField( - label=_('Monthly Snapshots Limit'), min_value=0, help_text=_( - 'Keep a maximum of this many monthly snapshots.')) + label=_('Monthly Snapshots Limit'), min_value=0, + help_text=_('Keep a maximum of this many monthly snapshots.')) yearly_limit = forms.IntegerField( label=_('Yearly Snapshots Limit'), min_value=0, help_text=_( diff --git a/plinth/modules/snapshot/templates/snapshot.html b/plinth/modules/snapshot/templates/snapshot.html index ea43c8959..297f1ee17 100644 --- a/plinth/modules/snapshot/templates/snapshot.html +++ b/plinth/modules/snapshot/templates/snapshot.html @@ -22,13 +22,13 @@ {% load i18n %} {% block configuration %} -
-
{% endblock %} diff --git a/plinth/modules/snapshot/templates/snapshot_manage.html b/plinth/modules/snapshot/templates/snapshot_manage.html index 8df08307b..573fdfb42 100644 --- a/plinth/modules/snapshot/templates/snapshot_manage.html +++ b/plinth/modules/snapshot/templates/snapshot_manage.html @@ -26,19 +26,19 @@