diff --git a/cookbook/forms.py b/cookbook/forms.py index 4ef327c84..d2ccf60ea 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -31,7 +31,7 @@ class UserPreferenceForm(forms.ModelForm): class Meta: model = UserPreference - fields = ('default_unit', 'theme', 'nav_color') + fields = ('default_unit', 'theme', 'nav_color', 'default_page') help_texts = { 'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'), diff --git a/cookbook/migrations/0033_userpreference_default_page.py b/cookbook/migrations/0033_userpreference_default_page.py new file mode 100644 index 000000000..11fca7df1 --- /dev/null +++ b/cookbook/migrations/0033_userpreference_default_page.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2020-04-13 20:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0032_userpreference_default_unit'), + ] + + operations = [ + migrations.AddField( + model_name='userpreference', + name='default_page', + field=models.CharField(choices=[('SEARCH', 'Search'), ('PLAN', 'Meal-Plan')], default='SEARCH', max_length=64), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index db5b85b59..53a5cf7c1 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -41,10 +41,18 @@ class UserPreference(models.Model): COLORS = ((PRIMARY, 'Primary'), (SECONDARY, 'Secondary'), (SUCCESS, 'Success'), (INFO, 'Info'), (WARNING, 'Warning'), (DANGER, 'Danger'), (LIGHT, 'Light'), (DARK, 'Dark')) + # Default Page + SEARCH = 'SEARCH' + PLAN = 'PLAN' + BOOKS = 'BOOKS' + + PAGES = ((SEARCH, _('Search')), (PLAN, _('Meal-Plan')), (BOOKS, _('Books')), ) + user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) theme = models.CharField(choices=THEMES, max_length=128, default=FLATLY) nav_color = models.CharField(choices=COLORS, max_length=128, default=PRIMARY) default_unit = models.CharField(max_length=32, default='g') + default_page = models.CharField(choices=PAGES, max_length=64, default=SEARCH) def __str__(self): return self.user diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 0ba41c4df..0121ca4ca 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -74,8 +74,8 @@