Commit 31026430 authored by Hänzelmann, Antje's avatar Hänzelmann, Antje
Browse files

register/login authenticated

parent 4c223288
......@@ -7,6 +7,7 @@ from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from oos_2020_todo import settings
from todo.forms import *
......@@ -14,10 +15,11 @@ from todo.models import *
logger = logging.getLogger('views')
def register_page(request):
form = CreateUserForm()
if request.user.is_authenticated:
return redirect('landing_page')
else:
form = CreateUserForm()
if request.method == 'POST':
form = CreateUserForm(request.POST)
if form.is_valid():
......@@ -29,10 +31,13 @@ def register_page(request):
def login_page(request):
context = {}
return render(request, 'todo/login.html', context)
if request.user.is_authenticated:
return redirect('login')
else:
context = {}
return render(request, 'todo/login.html', context)
@login_required(login_url='login')
def get_landing_page(request):
# send_mail('Hello from Feierabend',
# 'Mail gesendet',
......@@ -55,7 +60,7 @@ def get_landing_page(request):
return render(request, 'todo/landing_page.html', content)
@login_required(login_url='login')
def todo_details(request, pk=None):
if pk:
todo = Todo.objects.get(pk=pk)
......@@ -82,7 +87,7 @@ def todo_details(request, pk=None):
return render(request, 'todo/add_todo.html', {'page_title': 'Lege eine neue Aufgabe an! ',
'form': form})
@login_required(login_url='login')
def delete_todo(request, pk=None, source='show_todo', s_id=None):
if pk:
Todo.objects.get(pk=pk).delete()
......@@ -91,7 +96,7 @@ def delete_todo(request, pk=None, source='show_todo', s_id=None):
else:
return HttpResponseRedirect(reverse_lazy(source))
@login_required(login_url='login')
def get_selection_page(request):
selection = Selection()
......@@ -130,7 +135,7 @@ def get_selection_page(request):
}
return render(request, 'todo/selection_page.html', content)
@login_required(login_url='login')
def get_selection_id(request, pk=None):
if request.method == 'POST':
form = CheckedTodosForm(request.POST)
......@@ -166,7 +171,7 @@ def get_selection_id(request, pk=None):
}
return render(request, 'todo/show_selection.html', content)
@login_required(login_url='login')
def sort_todos(todos_late, todos_someday, todos_soon, todos_today, select_id=None):
if select_id is None:
todos_with_recurrence = Todo.objects.filter(complete=False).exclude(recurrences__exact='')
......@@ -201,7 +206,7 @@ def get_impressum(request):
content = {'page_title': 'Impressum'}
return render(request, 'todo/impressum.html', content)
@login_required(login_url='login')
def get_show_todo(request):
if request.method == 'POST':
form = CheckedTodosForm(request.POST)
......@@ -237,7 +242,7 @@ def get_show_todo(request):
# content = {'page_title': 'to Dos anzeigen'}
return render(request, 'todo/show_todo.html', content)
@login_required(login_url='login')
def get_archiv(request):
content = {'page_title': 'Archiv'}
return render(request, 'todo/archiv.html', content)
......@@ -247,7 +252,7 @@ def get_login(request):
content = {'page_title': 'Log In'}
return render(request, 'todo/login.html', content)
login_required()
def get_register(request):
content = {'page_title': 'Register'}
return render(request, 'todo/register.html', content)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment