Added events on day page
This commit is contained in:
@@ -9,7 +9,40 @@ from .models import Event
|
||||
|
||||
|
||||
def day_page(request, year: int, month: int, day: int):
|
||||
return HttpResponse(f'{year}.{month}.{day}')
|
||||
try:
|
||||
year_data = YearData.objects.get(number=year)
|
||||
except YearData.DoesNotExist:
|
||||
return HttpResponseNotFound('<h1>404 Not Found</h1>')
|
||||
|
||||
try:
|
||||
year_id = getattr(year_data, 'id')
|
||||
except AttributeError:
|
||||
return HttpResponseNotFound('<h1>404 Not Found</h1>')
|
||||
|
||||
try:
|
||||
month_data = MonthData.objects.get(number=month)
|
||||
except MonthData.DoesNotExist:
|
||||
return HttpResponseNotFound('<h1>404 Not Found</h1>')
|
||||
|
||||
try:
|
||||
month_id = getattr(month_data, 'id')
|
||||
except AttributeError:
|
||||
return HttpResponseNotFound('<h1>404 Not Found</h1>')
|
||||
|
||||
try:
|
||||
events = Event.objects.filter(year=year_id, month=month_id, day=day)
|
||||
except Event.DoesNotExist:
|
||||
return HttpResponseNotFound(f'<h1>404 Not Found</h1>')
|
||||
|
||||
params = {
|
||||
'type': 'day',
|
||||
'year_data': year_data,
|
||||
'month_data': month_data,
|
||||
'day': day,
|
||||
'events': events,
|
||||
}
|
||||
|
||||
return render(request, 'faerun_calendar/index.html', params)
|
||||
|
||||
|
||||
def year_page(request, year: int):
|
||||
@@ -23,6 +56,7 @@ def year_page(request, year: int):
|
||||
events = Event.objects.all()
|
||||
|
||||
params = {
|
||||
'type': 'year',
|
||||
'calendar_data': calendar_data,
|
||||
'year_data': year_data,
|
||||
'month_data': month_data,
|
||||
@@ -34,8 +68,6 @@ def year_page(request, year: int):
|
||||
|
||||
|
||||
def index(request):
|
||||
calendar_data = CalendarData.objects.first()
|
||||
|
||||
try:
|
||||
current_year = getattr(getattr(CalendarData.objects.first(), 'current_year'), 'number')
|
||||
except AttributeError:
|
||||
|
||||
Reference in New Issue
Block a user