Added data models and loading some information from DB

This commit is contained in:
2022-07-13 16:44:04 +03:00
parent ad87a47768
commit 890d50f230
9 changed files with 186 additions and 72 deletions
+26 -1
View File
@@ -1,6 +1,31 @@
from django.shortcuts import render
from .models import CalendarData
from .models import MonthData
def index(request):
return render(request, 'faerun_calendar/index.html')
def is_leap_year(year) -> bool:
if year == 0:
return False
elif year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
return False
calendar_data = CalendarData.objects.first()
month_data = MonthData.objects.all()
year = 1492
params = {
'calendar_data': calendar_data,
'month_data': month_data,
'month_days': tuple(i+1 for i in range(30)),
'year': year,
'is_leap_year': is_leap_year(year),
}
return render(request, 'faerun_calendar/index.html', params)