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)
|
self._add_event_internal(event)
|
||||||
|
|
||||||
def _add_event_internal(self, event):
|
def _add_event_internal(self, event):
|
||||||
|
from .models import Category
|
||||||
|
|
||||||
self.events.append(event)
|
self.events.append(event)
|
||||||
if event.category is None:
|
if event.category is None:
|
||||||
if "" not in self.events_by_category:
|
cat = Category.default_name
|
||||||
self.events_by_category[""] = []
|
|
||||||
self.events_by_category[""].append(event)
|
|
||||||
else:
|
else:
|
||||||
if event.category.name not in self.events_by_category:
|
cat = event.category.name
|
||||||
self.events_by_category[event.category.name] = []
|
if cat not in self.events_by_category:
|
||||||
self.events_by_category[event.category.name].append(event)
|
self.events_by_category[cat] = []
|
||||||
|
self.events_by_category[cat].append(event)
|
||||||
|
|
||||||
def filter_events(self):
|
def filter_events(self):
|
||||||
self.events.sort(
|
self.events.sort(
|
||||||
@ -90,6 +91,15 @@ class DayInCalendar:
|
|||||||
else e.start_time
|
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:
|
class CalendarList:
|
||||||
def __init__(self, firstdate, lastdate, filter=None, exact=False):
|
def __init__(self, firstdate, lastdate, filter=None, exact=False):
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
{% if day.events %}
|
{% if day.events %}
|
||||||
{% if resume %}
|
{% if resume %}
|
||||||
<ul>
|
<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 }}
|
<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>
|
<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 }}">
|
<dialog id="{{ daytag }}-category-{{ events.0.category.pk }}">
|
||||||
|
Loading…
Reference in New Issue
Block a user