Amélioration du rendu mois
- Fix #144 (sans catégorie en doblon) - tri des catégories suivant position
This commit is contained in:
parent
4405cdfc98
commit
fe55c23b74
@ -73,15 +73,16 @@ class DayInCalendar:
|
||||
self._add_event_internal(event)
|
||||
|
||||
def _add_event_internal(self, event):
|
||||
from .models import Category
|
||||
|
||||
self.events.append(event)
|
||||
if event.category is None:
|
||||
if "" not in self.events_by_category:
|
||||
self.events_by_category[""] = []
|
||||
self.events_by_category[""].append(event)
|
||||
cat = Category.default_name
|
||||
else:
|
||||
if event.category.name not in self.events_by_category:
|
||||
self.events_by_category[event.category.name] = []
|
||||
self.events_by_category[event.category.name].append(event)
|
||||
cat = event.category.name
|
||||
if cat not in self.events_by_category:
|
||||
self.events_by_category[cat] = []
|
||||
self.events_by_category[cat].append(event)
|
||||
|
||||
def filter_events(self):
|
||||
self.events.sort(
|
||||
@ -90,6 +91,15 @@ class DayInCalendar:
|
||||
else e.start_time
|
||||
)
|
||||
|
||||
def events_by_category_ordered(self):
|
||||
from .models import Category
|
||||
cats = Category.objects.order_by('position')
|
||||
result = []
|
||||
for c in cats:
|
||||
if c.name in self.events_by_category:
|
||||
result.append((c.name, self.events_by_category[c.name]))
|
||||
return result
|
||||
|
||||
|
||||
class CalendarList:
|
||||
def __init__(self, firstdate, lastdate, filter=None, exact=False):
|
||||
|
@ -25,7 +25,7 @@
|
||||
{% if day.events %}
|
||||
{% if resume %}
|
||||
<ul>
|
||||
{% for category, events in day.events_by_category.items %}
|
||||
{% for category, events in day.events_by_category_ordered %}
|
||||
<li>{{ events.0.category | circle_cat }}
|
||||
<a href="{{ day.date | url_day }}?{{ filter.get_url|add_url_category:events.0.category }}" data-target="{{ daytag }}-category-{{ events.0.category.pk }}" onClick="toggleModal(event)">{{ events | length }} {{ category }}</a></li>
|
||||
<dialog id="{{ daytag }}-category-{{ events.0.category.pk }}">
|
||||
|
Loading…
Reference in New Issue
Block a user