shopping list shortcut link
This commit is contained in:
parent
175fca2b39
commit
103878e107
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",
|
||||
"short_name": "Shopping List",
|
||||
"short_name": "Shopping",
|
||||
"description": "View your shopping lists",
|
||||
"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: {
|
||||
shopping_list_id: {% if shopping_list_id %}{{ shopping_list_id }}{% else %}null{% endif %},
|
||||
loading: true,
|
||||
edit_mode: false,
|
||||
{% if edit %}
|
||||
edit_mode: true,
|
||||
{% else %}
|
||||
edit_mode: false,
|
||||
{% endif %}
|
||||
export_text_prefix: '', //TODO add userpreference
|
||||
recipe_query: '',
|
||||
recipes: [],
|
||||
|
@ -48,6 +48,7 @@ urlpatterns = [
|
||||
path('plan/entry/<int:pk>', views.meal_plan_entry, name='view_plan_entry'),
|
||||
path('shopping/', 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('history/', views.history, name='view_history'),
|
||||
path('test/<int:pk>', views.test, name='view_test'),
|
||||
|
@ -25,7 +25,7 @@ from cookbook.forms import (CommentForm, Recipe, RecipeBookEntryForm, User,
|
||||
UserPreferenceForm)
|
||||
from cookbook.helper.permission_helper import group_required, share_link_valid, has_group_permission
|
||||
from cookbook.models import (Comment, CookLog, InviteLink, MealPlan,
|
||||
RecipeBook, RecipeBookEntry, ViewLog)
|
||||
RecipeBook, RecipeBookEntry, ViewLog, ShoppingList)
|
||||
from cookbook.tables import (CookLogTable, RecipeTable, RecipeTableSmall,
|
||||
ViewLogTable)
|
||||
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')
|
||||
def shopping_list(request, pk=None):
|
||||
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():
|
||||
recipes.append({'recipe': recipe.id, 'multiplier': multiplier})
|
||||
|
||||
return render(
|
||||
request,
|
||||
'shopping_list.html',
|
||||
{'shopping_list_id': pk, 'recipes': recipes}
|
||||
)
|
||||
edit = True if 'edit' in request.GET and request.GET['edit'] == 'true' else False
|
||||
|
||||
return render(request, 'shopping_list.html', {'shopping_list_id': pk, 'recipes': recipes, 'edit': edit})
|
||||
|
||||
|
||||
@group_required('guest')
|
||||
|
Loading…
Reference in New Issue
Block a user