[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
|
||||
page_start: 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"}
|
||||
|
||||
|
||||
@ -312,7 +312,8 @@ def manual_scrobble_book(
|
||||
|
||||
if action == "stop":
|
||||
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.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}
|
||||
|
||||
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>
|
||||
{% for s in scrobbles %}
|
||||
{% 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 %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user