GodsDevProject commited on
Commit
d9a6a5f
·
verified ·
1 Parent(s): bc517db

Create foia_requests.py

Browse files
Files changed (1) hide show
  1. foia_requests.py +22 -50
foia_requests.py CHANGED
@@ -1,52 +1,24 @@
1
- from typing import Dict, List
2
- import json
3
- import os
4
- import uuid
5
  from datetime import datetime
6
 
7
- FOIA_STORE = "data/foia_requests.json"
8
-
9
-
10
- def _load_requests() -> List[Dict]:
11
- if not os.path.exists(FOIA_STORE):
12
- return []
13
- try:
14
- with open(FOIA_STORE, "r", encoding="utf-8") as f:
15
- return json.load(f)
16
- except Exception:
17
- return []
18
-
19
-
20
- def _save_requests(requests: List[Dict]) -> None:
21
- os.makedirs(os.path.dirname(FOIA_STORE), exist_ok=True)
22
- with open(FOIA_STORE, "w", encoding="utf-8") as f:
23
- json.dump(requests, f, indent=2)
24
-
25
-
26
- def add_foia_request(
27
- agency: str,
28
- subject: str,
29
- description: str,
30
- requester_type: str = "Journalist"
31
- ) -> Dict:
32
- """
33
- Store a FOIA request record (tracking only).
34
- No submission to agencies is performed.
35
- """
36
-
37
- record = {
38
- "id": str(uuid.uuid4()),
39
- "timestamp": datetime.utcnow().isoformat() + "Z",
40
- "agency": agency,
41
- "subject": subject,
42
- "description": description,
43
- "requester_type": requester_type,
44
- "status": "Draft",
45
- "notes": "Generated by FOIA Declassified Document Search (tracking only)"
46
- }
47
-
48
- requests = _load_requests()
49
- requests.append(record)
50
- _save_requests(requests)
51
-
52
- return record
 
 
 
 
 
1
  from datetime import datetime
2
 
3
+ def generate_foia_request_text(agency, subject, requester):
4
+ return f"""
5
+ Freedom of Information Act Request
6
+
7
+ Date: {datetime.utcnow().strftime('%B %d, %Y')}
8
+
9
+ To: {agency} FOIA Office
10
+
11
+ Pursuant to the Freedom of Information Act, I request access to records
12
+ concerning the following subject:
13
+
14
+ {subject}
15
+
16
+ I request a waiver of fees as this request is made in the public interest.
17
+ Please provide records electronically where possible.
18
+
19
+ Requester:
20
+ {requester}
21
+
22
+ Sincerely,
23
+ {requester}
24
+ """.strip()