django-project/stadlbauer/views.py

44 lines
1.4 KiB
Python

"""
Barn Web App - A collection of web-apps for my family's personal use,
including a recipe database.
Copyright © 2023 Benjamin Stadlbauer
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
General Public License for more details.
This program comes with a copy of the GNU Affero General Public License
file at the root of this project.
"""
from .forms import SignupForm
from django.shortcuts import render
from django.urls import reverse
from django.http.response import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
def new_user(request):
if request.method == 'POST':
form = SignupForm(request.POST)
if form.is_valid():
form.save(commit=True)
return HttpResponseRedirect(reverse('login'))
else:
form = SignupForm()
return render(request, 'registration/new-user.html', {'form': form})
@login_required
def profile(request):
return render(request, 'registration/profile.html')
def index(request):
return render(request, 'index.html')