Added year switching
This commit is contained in:
@@ -10,7 +10,7 @@ class YearData(models.Model):
|
||||
])
|
||||
|
||||
@property
|
||||
def is_leap(self):
|
||||
def is_leap(self) -> bool:
|
||||
if self.number == 0:
|
||||
return False
|
||||
elif self.number % 400 == 0:
|
||||
@@ -21,7 +21,15 @@ class YearData(models.Model):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
@property
|
||||
def next_year(self):
|
||||
return YearData.objects.filter(number__gt=self.number).order_by('number').first()
|
||||
|
||||
@property
|
||||
def previous_year(self):
|
||||
return YearData.objects.filter(number__lt=self.number).order_by('number').last()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f'({self.number}, {self.is_leap})'
|
||||
|
||||
|
||||
@@ -35,7 +43,7 @@ class MonthData(models.Model):
|
||||
is_oneday = models.BooleanField('IsOneday')
|
||||
is_leap_month = models.BooleanField('IsLeapMonth')
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return f'({self.number}, {self.name}, {self.folkname}, {self.is_oneday}, {self.is_leap_month})'
|
||||
|
||||
|
||||
@@ -47,7 +55,7 @@ class CalendarData(models.Model):
|
||||
current_month = models.ForeignKey(MonthData, on_delete=models.CASCADE)
|
||||
current_year = models.ForeignKey(YearData, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return f'({self.current_day}, {self.current_month}, {self.current_year})'
|
||||
|
||||
|
||||
@@ -64,6 +72,6 @@ class Event(models.Model):
|
||||
is_suggested = models.BooleanField('IsSuggested')
|
||||
is_only_for_gm = models.BooleanField('IsOnlyForGm')
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
return f'({self.day}, {self.time}, {self.title})'
|
||||
|
||||
|
||||
@@ -5,6 +5,35 @@ div.calendarpage {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
a.previous_year,
|
||||
a.next_year {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 20px;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
a.previous_year:hover,
|
||||
a.next_year:hover {
|
||||
background: #00a0e0;
|
||||
margin-top: 1px;
|
||||
margin-bottom: 19px;
|
||||
}
|
||||
|
||||
a.previous_year:active,
|
||||
a.next_year:active {
|
||||
background: #0080c0;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 17px;
|
||||
}
|
||||
|
||||
a.previous_year {
|
||||
float: left;
|
||||
}
|
||||
|
||||
a.next_year {
|
||||
float: right;
|
||||
}
|
||||
|
||||
h2.year {
|
||||
text-align: center;
|
||||
padding-bottom: 10px;
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
<div class="calendarpage">
|
||||
{% if type == 'year' %}
|
||||
<h1 class="title">Календарь</h1>
|
||||
|
||||
{% if root == 'calendar' %}
|
||||
{% if year_data.previous_year %} <a draggable="false" class="button previous_year" href="{{year_data.previous_year.number}}">Предыдущий год ({{year_data.previous_year.number}}-й)</a> {% endif %}
|
||||
{% if year_data.next_year %} <a draggable="false" class="button next_year" href="{{year_data.next_year.number}}">Следующий год ({{year_data.next_year.number}}-й)</a> {% endif %}
|
||||
{% elif root == 'year' %}
|
||||
{% if year_data.previous_year %} <a draggable="false" class="button previous_year" href="../{{year_data.previous_year.number}}">Предыдущий год ({{year_data.previous_year.number}}-й)</a> {% endif %}
|
||||
{% if year_data.next_year %} <a draggable="false" class="button next_year" href="../{{year_data.next_year.number}}">Следующий год ({{year_data.next_year.number}}-й)</a> {% endif %}
|
||||
{% endif %}
|
||||
<h2 class="year">Год {{year_data.number}}-й</h2>
|
||||
|
||||
<div class="calendar">
|
||||
@@ -23,6 +31,7 @@
|
||||
</div>
|
||||
{% elif type == 'day' %}
|
||||
<h1 class="title">Календарь — События</h1>
|
||||
|
||||
<h2 class="year">Год {{year_data.number}}-й, {{month_data.name}}{% if not month_data.is_oneday %}, день {{day}}-й{% endif %}</h2>
|
||||
|
||||
<div class="calendar-events">
|
||||
|
||||
Reference in New Issue
Block a user