mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-10 00:28:22 -05:00
@@ -30,7 +30,7 @@ class UserPreferenceForm(forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserPreference
|
model = UserPreference
|
||||||
fields = ('default_unit', 'use_fractions', 'theme', 'nav_color', 'default_page', 'show_recent', 'search_style', 'plan_share', 'ingredient_decimals', 'shopping_auto_sync', 'comments')
|
fields = ('default_unit', 'use_fractions', 'theme', 'nav_color', 'sticky_navbar', 'default_page', 'show_recent', 'search_style', 'plan_share', 'ingredient_decimals', 'shopping_auto_sync', 'comments')
|
||||||
|
|
||||||
help_texts = {
|
help_texts = {
|
||||||
'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'),
|
'nav_color': _('Color of the top navigation bar. Not all colors work with all themes, just try them out!'),
|
||||||
@@ -42,7 +42,8 @@ class UserPreferenceForm(forms.ModelForm):
|
|||||||
'comments': _('If you want to be able to create and see comments underneath recipes.'),
|
'comments': _('If you want to be able to create and see comments underneath recipes.'),
|
||||||
'shopping_auto_sync': _(
|
'shopping_auto_sync': _(
|
||||||
'Setting to 0 will disable auto sync. When viewing a shopping list the list is updated every set seconds to sync changes someone else might have made. Useful when shopping with multiple people but might use a little bit '
|
'Setting to 0 will disable auto sync. When viewing a shopping list the list is updated every set seconds to sync changes someone else might have made. Useful when shopping with multiple people but might use a little bit '
|
||||||
'of mobile data. If lower than instance limit it is reset when saving.')
|
'of mobile data. If lower than instance limit it is reset when saving.'),
|
||||||
|
'sticky_navbar': _('Makes the navbar stick to the top of the page.')
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
|
|||||||
24
cookbook/migrations/0095_auto_20210107_1804.py
Normal file
24
cookbook/migrations/0095_auto_20210107_1804.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 3.1.5 on 2021-01-07 17:04
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0094_auto_20201231_1238'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='userpreference',
|
||||||
|
name='sticky_navbar',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='invitelink',
|
||||||
|
name='valid_until',
|
||||||
|
field=models.DateField(default=datetime.date(2021, 1, 21)),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -10,7 +10,7 @@ from django.utils.translation import gettext as _
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django_random_queryset import RandomManager
|
from django_random_queryset import RandomManager
|
||||||
|
|
||||||
from recipes.settings import COMMENT_PREF_DEFAULT, FRACTION_PREF_DEFAULT
|
from recipes.settings import COMMENT_PREF_DEFAULT, FRACTION_PREF_DEFAULT, STICKY_NAV_PREF_DEFAULT
|
||||||
|
|
||||||
|
|
||||||
def get_user_name(self):
|
def get_user_name(self):
|
||||||
@@ -78,6 +78,7 @@ class UserPreference(models.Model):
|
|||||||
ingredient_decimals = models.IntegerField(default=2)
|
ingredient_decimals = models.IntegerField(default=2)
|
||||||
comments = models.BooleanField(default=COMMENT_PREF_DEFAULT)
|
comments = models.BooleanField(default=COMMENT_PREF_DEFAULT)
|
||||||
shopping_auto_sync = models.IntegerField(default=5)
|
shopping_auto_sync = models.IntegerField(default=5)
|
||||||
|
sticky_navbar = models.BooleanField(default=STICKY_NAV_PREF_DEFAULT)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.user)
|
return str(self.user)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-{% nav_color request %}" id="id_main_nav">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-{% nav_color request %}" id="id_main_nav" style="{% sticky_nav request %}">
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText"
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText"
|
||||||
aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
|
aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
@@ -211,4 +211,4 @@
|
|||||||
{% endblock script %}
|
{% endblock script %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from django import template
|
|||||||
from django.templatetags.static import static
|
from django.templatetags.static import static
|
||||||
|
|
||||||
from cookbook.models import UserPreference
|
from cookbook.models import UserPreference
|
||||||
|
from recipes.settings import STICKY_NAV_PREF_DEFAULT
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@@ -29,6 +30,15 @@ def nav_color(request):
|
|||||||
return request.user.userpreference.nav_color.lower()
|
return request.user.userpreference.nav_color.lower()
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def sticky_nav(request):
|
||||||
|
if (not request.user.is_authenticated and STICKY_NAV_PREF_DEFAULT) or \
|
||||||
|
(request.user.is_authenticated and request.user.userpreference.sticky_navbar):
|
||||||
|
return 'position: sticky; top: 0; left: 0; z-index: 1000;'
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def tabulator_theme_url(request):
|
def tabulator_theme_url(request):
|
||||||
if not request.user.is_authenticated:
|
if not request.user.is_authenticated:
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ def user_settings(request):
|
|||||||
up.ingredient_decimals = form.cleaned_data['ingredient_decimals']
|
up.ingredient_decimals = form.cleaned_data['ingredient_decimals']
|
||||||
up.comments = form.cleaned_data['comments']
|
up.comments = form.cleaned_data['comments']
|
||||||
up.use_fractions = form.cleaned_data['use_fractions']
|
up.use_fractions = form.cleaned_data['use_fractions']
|
||||||
|
up.sticky_navbar = form.cleaned_data['sticky_navbar']
|
||||||
|
|
||||||
up.shopping_auto_sync = form.cleaned_data['shopping_auto_sync']
|
up.shopping_auto_sync = form.cleaned_data['shopping_auto_sync']
|
||||||
if up.shopping_auto_sync < settings.SHOPPING_MIN_AUTOSYNC_INTERVAL:
|
if up.shopping_auto_sync < settings.SHOPPING_MIN_AUTOSYNC_INTERVAL:
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ REVERSE_PROXY_AUTH = bool(int(os.getenv('REVERSE_PROXY_AUTH', False)))
|
|||||||
# default value for user preference 'comment'
|
# default value for user preference 'comment'
|
||||||
COMMENT_PREF_DEFAULT = bool(int(os.getenv('COMMENT_PREF_DEFAULT', True)))
|
COMMENT_PREF_DEFAULT = bool(int(os.getenv('COMMENT_PREF_DEFAULT', True)))
|
||||||
FRACTION_PREF_DEFAULT = bool(int(os.getenv('FRACTION_PREF_DEFAULT', False)))
|
FRACTION_PREF_DEFAULT = bool(int(os.getenv('FRACTION_PREF_DEFAULT', False)))
|
||||||
|
STICKY_NAV_PREF_DEFAULT = bool(int(os.getenv('STICKY_NAV_PREF_DEFAULT', True)))
|
||||||
|
|
||||||
# minimum interval that users can set for automatic sync of shopping lists
|
# minimum interval that users can set for automatic sync of shopping lists
|
||||||
SHOPPING_MIN_AUTOSYNC_INTERVAL = int(os.getenv('SHOPPING_MIN_AUTOSYNC_INTERVAL', 5))
|
SHOPPING_MIN_AUTOSYNC_INTERVAL = int(os.getenv('SHOPPING_MIN_AUTOSYNC_INTERVAL', 5))
|
||||||
|
|||||||
Reference in New Issue
Block a user