[scrobbles] Add a status page
This commit is contained in:
@ -85,6 +85,12 @@ class GeoLocation(ScrobblableMixin):
|
||||
)
|
||||
return location
|
||||
|
||||
@property
|
||||
def subtitle(self) -> str:
|
||||
if self.title:
|
||||
return f"{self.lat} x {self.lon}"
|
||||
return ""
|
||||
|
||||
def loc_diff(self, old_lat_lon: tuple) -> tuple:
|
||||
return (
|
||||
abs(Decimal(old_lat_lon[0]) - Decimal(self.lat)),
|
||||
|
||||
@ -4,6 +4,7 @@ from scrobbles import views
|
||||
app_name = "scrobbles"
|
||||
|
||||
urlpatterns = [
|
||||
path("status/", views.ScrobbleStatusView.as_view(), name="status"),
|
||||
path(
|
||||
"manual/lookup/",
|
||||
views.ManualScrobbleView.as_view(),
|
||||
|
||||
@ -725,3 +725,34 @@ class ChartRecordView(TemplateView):
|
||||
context_data["name"] = " ".join(["Top", media_type, "for", name])
|
||||
context_data["in_progress"] = in_progress
|
||||
return context_data
|
||||
|
||||
|
||||
class ScrobbleStatusView(LoginRequiredMixin, TemplateView):
|
||||
model = Scrobble
|
||||
template_name = "scrobbles/status.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
data = super().get_context_data(**kwargs)
|
||||
user_scrobble_qs = Scrobble.objects.filter().order_by("-timestamp")
|
||||
progress_plays = user_scrobble_qs.filter(
|
||||
in_progress=True, is_paused=False
|
||||
)
|
||||
|
||||
data["listening"] = progress_plays.filter(track__isnull=False).first()
|
||||
data["watching"] = progress_plays.filter(video__isnull=False).first()
|
||||
data["going"] = progress_plays.filter(
|
||||
geo_location__isnull=False
|
||||
).first()
|
||||
data["playing"] = progress_plays.filter(
|
||||
board_game__isnull=False
|
||||
).first()
|
||||
|
||||
long_plays = user_scrobble_qs.filter(
|
||||
long_play_complete=False, played_to_completion=True
|
||||
)
|
||||
data["reading"] = long_plays.filter(book__isnull=False).first()
|
||||
data["sessioning"] = long_plays.filter(
|
||||
video_game__isnull=False
|
||||
).first()
|
||||
|
||||
return data
|
||||
|
||||
@ -67,7 +67,7 @@ class WebPage(ScrobblableMixin):
|
||||
self.save(update_fields=["extract"])
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("webpages:webpage_detail", kwargs={"slug": self.uuid})
|
||||
return reverse("webpages:webpage-detail", kwargs={"slug": self.uuid})
|
||||
|
||||
@property
|
||||
def estimated_time_to_read_in_seconds(self):
|
||||
|
||||
@ -5,10 +5,10 @@ app_name = "webpages"
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path("webpage/", views.WebPageListView.as_view(), name="webpage_list"),
|
||||
path("webpage/", views.WebPageListView.as_view(), name="webpage-list"),
|
||||
path(
|
||||
"webpage/<slug:slug>/",
|
||||
views.WebPageDetailView.as_view(),
|
||||
name="webpage_detail",
|
||||
name="webpage-detail",
|
||||
),
|
||||
]
|
||||
|
||||
@ -258,10 +258,8 @@
|
||||
{% for scrobble in now_playing_list %}
|
||||
<div class="now-playing">
|
||||
{% if scrobble.media_obj.primary_image_url %}<div style="float:left;padding-right:10px;padding-bottom:10px;"><img src="{{scrobble.media_obj.primary_image_url}}" /></div>{% endif %}
|
||||
<span>
|
||||
<p><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></p>
|
||||
{% if scrobble.media_obj.subtitle %}<p><em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
</span>
|
||||
<p><small>{{scrobble.timestamp|naturaltime}} from {{scrobble.source}}</small></p>
|
||||
<div class="progress-bar" style="margin-right:5px;">
|
||||
<span class="progress-bar-fill" style="width: {{scrobble.percent_played}}%;"></span>
|
||||
|
||||
114
vrobbler/templates/scrobbles/status.html
Normal file
114
vrobbler/templates/scrobbles/status.html
Normal file
@ -0,0 +1,114 @@
|
||||
{% load static %}
|
||||
{% load humanize %}
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>Now Playing</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
<!-- Place favicon.ico in the root directory -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="now-playing">
|
||||
<h3>Listening</h3>
|
||||
<div class="titles">
|
||||
{% if listening %}
|
||||
<p><em>{{listening.media_type}}</em></p>
|
||||
<p><a href="{{listening.media_obj.get_absolute_url}}">{{listening.media_obj.title}}</a></p>
|
||||
{% if listening.media_obj.subtitle %}<p><em><a href="{{listening.media_obj.subtitle.get_absolute_url}}">{{listening.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
</div>
|
||||
<p><small>{{listening.timestamp|naturaltime}} from {{listening.source}}</small></p>
|
||||
<p>{{listening.percent_played}}% played</p>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nothing</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr />
|
||||
<div class="watching">
|
||||
<h3>Watching</h3>
|
||||
<div class="titles">
|
||||
{% if watching %}
|
||||
<p><em>{{watching.media_type}}</em></p>
|
||||
<p><a href="{{watching.media_obj.get_absolute_url}}">{{watching.media_obj.title}}</a></p>
|
||||
{% if watching.media_obj.subtitle %}<p><em><a href="{{watching.media_obj.subtitle.get_absolute_url}}">{{watching.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><small>{{watching.timestamp|naturaltime}} from {{watching.source}}</small></p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nothing</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr />
|
||||
<div class="going">
|
||||
<h3>Going</h3>
|
||||
<div class="titles">
|
||||
{% if going %}
|
||||
<p><em>{{going.media_type}}</em></p>
|
||||
<p><a href="{{going.media_obj.get_absolute_url}}">{{going.media_obj}}</a></p>
|
||||
{% if going.media_obj.subtitle %}<p><em><a href="{{going.media_obj.subtitle.get_absolute_url}}">{{going.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><small>{{going.timestamp|naturaltime}} from {{going.source}}</small></p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nowhere</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr />
|
||||
<div class="playing">
|
||||
<h3>Playing</h3>
|
||||
<div class="titles">
|
||||
{% if playing %}
|
||||
<p><em>{{playing.media_type}}</em></p>
|
||||
<p><a href="{{playing.media_obj.get_absolute_url}}">{{playing.media_obj}}</a></p>
|
||||
{% if playing.media_obj.subtitle %}<p><em><a href="{{playing.media_obj.subtitle.get_absolute_url}}">{{playing.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><small>{{playing.timestamp|naturaltime}} from {{playing.source}}</small></p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nothing</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr />
|
||||
<div class="reading">
|
||||
<h3>Reading</h3>
|
||||
<div class="titles">
|
||||
{% if reading %}
|
||||
<p><em>{{reading.media_type}}</em></p>
|
||||
<p><a href="{{reading.media_obj.get_absolute_url}}">{{reading.media_obj}}</a></p>
|
||||
{% if reading.media_obj.subtitle %}<p><em><a href="{{reading.media_obj.subtitle.get_absolute_url}}">{{reading.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><small>{{reading.timestamp|naturaltime}} from {{reading.source}}</small></p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nothing</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<hr />
|
||||
<div class="sessioning">
|
||||
<h3>Sessioning</h3>
|
||||
<div class="titles">
|
||||
{% if sessioning %}
|
||||
<p><em>{{sessioning.media_type}}</em></p>
|
||||
<p><a href="{{sessioning.media_obj.get_absolute_url}}">{{sessioning.media_obj}}</a></p>
|
||||
{% if sessioning.media_obj.subtitle %}<p><em><a href="{{sessioning.media_obj.subtitle.get_absolute_url}}">{{sessioning.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><small>{{sessioning.timestamp|naturaltime}} from {{sessioning.source}}</small></p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="titles">
|
||||
<p>Nothing</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user