shopping list shortcut link
This commit is contained in:
BIN
cookbook/static/manifest/shopping-cart-192.png
Normal file
BIN
cookbook/static/manifest/shopping-cart-192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -35,10 +35,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Shopping",
|
"name": "Shopping",
|
||||||
"short_name": "Shopping List",
|
"short_name": "Shopping",
|
||||||
"description": "View your shopping lists",
|
"description": "View your shopping lists",
|
||||||
"url": "/list/shopping-list/",
|
"url": "/list/shopping-list/",
|
||||||
"icons": [{ "src": "/static/manifest/icon-192.png", "sizes": "192x192" }]
|
"icons": [{ "src": "/static/manifest/shopping-cart-192.png", "sizes": "192x192" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Latest Shopping List",
|
||||||
|
"short_name": "Shopping List",
|
||||||
|
"description": "View the latest shopping list",
|
||||||
|
"url": "/shopping/latest/",
|
||||||
|
"icons": [{ "src": "/static/manifest/shopping-cart-192.png", "sizes": "192x192" }]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,11 @@
|
|||||||
data: {
|
data: {
|
||||||
shopping_list_id: {% if shopping_list_id %}{{ shopping_list_id }}{% else %}null{% endif %},
|
shopping_list_id: {% if shopping_list_id %}{{ shopping_list_id }}{% else %}null{% endif %},
|
||||||
loading: true,
|
loading: true,
|
||||||
|
{% if edit %}
|
||||||
|
edit_mode: true,
|
||||||
|
{% else %}
|
||||||
edit_mode: false,
|
edit_mode: false,
|
||||||
|
{% endif %}
|
||||||
export_text_prefix: '', //TODO add userpreference
|
export_text_prefix: '', //TODO add userpreference
|
||||||
recipe_query: '',
|
recipe_query: '',
|
||||||
recipes: [],
|
recipes: [],
|
||||||
|
@ -48,6 +48,7 @@ urlpatterns = [
|
|||||||
path('plan/entry/<int:pk>', views.meal_plan_entry, name='view_plan_entry'),
|
path('plan/entry/<int:pk>', views.meal_plan_entry, name='view_plan_entry'),
|
||||||
path('shopping/', views.shopping_list, name='view_shopping'),
|
path('shopping/', views.shopping_list, name='view_shopping'),
|
||||||
path('shopping/<int:pk>', views.shopping_list, name='view_shopping'),
|
path('shopping/<int:pk>', views.shopping_list, name='view_shopping'),
|
||||||
|
path('shopping/latest', views.latest_shopping_list, name='view_shopping_latest'),
|
||||||
path('settings/', views.user_settings, name='view_settings'),
|
path('settings/', views.user_settings, name='view_settings'),
|
||||||
path('history/', views.history, name='view_history'),
|
path('history/', views.history, name='view_history'),
|
||||||
path('test/<int:pk>', views.test, name='view_test'),
|
path('test/<int:pk>', views.test, name='view_test'),
|
||||||
|
@ -25,7 +25,7 @@ from cookbook.forms import (CommentForm, Recipe, RecipeBookEntryForm, User,
|
|||||||
UserPreferenceForm)
|
UserPreferenceForm)
|
||||||
from cookbook.helper.permission_helper import group_required, share_link_valid, has_group_permission
|
from cookbook.helper.permission_helper import group_required, share_link_valid, has_group_permission
|
||||||
from cookbook.models import (Comment, CookLog, InviteLink, MealPlan,
|
from cookbook.models import (Comment, CookLog, InviteLink, MealPlan,
|
||||||
RecipeBook, RecipeBookEntry, ViewLog)
|
RecipeBook, RecipeBookEntry, ViewLog, ShoppingList)
|
||||||
from cookbook.tables import (CookLogTable, RecipeTable, RecipeTableSmall,
|
from cookbook.tables import (CookLogTable, RecipeTable, RecipeTableSmall,
|
||||||
ViewLogTable)
|
ViewLogTable)
|
||||||
from recipes.settings import DEMO
|
from recipes.settings import DEMO
|
||||||
@ -232,6 +232,16 @@ def meal_plan_entry(request, pk):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@group_required('user')
|
||||||
|
def latest_shopping_list(request):
|
||||||
|
sl = ShoppingList.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).filter(finished=False).order_by('-created_at').first()
|
||||||
|
|
||||||
|
if sl:
|
||||||
|
return HttpResponseRedirect(reverse('view_shopping', kwargs={'pk': sl.pk}) + '?edit=true')
|
||||||
|
else:
|
||||||
|
return HttpResponseRedirect(reverse('view_shopping') + '?edit=true')
|
||||||
|
|
||||||
|
|
||||||
@group_required('user')
|
@group_required('user')
|
||||||
def shopping_list(request, pk=None):
|
def shopping_list(request, pk=None):
|
||||||
raw_list = request.GET.getlist('r')
|
raw_list = request.GET.getlist('r')
|
||||||
@ -244,11 +254,9 @@ def shopping_list(request, pk=None):
|
|||||||
if recipe := Recipe.objects.filter(pk=int(rid)).first():
|
if recipe := Recipe.objects.filter(pk=int(rid)).first():
|
||||||
recipes.append({'recipe': recipe.id, 'multiplier': multiplier})
|
recipes.append({'recipe': recipe.id, 'multiplier': multiplier})
|
||||||
|
|
||||||
return render(
|
edit = True if 'edit' in request.GET and request.GET['edit'] == 'true' else False
|
||||||
request,
|
|
||||||
'shopping_list.html',
|
return render(request, 'shopping_list.html', {'shopping_list_id': pk, 'recipes': recipes, 'edit': edit})
|
||||||
{'shopping_list_id': pk, 'recipes': recipes}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@group_required('guest')
|
@group_required('guest')
|
||||||
|
Reference in New Issue
Block a user