mirror of https://github.com/snachodog/mybuddy.git
Alternative implementation for item ordering
This commit is contained in:
parent
847125b1c6
commit
d34814260f
|
@ -17,10 +17,7 @@
|
|||
</h3>
|
||||
{% if timeline_objects %}
|
||||
<ul class="timeline m-auto">
|
||||
{% regroup timeline_objects by time as timeline_moments %}
|
||||
|
||||
{% for moment_objects in timeline_moments %}
|
||||
{% for object in moment_objects.list|dictsort:"type" %}
|
||||
{% for object in timeline_objects %}
|
||||
<li{% cycle "" ' class="timeline-inverted"' %}>
|
||||
<div class="timeline-badge {% if object.type == "start" %}bg-success{% elif object.type == "end" %}bg-danger{% else %}bg-info{% endif %}">
|
||||
<i class="icon-{{ object.model_name }}"></i>
|
||||
|
@ -63,7 +60,6 @@
|
|||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h3 class="text-center">
|
||||
{% if date_previous %}
|
||||
|
|
|
@ -24,7 +24,11 @@ def get_objects(date, child=None):
|
|||
_add_tummy_times(min_date, max_date, events, child)
|
||||
_add_notes(min_date, max_date, events, child)
|
||||
|
||||
events.sort(key=lambda x: x['time'], reverse=True)
|
||||
explicit_type_ordering = {'start': 0, 'end': 1}
|
||||
events.sort(
|
||||
key=lambda x: (x['time'], explicit_type_ordering.get(x.get('type'), -1)),
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
|
|
Loading…
Reference in New Issue