Spaces:
Sleeping
Sleeping
| from typing import Dict, List | |
| import json | |
| import os | |
| import uuid | |
| from datetime import datetime | |
| FOIA_STORE = "data/foia_requests.json" | |
| def _load_requests() -> List[Dict]: | |
| if not os.path.exists(FOIA_STORE): | |
| return [] | |
| try: | |
| with open(FOIA_STORE, "r", encoding="utf-8") as f: | |
| return json.load(f) | |
| except Exception: | |
| return [] | |
| def _save_requests(requests: List[Dict]) -> None: | |
| os.makedirs(os.path.dirname(FOIA_STORE), exist_ok=True) | |
| with open(FOIA_STORE, "w", encoding="utf-8") as f: | |
| json.dump(requests, f, indent=2) | |
| def add_foia_request( | |
| agency: str, | |
| subject: str, | |
| description: str, | |
| requester_type: str = "Journalist" | |
| ) -> Dict: | |
| """ | |
| Store a FOIA request record (tracking only). | |
| No submission to agencies is performed. | |
| """ | |
| record = { | |
| "id": str(uuid.uuid4()), | |
| "timestamp": datetime.utcnow().isoformat() + "Z", | |
| "agency": agency, | |
| "subject": subject, | |
| "description": description, | |
| "requester_type": requester_type, | |
| "status": "Draft", | |
| "notes": "Generated by FOIA Declassified Document Search (tracking only)" | |
| } | |
| requests = _load_requests() | |
| requests.append(record) | |
| _save_requests(requests) | |
| return record |