add notes app
This commit is contained in:
parent
acb398be1c
commit
a29376b3c5
38 changed files with 1720 additions and 45 deletions
|
@ -13,6 +13,29 @@ def aviary_all(request):
|
|||
return render(request, "aviary/aviary_all.html", context)
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def aviary_create(request):
|
||||
"""Create a new aviary."""
|
||||
form = AviaryEditForm(request.POST or None)
|
||||
if request.method == "POST":
|
||||
if form.is_valid():
|
||||
aviary = form.save(commit=False)
|
||||
if request.user.is_authenticated:
|
||||
aviary.created_by = request.user
|
||||
aviary.save()
|
||||
|
||||
# Handle different save options
|
||||
if 'save_and_add' in request.POST:
|
||||
return redirect("aviary_create") # Redirect to create another
|
||||
elif 'save_and_continue' in request.POST:
|
||||
return redirect("aviary_single", id=aviary.id) # Redirect to edit the created aviary
|
||||
else:
|
||||
return redirect("aviary_all") # Default: go to list
|
||||
|
||||
context = {"form": form, "is_create": True}
|
||||
return render(request, "aviary/aviary_form.html", context)
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def aviary_single(request, id):
|
||||
aviary = Aviary.objects.get(id=id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue