def voter_ballots()

in pysteve/lib/backends/sqlite.py [0:0]


    def voter_ballots(self, UID):
        """Find all elections (and ballots) this user has participated in"""

        # First, get all elections
        elections = {}

        res = [unpickle(x) for x in self.DB.db.fetch("elections", limit=None)]
        for election in res:
            # Mark election open or closed
            elections[election["id"]] = {"title": election["title"], "open": False if election["closed"] else True}

        # Then, get all ballots and note whether they still apply or not
        ballots = {}
        res = [pickle(x) for x in self.DB.db.fetch("voters", limit=100, uid=UID)]
        for ballot in res:
            ballots[ballot["election"]] = {"ballot": ballot["id"], "metadata": elections[ballot["election"]]}
        return ballots