Events are now sorted by time. Added is_suggested and is_only_for_gm for events
This commit is contained in:
@@ -61,6 +61,8 @@ class Event(models.Model):
|
||||
time = models.TimeField('Time')
|
||||
title = models.CharField('Title', max_length=250)
|
||||
description = models.TextField('Description', max_length=2500)
|
||||
is_suggested = models.BooleanField('IsSuggested')
|
||||
is_only_for_gm = models.BooleanField('IsOnlyForGm')
|
||||
|
||||
def __str__(self):
|
||||
return f'({self.day}, {self.time}, {self.title})'
|
||||
|
||||
@@ -42,7 +42,9 @@ table.month td.current a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.calendar {
|
||||
div.calendar,
|
||||
div.calendar-events,
|
||||
div.calendar-error {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
justify-content: space-around;
|
||||
@@ -54,7 +56,9 @@ table.month {
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
div.event {
|
||||
div.event,
|
||||
div.event-gm,
|
||||
div.event-suggested {
|
||||
border: 1px solid black;
|
||||
padding: 20px;
|
||||
margin: 20px;
|
||||
@@ -62,6 +66,18 @@ div.event {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.event {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
div.event-gm {
|
||||
border: 2px solid BlueViolet;
|
||||
}
|
||||
|
||||
div.event-suggested {
|
||||
border: 2px solid crimson;
|
||||
}
|
||||
|
||||
div.event-time {
|
||||
border: 1px solid black;
|
||||
border-radius: 3px;
|
||||
@@ -86,7 +102,7 @@ p.event-description {
|
||||
}
|
||||
|
||||
p.calendar-error {
|
||||
color: Crimson;
|
||||
color: crimson;
|
||||
font-size: 200%;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,33 +15,42 @@
|
||||
{% if type == 'year' %}
|
||||
<h1 class="title">Календарь</h1>
|
||||
<h2 class="year">{{year_data.number}}</h2>
|
||||
{% elif type == 'day' %}
|
||||
<h1 class="title">Календарь — События</h1>
|
||||
<h2 class="year">Год {{year_data.number}}, {{month_data.name}}, день {{day}}-й</h2>
|
||||
{% elif type == 'error' %}
|
||||
<h1 class="title">Календарь — Ошибка</h1>
|
||||
{% endif %}
|
||||
|
||||
<div class="calendar">
|
||||
{% if type == 'year' %}
|
||||
{% 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 %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif type == 'day' %}
|
||||
<h1 class="title">Календарь — События</h1>
|
||||
<h2 class="year">Год {{year_data.number}}, {{month_data.name}}, день {{day}}-й</h2>
|
||||
|
||||
<div class="calendar-events">
|
||||
{% if events.count == 0 %}
|
||||
<p class="calendar-info">Событий нет</p>
|
||||
{% else %}
|
||||
{% for event in events %}
|
||||
{% if event.is_suggested %}
|
||||
<div class="event-suggested">
|
||||
{% elif event.is_only_for_gm %}
|
||||
<div class="event-gm">
|
||||
{% else %}
|
||||
<div class="event">
|
||||
{% endif %}
|
||||
|
||||
<div class="event-time">{{event.time}}</div>
|
||||
<div class="event-title">{{event.title}}</div>
|
||||
<p class="event-description">{{event.description}}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% elif type == 'error' %}
|
||||
<h1 class="title">Календарь — Ошибка</h1>
|
||||
|
||||
<div class="calendar-error">
|
||||
{% if error_type == 'year' %}
|
||||
<p class="calendar-error">Неверный год</p>
|
||||
{% elif error_type == 'month' %}
|
||||
@@ -49,7 +58,7 @@
|
||||
{% elif error_type == 'day' %}
|
||||
<p class="calendar-error">Неверный день</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponseNotFound
|
||||
|
||||
from .models import YearData
|
||||
@@ -11,6 +10,9 @@ from .models import Event
|
||||
def day_page(request, year: int, month: int, day: int):
|
||||
params = None
|
||||
|
||||
select_suggested = False
|
||||
select_only_for_gm = False
|
||||
|
||||
if not params:
|
||||
try:
|
||||
year_data = YearData.objects.get(number=year)
|
||||
@@ -35,12 +37,6 @@ def day_page(request, year: int, month: int, day: int):
|
||||
except AttributeError:
|
||||
params = {'type': 'error', 'error_type': 'month'}
|
||||
|
||||
if not params:
|
||||
try:
|
||||
events = Event.objects.filter(year=year_id, month=month_id, day=day)
|
||||
except Event.DoesNotExist:
|
||||
params = {'type': 'error', 'error_type': 'events'}
|
||||
|
||||
if not params:
|
||||
try:
|
||||
is_leap = getattr(year_data, 'is_leap')
|
||||
@@ -55,6 +51,14 @@ def day_page(request, year: int, month: int, day: int):
|
||||
if not is_leap and is_leap_month:
|
||||
params = {'type': 'error', 'error_type': 'month'}
|
||||
|
||||
if not params:
|
||||
try:
|
||||
events = Event.objects.filter(year=year_id, month=month_id, day=day,
|
||||
is_suggested=select_suggested, is_only_for_gm=select_only_for_gm
|
||||
).order_by('time')
|
||||
except Event.DoesNotExist:
|
||||
params = {'type': 'error', 'error_type': 'events'}
|
||||
|
||||
if not params:
|
||||
try:
|
||||
is_oneday = getattr(month_data, 'is_oneday')
|
||||
|
||||
Reference in New Issue
Block a user