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

Resume reading

-

Finish long play

{% if charts %}
@@ -62,7 +61,7 @@ {% for scrobble in scrobbles.all|dictsortreversed:"timestamp" %} {{scrobble.local_timestamp}} - {% if scrobble.long_play_complete == True %}Yes{% else %}No{% endif %} + {% if scrobble.long_play_complete == True %}Yes (not complete?){% else %}No{% endif %} {% if scrobble.in_progress %}Now reading{% else %}{{scrobble.session_pages_read}}{% endif %} {% for author in scrobble.book.authors.all %}{{author}}{% if not forloop.last %}, {% endif %}{% endfor %} diff --git a/vrobbler/templates/bricksets/brickset_detail.html b/vrobbler/templates/bricksets/brickset_detail.html index 2bdb216..731d83c 100644 --- a/vrobbler/templates/bricksets/brickset_detail.html +++ b/vrobbler/templates/bricksets/brickset_detail.html @@ -27,7 +27,6 @@

{{scrobbles.count}} scrobbles

-

Finish long play

@@ -45,7 +44,7 @@ {% for scrobble in scrobbles.all|dictsortreversed:"timestamp" %} {{scrobble.local_timestamp}} - {% if scrobble.long_play_complete == True %}Yes{% else %}No{% endif %} + {% if scrobble.long_play_complete == True %}Yes (not complete?){% else %}No{% endif %} {% if scrobble.in_progress %}Now reading{% else %}{{scrobble.session_pages_read}}{% endif %} {% endfor %} diff --git a/vrobbler/templates/tasks/task_detail.html b/vrobbler/templates/tasks/task_detail.html index 8ea1c4f..7c50335 100644 --- a/vrobbler/templates/tasks/task_detail.html +++ b/vrobbler/templates/tasks/task_detail.html @@ -53,7 +53,6 @@

{{scrobbles.count}} scrobbles

Play again - Finish long play

@@ -68,6 +67,7 @@ Title Notes Source + Completed @@ -77,6 +77,7 @@ {{scrobble.logdata.title}} {{scrobble.logdata.notes_as_str}} {{scrobble.source}} + {% if scrobble.long_play_complete == True %}Yes (not complete?){% else %}No{% endif %} {% endfor %} diff --git a/vrobbler/templates/videogames/videogame_detail.html b/vrobbler/templates/videogames/videogame_detail.html index 6e7e4f3..d1f1cbe 100644 --- a/vrobbler/templates/videogames/videogame_detail.html +++ b/vrobbler/templates/videogames/videogame_detail.html @@ -62,7 +62,6 @@

{{scrobbles.count}} scrobbles

Play again - Finish long play

@@ -84,7 +83,7 @@ {{scrobble.local_timestamp}} - {% if scrobble.long_play_complete == True %}Yes{% else %}Not yet{% endif %} + {% if scrobble.long_play_complete == True %}Yes (not complete?){% else %}Not yet{% endif %} {% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position_seconds|natural_duration}}{% endif %} {% for platform in scrobble.video_game.platforms.all %}{{platform}}{% if not forloop.last %}, {% endif %}{% endfor %} {% if scrobble.videogame_save_data %}Save data{% else %}Not yet{% endif %}