[books] Set restart and resume urls on comic book scrobbles
This commit is contained in:
@ -62,7 +62,8 @@ class BookLogData(BaseLogData, LongPlayLogData):
|
|||||||
pages_read: Optional[int] = None
|
pages_read: Optional[int] = None
|
||||||
page_start: Optional[int] = None
|
page_start: Optional[int] = None
|
||||||
page_end: Optional[int] = None
|
page_end: Optional[int] = None
|
||||||
bookmark_url: Optional[str] = None
|
resume_url: Optional[str] = None
|
||||||
|
restart_url: Optional[str] = None
|
||||||
|
|
||||||
_excluded_fields = {"koreader_hash", "page_data"}
|
_excluded_fields = {"koreader_hash", "page_data"}
|
||||||
|
|
||||||
|
|||||||
@ -312,7 +312,8 @@ def manual_scrobble_book(
|
|||||||
|
|
||||||
if action == "stop":
|
if action == "stop":
|
||||||
if url:
|
if url:
|
||||||
scrobble.log["bookmark_url"] = url
|
scrobble.log["resume_url"] = url
|
||||||
|
scrobble.log["restart_url"] = remove_last_part(url)
|
||||||
scrobble.save(update_fields=["log"])
|
scrobble.save(update_fields=["log"])
|
||||||
scrobble.stop(force_finish=True)
|
scrobble.stop(force_finish=True)
|
||||||
|
|
||||||
|
|||||||
@ -408,3 +408,9 @@ def get_daily_calorie_dict_for_user(user_id: int) -> dict[date, int]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {entry["day"]: entry["total_calories"] for entry in qs}
|
return {entry["day"]: entry["total_calories"] for entry in qs}
|
||||||
|
|
||||||
|
def remove_last_part(url: str) -> str:
|
||||||
|
url = url.rstrip('/')
|
||||||
|
if '/' not in url:
|
||||||
|
return url
|
||||||
|
return url.rsplit('/', 1)[0]
|
||||||
|
|||||||
@ -29,7 +29,8 @@
|
|||||||
<p>{{scrobbles.count}} scrobbles</p>
|
<p>{{scrobbles.count}} scrobbles</p>
|
||||||
{% for s in scrobbles %}
|
{% for s in scrobbles %}
|
||||||
{% if forloop.first %}
|
{% if forloop.first %}
|
||||||
<p><a href="{{s.logdata.bookmark_url}}">Resume</a></p>
|
<p><a href="{{s.logdata.restart_url}}">Re-read</a></p>
|
||||||
|
<p><a href="{{s.logdata.resume_url}}">Resume</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user