Added year switching
This commit is contained in:
@@ -10,7 +10,7 @@ class YearData(models.Model):
|
|||||||
])
|
])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_leap(self):
|
def is_leap(self) -> bool:
|
||||||
if self.number == 0:
|
if self.number == 0:
|
||||||
return False
|
return False
|
||||||
elif self.number % 400 == 0:
|
elif self.number % 400 == 0:
|
||||||
@@ -21,7 +21,15 @@ class YearData(models.Model):
|
|||||||
return True
|
return True
|
||||||
return False
|
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})'
|
return f'({self.number}, {self.is_leap})'
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +43,7 @@ class MonthData(models.Model):
|
|||||||
is_oneday = models.BooleanField('IsOneday')
|
is_oneday = models.BooleanField('IsOneday')
|
||||||
is_leap_month = models.BooleanField('IsLeapMonth')
|
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})'
|
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_month = models.ForeignKey(MonthData, on_delete=models.CASCADE)
|
||||||
current_year = models.ForeignKey(YearData, 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})'
|
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_suggested = models.BooleanField('IsSuggested')
|
||||||
is_only_for_gm = models.BooleanField('IsOnlyForGm')
|
is_only_for_gm = models.BooleanField('IsOnlyForGm')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f'({self.day}, {self.time}, {self.title})'
|
return f'({self.day}, {self.time}, {self.title})'
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,35 @@ div.calendarpage {
|
|||||||
border-radius: 20px;
|
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 {
|
h2.year {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
|
|||||||
@@ -14,6 +14,14 @@
|
|||||||
<div class="calendarpage">
|
<div class="calendarpage">
|
||||||
{% if type == 'year' %}
|
{% if type == 'year' %}
|
||||||
<h1 class="title">Календарь</h1>
|
<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>
|
<h2 class="year">Год {{year_data.number}}-й</h2>
|
||||||
|
|
||||||
<div class="calendar">
|
<div class="calendar">
|
||||||
@@ -23,6 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% elif type == 'day' %}
|
{% elif type == 'day' %}
|
||||||
<h1 class="title">Календарь — События</h1>
|
<h1 class="title">Календарь — События</h1>
|
||||||
|
|
||||||
<h2 class="year">Год {{year_data.number}}-й, {{month_data.name}}{% if not month_data.is_oneday %}, день {{day}}-й{% endif %}</h2>
|
<h2 class="year">Год {{year_data.number}}-й, {{month_data.name}}{% if not month_data.is_oneday %}, день {{day}}-й{% endif %}</h2>
|
||||||
|
|
||||||
<div class="calendar-events">
|
<div class="calendar-events">
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ div.menu {
|
|||||||
flex-flow: row wrap;
|
flex-flow: row wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside.menu a {
|
a.button {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
@@ -28,7 +28,6 @@ aside.menu a {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
|
|
||||||
max-width: 100px;
|
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -47,13 +46,13 @@ aside.menu a {
|
|||||||
supported by Chrome, Edge, Opera and Firefox */
|
supported by Chrome, Edge, Opera and Firefox */
|
||||||
}
|
}
|
||||||
|
|
||||||
aside.menu a:hover {
|
a.button:hover {
|
||||||
background: #00a0e0;
|
background: #00a0e0;
|
||||||
margin-top: 11px;
|
margin-top: 11px;
|
||||||
margin-bottom: 9px;
|
margin-bottom: 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside.menu a:active {
|
a.button:active {
|
||||||
background: #0080c0;
|
background: #0080c0;
|
||||||
margin-top: 13px;
|
margin-top: 13px;
|
||||||
margin-bottom: 7px;
|
margin-bottom: 7px;
|
||||||
|
|||||||
@@ -21,13 +21,13 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<aside class="menu">
|
<aside class="menu">
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a draggable="false" class="menuitem" href="/">
|
<a draggable="false" class="button menuitem" href="/">
|
||||||
Главная
|
Главная
|
||||||
</a>
|
</a>
|
||||||
<a draggable="false" class="menuitem" href="/calendar">
|
<a draggable="false" class="button menuitem" href="/calendar">
|
||||||
Календарь
|
Календарь
|
||||||
</a>
|
</a>
|
||||||
<a draggable="false" class="menuitem" href="/links">
|
<a draggable="false" class="button menuitem" href="/links">
|
||||||
Полезные ссылки
|
Полезные ссылки
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user