Add basic timeline view (WIP)

This commit is contained in:
Christopher C. Wells 2021-08-21 20:42:29 -07:00 committed by Christopher Charbonneau Wells
parent 39393dcc1b
commit 0990678325
4 changed files with 41 additions and 6 deletions

View File

@ -10,9 +10,8 @@
<div class="d-lg-none d-md-none d-flex ml-auto p-0 mr-2">
<div>
<!-- TODO: Actually link to the timeline... but for which child? -->
<a class="text-success"
href="#"
href="{% url 'core:timeline' %}"
aria-expanded="false"><i class="icon icon-2x icon-timeline" aria-hidden="true"></i>
</a>
&nbsp;
@ -97,9 +96,8 @@
</a>
</li>
<li class="nav-item{% if request.path == '/' %} active{% endif %}">
<!-- TODO: Actually link to the timeline... but for which child? -->
<a class="nav-link" href="{% url 'dashboard:dashboard' %}">
<li class="nav-item{% if request.path == '/timeline' %} active{% endif %}">
<a class="nav-link" href="{% url 'core:timeline' %}">
<i class="icon icon-timeline" aria-hidden="true"></i>
{% trans "Timeline" %}
</a>

View File

@ -0,0 +1,12 @@
{% extends 'babybuddy/page.html' %}
{% load cards i18n static thumbnail %}
{% block title %}{% trans "Timeline" %}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item font-weight-bold">{% trans "Timeline" %}</li>
{% endblock %}
{% block content %}
{# TODO! #}
{% endblock %}

View File

@ -20,6 +20,8 @@ urlpatterns = [
name='child-delete'
),
path('timeline/', views.Timeline.as_view(), name='timeline'),
path(
'changes/',
views.DiaperChangeList.as_view(),

View File

@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.forms import Form
from django.http import HttpResponseRedirect
from django.urls import reverse, reverse_lazy
from django.utils import timezone
from django.utils.translation import gettext as _
from django.views.generic.base import RedirectView
from django.views.generic.base import RedirectView, TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView, \
FormView
@ -266,6 +267,28 @@ class TemperatureDelete(CoreDeleteView):
success_url = reverse_lazy('core:temperature-list')
class Timeline(LoginRequiredMixin, TemplateView):
template_name = 'timeline/timeline.html'
# Show the overall timeline or a child timeline if one Child instance.
def get(self, request, *args, **kwargs):
children = models.Child.objects.count()
if children == 1:
return HttpResponseRedirect(
reverse(
'core:child',
args={models.Child.objects.first().slug}
)
)
return super(Timeline, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(Timeline, self).get_context_data(**kwargs)
# TODO: Get relevant data for a given day.
context['objects'] = models.Child.objects.all()
return context
class TimerList(PermissionRequired403Mixin, BabyBuddyFilterView):
model = models.Timer
template_name = 'core/timer_list.html'