Beispiel #1
0
    def person_main():
        assembly_id = int(request.args.get("assembly_id", current_assembly_id()))
        officials = (
            Person.query.order_by(desc(Person.id))
            .join(Candidacy)
            .filter(and_(Candidacy.assembly_id == assembly_id, Candidacy.is_elected == True))
        )

        return render_template("people.html", officials=officials, assembly_id=assembly_id)
Beispiel #2
0
    def party_main():
        assembly_id = int(request.args.get('assembly_id', current_assembly_id()))

        parties = Party.query.distinct(Party.id)\
                        .join(Candidacy)\
                        .filter(Candidacy.assembly_id==assembly_id)

        return render_template('parties.html',\
                                assembly_id=assembly_id,\
                                parties=parties)
Beispiel #3
0
    def legislator_of(cls, region_id):
        if not region_id:
            return None

        assembly_id = current_assembly_id()
        region = Region.query.filter_by(id=region_id).one()

        legislator = None
        while not legislator and region:
            try:
                legislator = region.candidates\
                                   .filter(Candidacy.assembly_id == assembly_id)\
                                   .filter_by(is_elected=True)\
                                   .one()
            except MultipleResultsFound as e:
                break
            except NoResultFound as e:
                region = region.parents.order_by(False)\
                                       .order_by(func.length(Region.id).desc())\
                                       .first()

        return legislator
Beispiel #4
0
 def bill_main():
     assembly_id = int(request.args.get('assembly_id', current_assembly_id()))
     bills = Bill.query.filter(Bill.assembly_id==assembly_id)\
                       .order_by(Bill.proposed_date.desc().nullslast())
     return render_template('bills.html',\
             assembly_id=assembly_id, bills=bills)