mirror of https://github.com/snachodog/mybuddy.git
Alternative implementation for item ordering
This commit is contained in:
parent
847125b1c6
commit
d34814260f
|
@ -17,52 +17,48 @@
|
||||||
</h3>
|
</h3>
|
||||||
{% if timeline_objects %}
|
{% if timeline_objects %}
|
||||||
<ul class="timeline m-auto">
|
<ul class="timeline m-auto">
|
||||||
{% regroup timeline_objects by time as timeline_moments %}
|
{% for object in timeline_objects %}
|
||||||
|
<li{% cycle "" ' class="timeline-inverted"' %}>
|
||||||
{% for moment_objects in timeline_moments %}
|
<div class="timeline-badge {% if object.type == "start" %}bg-success{% elif object.type == "end" %}bg-danger{% else %}bg-info{% endif %}">
|
||||||
{% for object in moment_objects.list|dictsort:"type" %}
|
<i class="icon-{{ object.model_name }}"></i>
|
||||||
<li{% cycle "" ' class="timeline-inverted"' %}>
|
</div>
|
||||||
<div class="timeline-badge {% if object.type == "start" %}bg-success{% elif object.type == "end" %}bg-danger{% else %}bg-info{% endif %}">
|
<div class="card text-right">
|
||||||
<i class="icon-{{ object.model_name }}"></i>
|
<div class="card-body">
|
||||||
|
{{ object.event }}
|
||||||
|
{% for detail in object.details %}
|
||||||
|
<div><small>{{ detail }}</small></div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="card text-right">
|
<div class="card-footer text-muted">
|
||||||
<div class="card-body">
|
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %}
|
||||||
{{ object.event }}
|
{{ since }} ago ({{ time }})
|
||||||
{% for detail in object.details %}
|
{% endblocktrans %}
|
||||||
<div><small>{{ detail }}</small></div>
|
{% if object.duration %}
|
||||||
{% endfor %}
|
<div>
|
||||||
</div>
|
<small>
|
||||||
<div class="card-footer text-muted">
|
{% blocktrans trimmed with duration=object.duration %}
|
||||||
{% blocktrans trimmed with since=object.time|timesince time=object.time|time %}
|
Duration: {{ duration }}
|
||||||
{{ since }} ago ({{ time }})
|
{% endblocktrans %}
|
||||||
{% endblocktrans %}
|
</small>
|
||||||
{% if object.duration %}
|
</div>
|
||||||
<div>
|
{% endif %}
|
||||||
<small>
|
{% if object.time_since_prev %}
|
||||||
{% blocktrans trimmed with duration=object.duration %}
|
<div>
|
||||||
Duration: {{ duration }}
|
<small>
|
||||||
{% endblocktrans %}
|
{% blocktrans trimmed with since=object.time_since_prev %}
|
||||||
</small>
|
{{ since }} since previous
|
||||||
</div>
|
{% endblocktrans %}
|
||||||
{% endif %}
|
</small>
|
||||||
{% if object.time_since_prev %}
|
</div>
|
||||||
<div>
|
{% endif %}
|
||||||
<small>
|
{% if object.edit_link %}
|
||||||
{% blocktrans trimmed with since=object.time_since_prev %}
|
<div>
|
||||||
{{ since }} since previous
|
<small><a href="{{ object.edit_link }}">{% trans "Edit" %}</a></small>
|
||||||
{% endblocktrans %}
|
</div>
|
||||||
</small>
|
{% endif %}
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if object.edit_link %}
|
|
||||||
<div>
|
|
||||||
<small><a href="{{ object.edit_link }}">{% trans "Edit" %}</a></small>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
{% endfor %}
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<h3 class="text-center">
|
<h3 class="text-center">
|
||||||
|
|
|
@ -24,7 +24,11 @@ def get_objects(date, child=None):
|
||||||
_add_tummy_times(min_date, max_date, events, child)
|
_add_tummy_times(min_date, max_date, events, child)
|
||||||
_add_notes(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
|
return events
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue