|
@ -52,6 +52,8 @@ def make_cards(filepath, db_path, side_a, side_b): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_fields(fields, content, styles, book): |
|
|
def select_fields(fields, content, styles, book): |
|
|
|
|
|
appended = True |
|
|
|
|
|
|
|
|
if "title" in fields: |
|
|
if "title" in fields: |
|
|
tag = "<font size=12>{}</font>".format(strip_tags(book.title)) |
|
|
tag = "<font size=12>{}</font>".format(strip_tags(book.title)) |
|
|
ptitle = Paragraph(tag, styles["Italic"]) |
|
|
ptitle = Paragraph(tag, styles["Italic"]) |
|
@ -87,13 +89,14 @@ def select_fields(fields, content, styles, book): |
|
|
if "tags" in fields: |
|
|
if "tags" in fields: |
|
|
format_string = "<font size=10>{}</font>" |
|
|
format_string = "<font size=10>{}</font>" |
|
|
all_tags = [strip_tags(tag.name) for tag in book.tags] |
|
|
all_tags = [strip_tags(tag.name) for tag in book.tags] |
|
|
|
|
|
if not all_tags: |
|
|
|
|
|
appended = False |
|
|
tags_glued_together = format_string.format(", ".join(all_tags)) |
|
|
tags_glued_together = format_string.format(", ".join(all_tags)) |
|
|
|
|
|
|
|
|
p = Paragraph(tags_glued_together, styles["Normal"]) |
|
|
p = Paragraph(tags_glued_together, styles["Normal"]) |
|
|
content.append(p) |
|
|
content.append(p) |
|
|
content.append(Spacer(6, 12)) |
|
|
content.append(Spacer(6, 12)) |
|
|
|
|
|
|
|
|
return content |
|
|
return content, appended |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_fields(db_path, side_a, side_b): |
|
|
def get_fields(db_path, side_a, side_b): |
|
@ -103,9 +106,10 @@ def get_fields(db_path, side_a, side_b): |
|
|
session = init_session(db_path) |
|
|
session = init_session(db_path) |
|
|
|
|
|
|
|
|
for book in session.query(Book).all(): |
|
|
for book in session.query(Book).all(): |
|
|
content = select_fields(side_a, content, styles, book) |
|
|
content, _ = select_fields(side_a, content, styles, book) |
|
|
content.append(PageBreak()) |
|
|
content.append(PageBreak()) |
|
|
content = select_fields(side_b, content, styles, book) |
|
|
content, appended = select_fields(side_b, content, styles, book) |
|
|
|
|
|
if appended: |
|
|
content.append(PageBreak()) |
|
|
content.append(PageBreak()) |
|
|
|
|
|
|
|
|
return content |
|
|
return content |
|
|