25 lines
817 B
Python
25 lines
817 B
Python
|
import datetime
|
||
|
|
||
|
import django.utils.timezone
|
||
|
from django.shortcuts import render
|
||
|
|
||
|
from .models import Tobacco, TobaccoCategory, ClubhausEvent
|
||
|
|
||
|
|
||
|
# Create your views here.
|
||
|
def tobacco(request):
|
||
|
test_image = Tobacco.objects.first().picture
|
||
|
context = {'tobaccos': Tobacco.objects.all(), 'categories': TobaccoCategory.objects.all(), 'pic': test_image}
|
||
|
return render(request, 'homepage/index.html', context)
|
||
|
|
||
|
|
||
|
def events(request):
|
||
|
yesterday = django.utils.timezone.now() - datetime.timedelta(days=1)
|
||
|
next_events = ClubhausEvent.objects.filter(date__gte=yesterday).order_by('-date')
|
||
|
next_event = next_events[0] if next_events else None
|
||
|
return render(request, 'homepage/events.html', {'next_event': next_event})
|
||
|
|
||
|
|
||
|
def landing(request):
|
||
|
return render(request, 'homepage/landingpage.html', {})
|