aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-10-21 16:39:17 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-10-21 16:39:17 +0100
commit07c741c785761cfa0e9895e35ba7e1f1549ce676 (patch)
tree444cd6dee37ca0f8587e23365ddc44e00ec12595
parent4bd6e569fef7c9ebda8f63e5064ac90fcfe1c3e4 (diff)
started work on merging events sorted keyed on date for user profile page
-rw-r--r--ctrack/templates/users/user_detail.html6
-rw-r--r--ctrack/users/views.py12
2 files changed, 13 insertions, 5 deletions
diff --git a/ctrack/templates/users/user_detail.html b/ctrack/templates/users/user_detail.html
index f4f466f..5314f20 100644
--- a/ctrack/templates/users/user_detail.html
+++ b/ctrack/templates/users/user_detail.html
@@ -39,13 +39,15 @@
<table class="table table-bordered">
<thead>
<tr>
- <th class="w-25">Event</th>
+ <th class="w-25">Type</th>
+ <th>Event</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
- {% for event in single_date_events %}
+ {% for event in all_events %}
<tr>
+ <td>{{ event.type_descriptor }}</td>
<td>{{ event.short_description }}</td>
<td>{{ event.comments }}</td>
</tr>
diff --git a/ctrack/users/views.py b/ctrack/users/views.py
index 3ca574a..de3f4d1 100644
--- a/ctrack/users/views.py
+++ b/ctrack/users/views.py
@@ -1,3 +1,5 @@
+import itertools
+
from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
@@ -5,7 +7,7 @@ from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, RedirectView, UpdateView
-from ctrack.register.models import SingleDateTimeEvent
+from ctrack.register.models import SingleDateTimeEvent, CAFSingleDateEvent, CAFTwinDateEvent
User = get_user_model()
@@ -24,8 +26,12 @@ class UserDetailView(DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data()
user = self.request.user
- single_date_events = SingleDateTimeEvent.objects.filter(user=user).all()
- context["single_date_events"] = single_date_events
+ _single_date_events = SingleDateTimeEvent.objects.filter(user=user).all()
+ _caf_single_date_events = CAFSingleDateEvent.objects.all()
+ _caf_twin_date_events = CAFTwinDateEvent.objects.all()
+ _combined = list(itertools.chain(_caf_twin_date_events, _caf_single_date_events, _single_date_events))
+ all_events = sorted(_combined, key=lambda x: x.date, reverse=True)
+ context["all_events"] = all_events
return context