This commit is contained in:
2025-11-05 19:46:21 -08:00
parent 2b0b81abb8
commit a123d4e93b
10 changed files with 2137 additions and 29 deletions

77
app.py
View File

@@ -41,6 +41,33 @@ if not all([FV_CLIENT_ID, FV_CLIENT_SECRET, FV_PAT, FV_ORG_ID, FV_USER_ID]):
# --- Cache ---
from cache import project_cache
PHASES = {
209436: "Nonpayment File Review",
209437: "Attorney File Review",
209438: "Notice Preparation",
209439: "Notice Pending",
209440: "Notice Expired",
209442: "Preparing and Filing UD",
209443: "Waiting for Answer",
209444: "Archived",
210761: "Service of Process",
211435: "Default",
211436: "Pre-Answer Motion",
211437: "Request for Trial",
211438: "Trial Prep and Trial",
211439: "Writ and Sheriff",
211440: "Lockout Pending",
211441: "Stipulation Preparation",
211442: "Stipulation Pending",
211443: "Stipulation Expired",
211446: "On Hold",
211466: "Request for Monetary Judgment",
211467: "Appeals and Post-Poss. Motions",
211957: "Migrated",
213691: "Close Out/ Invoicing",
213774: "Judgment After Stip & Order",
}
# --- Helpers ---
def login_required(view):
@@ -97,13 +124,31 @@ def fetch_all_projects():
defendant_one = next((c.get('orgContact', {}) for c in cs if "Defendant" in c.get('orgContact', {}).get('personTypes', [])), {})
new_file_review = fetch_form(bearer, pid, "newFileReview") or {}
dates_and_deadlines = fetch_form(bearer, pid, "datesAndDeadlines") or {}
defendants = fetch_collection(bearer, pid, "defendants") or []
service_info = fetch_collection(bearer, pid, "serviceInfo") or []
property_info = fetch_form(bearer, pid, "propertyInfo")
project_overview = fetch_form(bearer, pid, "projectOverview")
matter_overview = fetch_form(bearer, pid, "matterOverview")
completed_tasks = [x.get("body") for x in fetch_project_tasks(bearer, pid).get("items") if x.get("isCompleted")]
pending_tasks = [x.get("body") for x in fetch_project_tasks(bearer, pid).get("items") if not x.get("isCompleted")]
row = {
"client": c.get("firstName"),
"matter_description": p.get("projectName"),
"defendant_1": defendant_one.get('fullName', 'Unknown'),
"matter_open": p.get("createdDate"),
"matter_open": dates_and_deadlines.get("dateCaseFiled") or p.get("createdDate"),
"notice_type": new_file_review.get("noticeType", '') or '',
"case_number": dates_and_deadlines.get('caseNumber', '') or '',
"premises_address": property_info.get("premisesAddressWithUnit") or '',
"premises_city": property_info.get("premisisCity") or '',
"client_email": "", # TODO
"responsible_attorney": matter_overview.get("signingAttorney"),
"staff_person": project_overview.get("teamLead"), # TODO
"staff_person_2": project_overview.get("teamLead"), # TODO
"phase_name": p.get("phaseName"),
"completed_tasks": completed_tasks,
"pending_tasks": pending_tasks,
"service_attempt_date_1": next(iter(service_info), {}).get('serviceDate'),
"contacts": cs,
"ProjectEmailAddress": p.get("projectEmailAddress"),
"Number": p.get("number"),
@@ -273,6 +318,19 @@ def fetch_project_detail(bearer: str, project_id_native: int):
r.raise_for_status()
return r.json()
def fetch_project_tasks(bearer: str, project_id_native: int):
url = f"https://api.filevineapp.com/fv-app/v2/Projects/{project_id_native}/tasks"
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {bearer}",
"x-fv-orgid": str(FV_ORG_ID),
"x-fv-userid": str(FV_USER_ID),
}
r = requests.get(url, headers=headers, timeout=30)
r.raise_for_status()
return r.json()
def fetch_client(bearer: str, client_id_native: int):
url = f"https://api.filevineapp.com/fv-app/v2/contacts/{client_id_native}"
headers = {
@@ -314,6 +372,23 @@ def fetch_form(bearer: str, project_id_native: int, form: str):
print(e)
return {}
def fetch_collection(bearer: str, project_id_native: int, collection: str):
try:
url = f"https://api.filevineapp.com/fv-app/v2/Projects/{project_id_native}/Collections/{collection}"
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {bearer}",
"x-fv-orgid": str(FV_ORG_ID),
"x-fv-userid": str(FV_USER_ID),
}
r = requests.get(url, headers=headers, timeout=30)
r.raise_for_status()
return [x.get('dataObject') for x in r.json().get("items")]
except Exception as e:
print(e)
return {}