diff --git a/babybuddy/admin.py b/babybuddy/admin.py
index 285017cb..5f35f234 100644
--- a/babybuddy/admin.py
+++ b/babybuddy/admin.py
@@ -14,7 +14,10 @@ class SettingsInline(admin.StackedInline):
can_delete = False
fieldsets = (
(_('Dashboard'), {
- 'fields': ('dashboard_refresh_rate', 'dashboard_hide_empty',)
+ 'fields': (
+ 'dashboard_refresh_rate',
+ 'dashboard_hide_empty',
+ 'dashboard_hide_age')
}),
)
diff --git a/babybuddy/forms.py b/babybuddy/forms.py
index 3bb49dfe..c48ce900 100644
--- a/babybuddy/forms.py
+++ b/babybuddy/forms.py
@@ -44,6 +44,7 @@ class UserSettingsForm(forms.ModelForm):
fields = [
'dashboard_refresh_rate',
'dashboard_hide_empty',
+ 'dashboard_hide_age',
'language',
'timezone'
]
diff --git a/babybuddy/migrations/0017_settings_hide_age.py b/babybuddy/migrations/0017_settings_hide_age.py
new file mode 100644
index 00000000..3373cb09
--- /dev/null
+++ b/babybuddy/migrations/0017_settings_hide_age.py
@@ -0,0 +1,28 @@
+from django.db import migrations, models
+from django.utils import timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('babybuddy', '0016_alter_settings_timezone'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='settings',
+ name='dashboard_hide_age',
+ field=models.DurationField(
+ choices=[
+ (None, 'show all data'),
+ (timezone.timedelta(days=1), '1 day'),
+ (timezone.timedelta(days=2), '2 days'),
+ (timezone.timedelta(days=3), '3 days'),
+ (timezone.timedelta(weeks=1), '1 week'),
+ (timezone.timedelta(weeks=4), '4 weeks')
+ ],
+ default=None,
+ null=True,
+ verbose_name='Hide data older than'),
+ ),
+ ]
diff --git a/babybuddy/models.py b/babybuddy/models.py
index 90b708f3..9db037e4 100644
--- a/babybuddy/models.py
+++ b/babybuddy/models.py
@@ -39,6 +39,21 @@ class Settings(models.Model):
default=False,
editable=True
)
+ dashboard_hide_age = models.DurationField(
+ verbose_name=_('Hide data older than'),
+ help_text=_('This setting controls which data will be shown '
+ 'in the dashboard.'),
+ blank=True,
+ null=True,
+ default=None,
+ choices=[
+ (None, _('show all data')),
+ (timezone.timedelta(days=1), _('1 day')),
+ (timezone.timedelta(days=2), _('2 days')),
+ (timezone.timedelta(days=3), _('3 days')),
+ (timezone.timedelta(weeks=1), _('1 week')),
+ (timezone.timedelta(weeks=4), _('4 weeks')),
+ ])
language = models.CharField(
choices=settings.LANGUAGES,
default=settings.LANGUAGE_CODE,
diff --git a/babybuddy/templates/babybuddy/user_settings_form.html b/babybuddy/templates/babybuddy/user_settings_form.html
index 77f188db..2bb91a7b 100644
--- a/babybuddy/templates/babybuddy/user_settings_form.html
+++ b/babybuddy/templates/babybuddy/user_settings_form.html
@@ -69,6 +69,11 @@
{% include 'babybuddy/form_field.html' %}
{% endwith %}
+
+ {% with form_settings.dashboard_hide_age as field %}
+ {% include 'babybuddy/form_field.html' %}
+ {% endwith %}
+