Verified Commit 682aa5cf authored by Jakob Moser's avatar Jakob Moser
Browse files

Implement getting person CSV

parent 16cca6c0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
from csv import DictWriter
from io import StringIO

from poolpay.model.Person import Person


def get_persons_csv() -> str:
    with StringIO() as f:
        writer = DictWriter(
            f, ["name", "cl_account_name", "balance_cents", "balance_str"]
        )
        writer.writeheader()
        writer.writerows(p.to_dict() for p in Person.get_all())

        return f.getvalue()