mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-05 06:08:46 -05:00
add category context menu
This commit is contained in:
@@ -35,4 +35,3 @@ class CookbookConfig(AppConfig):
|
||||
# if DEBUG:
|
||||
# traceback.print_exc()
|
||||
# pass # dont break startup just because fix could not run, need to investigate cases when this happens
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from rest_framework.authtoken.models import Token
|
||||
from rest_framework.exceptions import AuthenticationFailed
|
||||
|
||||
from cookbook.views import views
|
||||
from recipes import settings
|
||||
|
||||
|
||||
class ScopeMiddleware:
|
||||
@@ -14,14 +15,15 @@ class ScopeMiddleware:
|
||||
def __call__(self, request):
|
||||
if request.user.is_authenticated:
|
||||
|
||||
if request.path.startswith('/admin/'):
|
||||
prefix = settings.JS_REVERSE_SCRIPT_PREFIX or ''
|
||||
if request.path.startswith(prefix + '/admin/'):
|
||||
with scopes_disabled():
|
||||
return self.get_response(request)
|
||||
|
||||
if request.path.startswith('/signup/') or request.path.startswith('/invite/'):
|
||||
if request.path.startswith(prefix + '/signup/') or request.path.startswith(prefix + '/invite/'):
|
||||
return self.get_response(request)
|
||||
|
||||
if request.path.startswith('/accounts/'):
|
||||
if request.path.startswith(prefix + '/accounts/'):
|
||||
return self.get_response(request)
|
||||
|
||||
with scopes_disabled():
|
||||
|
||||
@@ -17,8 +17,7 @@ def shopping_helper(qs, request):
|
||||
supermarket = request.query_params.get('supermarket', None)
|
||||
checked = request.query_params.get('checked', 'recent')
|
||||
user = request.user
|
||||
|
||||
supermarket_order = ['food__supermarket_category__name', 'food__name']
|
||||
supermarket_order = [F('food__supermarket_category__name').asc(nulls_first=True), 'food__name']
|
||||
|
||||
# TODO created either scheduled task or startup task to delete very old shopping list entries
|
||||
# TODO create user preference to define 'very old'
|
||||
|
||||
@@ -65,7 +65,6 @@ def test_related_mixed_space(request, recipe, u1_s2):
|
||||
reverse(RELATED_URL, args={recipe.id})).content)) == 0
|
||||
|
||||
|
||||
# TODO add tests for mealplan related when thats added
|
||||
# TODO if/when related recipes includes multiple levels (related recipes of related recipes) add the following tests
|
||||
# -- step recipes included in step recipes
|
||||
# -- step recipes included in food recipes
|
||||
|
||||
@@ -233,7 +233,6 @@ def test_shopping_recipe_mixed_authors(u1_s1, u2_s1):
|
||||
assert len(json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 0
|
||||
|
||||
|
||||
# TODO test adding recipe with ingredients that are not food
|
||||
@pytest.mark.parametrize("recipe", [{'steps__ingredients__header': 1}], indirect=['recipe'])
|
||||
def test_shopping_with_header_ingredient(u1_s1, recipe):
|
||||
# with scope(space=recipe.space):
|
||||
|
||||
@@ -689,8 +689,11 @@ class RecipeViewSet(viewsets.ModelViewSet):
|
||||
obj = self.get_object()
|
||||
if obj.get_space() != request.space:
|
||||
raise PermissionDenied(detail='You do not have the required permission to perform this action', code=403)
|
||||
qs = obj.get_related_recipes(levels=1) # TODO: make levels a user setting, included in request data?, keep solely in the backend?
|
||||
# mealplans= TODO get todays mealplans
|
||||
try:
|
||||
levels = int(request.query_params.get('levels', 1))
|
||||
except (ValueError, TypeError):
|
||||
levels = 1
|
||||
qs = obj.get_related_recipes(levels=levels) # TODO: make levels a user setting, included in request data?, keep solely in the backend?
|
||||
return Response(self.serializer_class(qs, many=True).data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user