- Added a Makefile to easily run project scripts (fees, match, web, image) - Modified attendance.py to dynamically handle a variable number of header rows from the Google Sheet - Updated both attendance calculations and calculate_fees terminal output to show actual attendance counts (e.g., '750 CZK (3)') - Created a Flask web dashboard (app.py and templates/fees.html) to view member fees in an attractive, condensed, terminal-like UI - Bound the Flask server to port 5000 and added a routing alias from '/' to '/fees' - Configured Python virtual environment (.venv) creation directly into the Makefile to resolve global pip install errors on macOS Co-authored-by: Antigravity <antigravity@deepmind.com>
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import sys
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
from flask import Flask, render_template
|
|
|
|
# Add scripts directory to path to allow importing from it
|
|
scripts_dir = Path(__file__).parent / "scripts"
|
|
sys.path.append(str(scripts_dir))
|
|
|
|
from attendance import get_members_with_fees
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
# Redirect root to /fees for convenience while there are no other apps
|
|
return '<meta http-equiv="refresh" content="0; url=/fees" />'
|
|
|
|
@app.route("/fees")
|
|
def fees():
|
|
members, sorted_months = get_members_with_fees()
|
|
if not members:
|
|
return "No data."
|
|
|
|
# Filter to adults only for display
|
|
results = [(name, fees) for name, tier, fees in members if tier == "A"]
|
|
|
|
# Format month labels
|
|
month_labels = {
|
|
m: datetime.strptime(m, "%Y-%m").strftime("%b %Y") for m in sorted_months
|
|
}
|
|
|
|
monthly_totals = {m: 0 for m in sorted_months}
|
|
|
|
formatted_results = []
|
|
for name, month_fees in results:
|
|
row = {"name": name, "months": []}
|
|
for m in sorted_months:
|
|
fee, count = month_fees.get(m, (0, 0))
|
|
monthly_totals[m] += fee
|
|
cell = f"{fee} CZK ({count})" if count > 0 else "-"
|
|
row["months"].append(cell)
|
|
formatted_results.append(row)
|
|
|
|
return render_template(
|
|
"fees.html",
|
|
months=[month_labels[m] for m in sorted_months],
|
|
results=formatted_results,
|
|
totals=[f"{monthly_totals[m]} CZK" for m in sorted_months]
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
app.run(debug=True, port=5001)
|