[lifeevents] Add life events to index and templates
This commit is contained in:
@ -1,12 +1,10 @@
|
||||
from django.views import generic
|
||||
from scrobbles.views import ScrobbleableDetailView, ScrobbleableListView
|
||||
from lifeevents.models import LifeEvent
|
||||
|
||||
|
||||
class LifeEventListView(generic.ListView):
|
||||
class LifeEventListView(ScrobbleableListView):
|
||||
model = LifeEvent
|
||||
paginate_by = 20
|
||||
|
||||
|
||||
class LifeEventDetailView(generic.DetailView):
|
||||
class LifeEventDetailView(ScrobbleableDetailView):
|
||||
model = LifeEvent
|
||||
slug_field = "uuid"
|
||||
|
||||
@ -234,6 +234,11 @@ class RecentScrobbleList(ListView):
|
||||
data["daily_calories"] = get_daily_calories_for_user_by_day(
|
||||
self.request.user.id, date
|
||||
)
|
||||
data["life_events_in_progress"] = Scrobble.objects.filter(
|
||||
user=self.request.user,
|
||||
life_event__isnull=False,
|
||||
in_progress=True,
|
||||
).order_by("-timestamp")
|
||||
else:
|
||||
data["weekly_data"] = week_of_scrobbles()
|
||||
data["counts"] = scrobble_counts()
|
||||
|
||||
69
vrobbler/templates/lifeevents/lifeevent_detail.html
Normal file
69
vrobbler/templates/lifeevents/lifeevent_detail.html
Normal file
@ -0,0 +1,69 @@
|
||||
{% extends "base_list.html" %}
|
||||
|
||||
{% block title %}{{object.title}}{% endblock %}
|
||||
|
||||
{% block lists %}
|
||||
|
||||
<div class="row">
|
||||
<div class="summary">
|
||||
{% if object.description%}
|
||||
<p>{{object.description|safe|linebreaks|truncatewords:160}}</p>
|
||||
<hr />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p>{{scrobbles.count}} scrobbles</p>
|
||||
<p>
|
||||
<a href="{{object.start_url}}">Play again</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<h3>Last scrobbles</h3>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Date</th>
|
||||
<th scope="col">Title</th>
|
||||
<th scope="col">Notes</th>
|
||||
<th scope="col">Source</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for scrobble in scrobbles.all|dictsortreversed:"timestamp" %}
|
||||
<tr>
|
||||
<td><a href="{{scrobble.get_absolute_url}}">{{scrobble.local_timestamp}}</a></td>
|
||||
<td><a href="{{scrobble.get_media_source_url}}">{{scrobble.logdata.title}}</a></td>
|
||||
<td>{{scrobble.logdata.notes_as_str|safe}}</td>
|
||||
<td>{{scrobble.source}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if is_paginated %}
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?page={{ page_obj.previous_page_number }}">« Previous</a>
|
||||
{% endif %}
|
||||
|
||||
{% for num in page_obj.paginator.page_range %}
|
||||
{% if num == page_obj.number %}
|
||||
<strong>{{ num }}</strong>
|
||||
{% else %}
|
||||
<a href="?page={{ num }}">{{ num }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?page={{ page_obj.next_page_number }}">Next »</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
10
vrobbler/templates/lifeevents/lifeevent_list.html
Normal file
10
vrobbler/templates/lifeevents/lifeevent_list.html
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends "base_list.html" %}
|
||||
{% block title %}Life Events{% endblock %}
|
||||
|
||||
{% block lists %}
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="table-responsive">{% include "_scrobblable_list.html" %}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -25,6 +25,28 @@
|
||||
<p>No food today</p>
|
||||
{% endif %}
|
||||
|
||||
<h3><a href="{% url 'lifeevents:lifeevent_list' %}">Life Events</a></h3>
|
||||
{% if life_events_in_progress %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Started</th>
|
||||
<th scope="col">Title</th>
|
||||
<th scope="col">Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for scrobble in life_events_in_progress %}
|
||||
{% include "scrobbles/_row.html" %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>No life events in progress</p>
|
||||
{% endif %}
|
||||
|
||||
<h3><a href="{% url 'moods:mood_list' %}">Moods</a></h3>
|
||||
{% if Mood %}
|
||||
{% with scrobbles=Mood count=Mood_count time=Mood_time %}
|
||||
|
||||
Reference in New Issue
Block a user