Create appeals/pdf_appeal.py
Browse files- appeals/pdf_appeal.py +52 -0
appeals/pdf_appeal.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# appeals/pdf_appeal.py
|
| 2 |
+
|
| 3 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
| 4 |
+
from reportlab.lib.styles import getSampleStyleSheet
|
| 5 |
+
from reportlab.lib.pagesizes import LETTER
|
| 6 |
+
from datetime import date
|
| 7 |
+
|
| 8 |
+
def generate_appeal_text(
|
| 9 |
+
agency: str,
|
| 10 |
+
subject: str,
|
| 11 |
+
rationale: str
|
| 12 |
+
) -> str:
|
| 13 |
+
return f"""
|
| 14 |
+
FOIA APPEAL
|
| 15 |
+
|
| 16 |
+
Agency: {agency}
|
| 17 |
+
Date: {date.today().isoformat()}
|
| 18 |
+
|
| 19 |
+
This appeal concerns a Freedom of Information Act request regarding:
|
| 20 |
+
|
| 21 |
+
"{subject}"
|
| 22 |
+
|
| 23 |
+
Grounds for Appeal:
|
| 24 |
+
{rationale}
|
| 25 |
+
|
| 26 |
+
The requester respectfully seeks reconsideration under FOIA,
|
| 27 |
+
noting that similar records have previously been released and that
|
| 28 |
+
this appeal makes no claim regarding classified or undisclosed activity.
|
| 29 |
+
|
| 30 |
+
Sincerely,
|
| 31 |
+
Requester
|
| 32 |
+
""".strip()
|
| 33 |
+
|
| 34 |
+
def export_appeal_pdf(
|
| 35 |
+
agency: str,
|
| 36 |
+
subject: str,
|
| 37 |
+
rationale: str,
|
| 38 |
+
out_path: str = "/tmp/foia_appeal.pdf"
|
| 39 |
+
) -> str:
|
| 40 |
+
|
| 41 |
+
styles = getSampleStyleSheet()
|
| 42 |
+
doc = SimpleDocTemplate(out_path, pagesize=LETTER)
|
| 43 |
+
|
| 44 |
+
story = []
|
| 45 |
+
text = generate_appeal_text(agency, subject, rationale)
|
| 46 |
+
|
| 47 |
+
for para in text.split("\n\n"):
|
| 48 |
+
story.append(Paragraph(para.replace("\n", "<br/>"), styles["BodyText"]))
|
| 49 |
+
story.append(Spacer(1, 12))
|
| 50 |
+
|
| 51 |
+
doc.build(story)
|
| 52 |
+
return out_path
|