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