Configure shop app, admin sidebar, media routing, and Stripe dependencies
This commit is contained in:
commit
93d83a0d63
188 files changed
+9220
No files matched your search
@@ -0,0 +1,31 @@
|
||||
from .models import Page
|
||||
|
||||
|
||||
def reading_frames(chapter, pages):
|
||||
"""Group ordered uploads into stable reader turns without altering images."""
|
||||
frames = []
|
||||
pending = []
|
||||
|
||||
def flush():
|
||||
if pending:
|
||||
frames.append({'kind': 'pair' if len(pending) == 2 else 'single', 'pages': pending[:]})
|
||||
pending.clear()
|
||||
|
||||
if chapter.cover:
|
||||
frames.append({'kind': 'cover', 'pages': []})
|
||||
|
||||
for index, page in enumerate(pages):
|
||||
if index == 0 and not chapter.cover and chapter.first_upload_is_cover:
|
||||
frames.append({'kind': 'cover', 'pages': [page]})
|
||||
continue
|
||||
if page.layout in (Page.Layout.SINGLE, Page.Layout.SPREAD):
|
||||
flush()
|
||||
frames.append({'kind': page.layout, 'pages': [page]})
|
||||
continue
|
||||
if page.layout == Page.Layout.PAIR_START:
|
||||
flush()
|
||||
pending.append(page)
|
||||
if len(pending) == 2:
|
||||
flush()
|
||||
flush()
|
||||
return frames
|
||||
Reference in new issue
Block a user