diff --git a/cookbook/forms.py b/cookbook/forms.py index 7be812626..5a529a58a 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -29,7 +29,11 @@ class DateWidget(forms.DateInput): class UserPreferenceForm(forms.ModelForm): class Meta: model = UserPreference - fields = ('theme',) + fields = ('theme', 'nav_color') + + help_texts = { + 'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!') + } class ExternalRecipeForm(forms.ModelForm): diff --git a/cookbook/migrations/0025_userpreference_nav_color.py b/cookbook/migrations/0025_userpreference_nav_color.py new file mode 100644 index 000000000..21917c354 --- /dev/null +++ b/cookbook/migrations/0025_userpreference_nav_color.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.2 on 2020-02-16 23:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0024_auto_20200216_2313'), + ] + + operations = [ + migrations.AddField( + model_name='userpreference', + name='nav_color', + field=models.CharField(choices=[('PRIMARY', 'Primary'), ('SECONDARY', 'Secondary'), ('SUCCESS', 'Success'), ('INFO', 'Info'), ('WARNING', 'Warning'), ('DANGER', 'Danger'), ('LIGHT', 'Light'), ('DARK', 'Dark')], default='PRIMARY', max_length=128), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index db62a1623..d40da63ec 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -4,6 +4,7 @@ from django.db import models class UserPreference(models.Model): + # Themes BOOTSTRAP = 'BOOTSTRAP' DARKLY = 'DARKLY' FLATLY = 'FLATLY' @@ -11,8 +12,21 @@ class UserPreference(models.Model): THEMES = ((BOOTSTRAP, 'Bootstrap'), (DARKLY, 'Darkly'), (FLATLY, 'Flatly'), (SUPERHERO, 'Superhero')) + # Nav colors + PRIMARY = 'PRIMARY' + SECONDARY = 'SECONDARY' + SUCCESS = 'SUCCESS' + INFO = 'INFO' + WARNING = 'WARNING' + DANGER = 'DANGER' + LIGHT = 'LIGHT' + DARK = 'DARK' + + COLORS = ((PRIMARY, 'Primary'), (SECONDARY, 'Secondary'), (SUCCESS, 'Success'), (INFO, 'Info'), (WARNING, 'Warning'), (DANGER, 'Danger'), (LIGHT, 'Light'), (DARK, 'Dark')) + 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) class Storage(models.Model): diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index a9690c1f4..f4da70fe4 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -66,7 +66,7 @@
-