Port to new django version - not yet fully working

- location field makes problems
This commit is contained in:
Martin Bauer
2019-01-05 11:27:15 +01:00
parent 72a9642a8e
commit 663185fd40
168 changed files with 797 additions and 5967 deletions

View File

@@ -1,43 +1,34 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import render,redirect
from datetime import datetime
from models import Message
from django.shortcuts import render, redirect
from simpleforum.models import Message
def message_view( request ):
def message_view(request):
if request.method == 'POST':
if 'titel' in request.POST and 'text' in request.POST:
titel = request.POST.get('titel')
text = request.POST.get('text')
text = request.POST.get('text')
if len(titel) > 0 and len(text) > 0:
print "create"
Message.objects.create( titel = titel, text = text, author = request.user, creation_time = datetime.now() )
return redirect( message_view )
Message.objects.create(titel=titel, text=text, author=request.user, creation_time=datetime.now())
return redirect(message_view)
context = dict()
if request.method == 'GET':
if 'month' in request.GET and 'year' in request.GET:
year = int( request.GET['year'] )
month = int( request.GET['month'] )
until_date = datetime( year, month+1, 01 )
from_date = datetime( year, month , 01 )
year = int(request.GET['year'])
month = int(request.GET['month'])
until_date = datetime(year, month + 1, 1)
from_date = datetime(year, month, 1)
context['archiveMode'] = True
context['year'] = year
context['year'] = year
context['month'] = month
context['messages'] = Message.objects.filter( creation_time__lt=until_date ).filter( creation_time__gte=from_date).order_by('-creation_time')
context['messages'] = Message.objects.filter(creation_time__lt=until_date).filter(
creation_time__gte=from_date).order_by('-creation_time')
else:
context['messages'] = Message.objects.order_by('-creation_time')[:20]
context['messages'] = Message.objects.order_by('-creation_time')[:20]
context['archiveMode'] = False
return render ( request, 'simpleforum/simpleforum.html', context )
return render(request, 'simpleforum/simpleforum.html', context)