Added highlighting of days with events
This commit is contained in:
@@ -15,19 +15,20 @@ h2.year {
|
|||||||
table.month, table.month th, table.month td {
|
table.month, table.month th, table.month td {
|
||||||
border: 1px solid white;
|
border: 1px solid white;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
padding: 5px;
|
|
||||||
background: gainsboro;
|
background: gainsboro;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.month th {
|
table.month th {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.month td {
|
table.month td {
|
||||||
text-align: right;
|
text-align: center;
|
||||||
|
padding: 5px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.month td.current {
|
table.month td.with_events {
|
||||||
background: dimgrey;
|
background: dimgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +40,16 @@ table.month th.subtitle {
|
|||||||
table.month a {
|
table.month a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: black;
|
color: black;
|
||||||
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.month td.current a {
|
a.current_day {
|
||||||
|
border-radius: 3px;
|
||||||
|
background: DeepSkyBlue;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.month td.with_events a {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,8 @@
|
|||||||
<h2 class="year">Год {{year_data.number}}-й</h2>
|
<h2 class="year">Год {{year_data.number}}-й</h2>
|
||||||
|
|
||||||
<div class="calendar">
|
<div class="calendar">
|
||||||
{% for month in month_data %}
|
{% for month in months %}
|
||||||
{% if not month.is_leap_month or year_data.is_leap %}
|
{% include 'faerun_calendar/month.html' with month=month %}
|
||||||
{% include 'faerun_calendar/month.html' with month=month calendar_data=calendar_data month_days=month_days events=events %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% elif type == 'day' %}
|
{% elif type == 'day' %}
|
||||||
@@ -57,6 +55,8 @@
|
|||||||
<p class="calendar-error">Неверный месяц</p>
|
<p class="calendar-error">Неверный месяц</p>
|
||||||
{% elif error_type == 'day' %}
|
{% elif error_type == 'day' %}
|
||||||
<p class="calendar-error">Неверный день</p>
|
<p class="calendar-error">Неверный день</p>
|
||||||
|
{% elif error_type == 'unknown' %}
|
||||||
|
<p class="calendar-error">Неизвестная ошибка</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -14,23 +14,32 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not month.is_oneday %}
|
{% if not month.is_oneday %}
|
||||||
{% for day in month_days %}
|
{% for day in month.days %}
|
||||||
{% if forloop.counter0|divisibleby:10 %}
|
{% if forloop.counter0|divisibleby:10 %}
|
||||||
<tr>
|
<tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if day == calendar_data.current_day and year_data == calendar_data.current_year and month == calendar_data.current_month %}
|
{% if day.event_counts %}
|
||||||
<td class="current">
|
<td class="with_events">
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>
|
<td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if day.number == calendar_data.current_day and month.id == calendar_data.current_month.id and year_data.id == calendar_data.current_year.id %}
|
||||||
{% if root == 'calendar' %}
|
{% if root == 'calendar' %}
|
||||||
<a href="{{year_data.number}}/{{month.number}}/{{day}}">{{day}}</a>
|
<a class="current_day" href="{{year_data.number}}/{{month.number}}/{{day.number}}">{{day.number}}</a>
|
||||||
{% elif root == 'year' %}
|
{% elif root == 'year' %}
|
||||||
<a href="{{month.number}}/{{day}}">{{day}}</a>
|
<a class="current_day" href="{{month.number}}/{{day.number}}">{{day.number}}</a>
|
||||||
{% elif root == 'month' %}
|
{% elif root == 'month' %}
|
||||||
<a href="{{day}}">{{day}}</a>
|
<a class="current_day" href="{{day.number}}">{{day.number}}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% if root == 'calendar' %}
|
||||||
|
<a href="{{year_data.number}}/{{month.number}}/{{day.number}}">{{day.number}}</a>
|
||||||
|
{% elif root == 'year' %}
|
||||||
|
<a href="{{month.number}}/{{day.number}}">{{day.number}}</a>
|
||||||
|
{% elif root == 'month' %}
|
||||||
|
<a href="{{day.number}}">{{day.number}}</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
+38
-12
@@ -93,19 +93,45 @@ def year_page(request, year: int, root: str = None):
|
|||||||
params = {'type': 'error', 'error_type': 'year'}
|
params = {'type': 'error', 'error_type': 'year'}
|
||||||
|
|
||||||
if not params:
|
if not params:
|
||||||
month_data = MonthData.objects.all().order_by('number')
|
try:
|
||||||
calendar_data = CalendarData.objects.first()
|
month_data = MonthData.objects.all().order_by('number')
|
||||||
events = Event.objects.all()
|
calendar_data = CalendarData.objects.first()
|
||||||
|
|
||||||
params = {
|
months = []
|
||||||
'type': 'year',
|
for month in month_data:
|
||||||
'root': root,
|
is_oneday_month = getattr(month, 'is_oneday')
|
||||||
'calendar_data': calendar_data,
|
is_leap_month = getattr(month, 'is_leap_month')
|
||||||
'year_data': year_data,
|
is_leap_year = getattr(year_data, 'is_leap')
|
||||||
'month_data': month_data,
|
|
||||||
'month_days': tuple(i+1 for i in range(30)),
|
if is_leap_month and not is_leap_year:
|
||||||
'events': events,
|
continue
|
||||||
}
|
m = {
|
||||||
|
'id': getattr(month, 'id'),
|
||||||
|
'number': getattr(month, 'number'),
|
||||||
|
'name': getattr(month, 'name'),
|
||||||
|
'folkname': getattr(month, 'folkname'),
|
||||||
|
'is_oneday': getattr(month, 'is_oneday'),
|
||||||
|
'days': []
|
||||||
|
}
|
||||||
|
for i in range(0, 1 if is_oneday_month else 30):
|
||||||
|
day = {
|
||||||
|
'number': i+1,
|
||||||
|
'event_counts': Event.objects.filter(year=year_data.id, month=month.id, day=i+1,
|
||||||
|
is_suggested=False, is_only_for_gm=False).count()
|
||||||
|
}
|
||||||
|
m['days'].append(day)
|
||||||
|
|
||||||
|
months.append(m)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'type': 'year',
|
||||||
|
'root': root,
|
||||||
|
'calendar_data': calendar_data,
|
||||||
|
'year_data': year_data,
|
||||||
|
'months': months,
|
||||||
|
}
|
||||||
|
except AttributeError:
|
||||||
|
params = {'type': 'error', 'error_type': 'unknown'}
|
||||||
|
|
||||||
return render(request, 'faerun_calendar/index.html', params)
|
return render(request, 'faerun_calendar/index.html', params)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user