added sharing to recipe books

This commit is contained in:
vabene1111
2020-05-02 14:15:56 +02:00
parent 64ee18c4d8
commit 349b9629f8
4 changed files with 25 additions and 4 deletions

View File

@ -4,6 +4,7 @@ from datetime import datetime, timedelta
from django.contrib import messages
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.forms import PasswordChangeForm
from django.db.models import Q
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.urls import reverse_lazy
@ -86,7 +87,7 @@ def recipe_view(request, pk):
def books(request):
book_list = []
books = RecipeBook.objects.filter(created_by=request.user).all()
books = RecipeBook.objects.filter(Q(created_by=request.user) | Q(shared=request.user)).all()
for b in books:
book_list.append({'book': b, 'recipes': RecipeBookEntry.objects.filter(book=b).all()})