diff --git a/PROJECT.org b/PROJECT.org index a229ca2..14c3793 100644 --- a/PROJECT.org +++ b/PROJECT.org @@ -594,6 +594,7 @@ named constants for maintainability. - ~vrobbler/apps/webpages/models.py~ (line 290) -- ="url"= - ~vrobbler/apps/scrobbles/importers/tsv.py~ (line 55) -- ="S"= completion status +** TODO [#C] Show time per scrobble in long play lists and total time playing :templates:longplay:scrobbles: ** DONE [#B] Allow marking media as long play complete from detail page :templates:scrobbles:longplay: :PROPERTIES: :ID: 2c314768-be97-9b10-d13c-9cfd0f38a64e diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 71c28d0..d61d2ac 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -909,6 +909,28 @@ def scrobble_longplay_finish(request, uuid): if not user.is_authenticated: return HttpResponseRedirect(success_url) + # Try scrobble UUID first + scrobble = Scrobble.objects.filter(uuid=uuid, user=user).first() + if scrobble: + if scrobble.long_play_complete == True: + scrobble.long_play_complete = None + scrobble.save(update_fields=["long_play_complete"]) + messages.add_message( + request, + messages.INFO, + f"Long play of {scrobble.media_obj} marked as not complete.", + ) + else: + scrobble.long_play_complete = True + scrobble.save(update_fields=["long_play_complete"]) + messages.add_message( + request, + messages.SUCCESS, + f"Long play of {scrobble.media_obj} finished.", + ) + return HttpResponseRedirect(success_url) + + # Fall back to media UUID (existing behavior) media_obj = None for app, model in LONG_PLAY_MEDIA.items(): media_model = apps.get_model(app_label=app, model_name=model) @@ -917,10 +939,21 @@ def scrobble_longplay_finish(request, uuid): break if not media_obj: - return + messages.add_message( + request, messages.ERROR, f"Media with uuid {uuid} not found." + ) + return HttpResponseRedirect(success_url) last_scrobble = media_obj.last_long_play_scrobble_for_user(user) - if last_scrobble and last_scrobble.long_play_complete == False: + if last_scrobble and last_scrobble.long_play_complete == True: + last_scrobble.long_play_complete = None + last_scrobble.save(update_fields=["long_play_complete"]) + messages.add_message( + request, + messages.INFO, + f"Long play of {media_obj} marked as not complete.", + ) + elif last_scrobble: last_scrobble.long_play_complete = True last_scrobble.save(update_fields=["long_play_complete"]) messages.add_message( @@ -928,12 +961,6 @@ def scrobble_longplay_finish(request, uuid): messages.SUCCESS, f"Long play of {media_obj} finished.", ) - elif last_scrobble and last_scrobble.long_play_complete == True: - messages.add_message( - request, - messages.INFO, - f"Long play of {media_obj} was already completed.", - ) else: messages.add_message( request, messages.ERROR, f"Media with uuid {uuid} not found." diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html index e725321..8bbe953 100644 --- a/vrobbler/templates/books/book_detail.html +++ b/vrobbler/templates/books/book_detail.html @@ -36,7 +36,6 @@
{{scrobbles.count}} scrobbles
- {% if charts %}{{scrobbles.count}} scrobbles
-{{scrobbles.count}} scrobbles
{{scrobbles.count}} scrobbles