Exemple #1
0
 def GET(self, what):
     if not r_safeproperty.match(what): raise web.notfound
     
     inp = web.input(point=None)
     points = db.select('district', what=what, order=what+' desc', where=what+' is not null')
     points = [x[what] for x in points.list()]
     
     web.header('Content-Type', 'image/png')
     return simplegraphs.sparkline(points, inp.point)
Exemple #2
0
 def GET(self, table, what):
     try:
         table = table_map[table]
     except KeyError:
         raise web.notfound
     if not r_safeproperty.match(what): raise web.notfound
     
     inp = web.input(point=None)
     points = db.select(table, what=what, order=what+' asc', where=what+' is not null')
     points = [x[what] for x in points.list()]
     
     web.header('Content-Type', 'image/png')
     return simplegraphs.sparkline(points, inp.point)
Exemple #3
0
    def GET(self, table, what):
        try:
            table = table_map[table]
        except KeyError:
            raise web.notfound()
        if not r_safeproperty.match(what): raise web.notfound()

        inp = web.input(point=None)
        points = db.select(table,
                           what=what,
                           order=what + ' asc',
                           where=what + ' is not null')
        points = [x[what] for x in points.list()]

        web.header('Content-Type', 'image/png')
        return simplegraphs.sparkline(points, inp.point)
Exemple #4
0
 def GET(self, img=None):
     i = web.input()
     frm, to = i.get('from', ''), i.get('to', '')
     if frm and to:
         contributions = db.query("""SELECT sum(amount) AS amount,
             p.firstname, p.lastname, p.id as polid,
             employer_stem as employer, date_part('year', sent) as year
             FROM contribution cn, committee cm, politician_fec_ids pfi, politician p 
             WHERE cn.recipient_id = cm.id AND cm.candidate_id = pfi.fec_id 
             AND pfi.politician_id = p.id AND cn.employer_stem = $frm AND p.id=$to 
             GROUP BY year, p.lastname, p.firstname, cn.employer_stem, p.id
             ORDER BY year""", vars=locals()).list()
         
         if img:
             points = [c.amount for c in contributions]
             web.header('Content-Type', 'image/png')
             return simplegraphs.sparkline(points, i.get('point', 0))
         return render.contributions(frm, to, contributions)
     else:
         raise web.notfound()
Exemple #5
0
    def GET(self, img=None):
        i = web.input()
        frm, to = i.get('from', ''), i.get('to', '')
        if frm and to:
            contributions = db.query("""SELECT sum(amount) AS amount,
                p.firstname, p.lastname, p.id as polid,
                employer_stem as employer, date_part('year', sent) as year
                FROM contribution cn, committee cm, politician_fec_ids pfi, politician p 
                WHERE cn.recipient_id = cm.id AND cm.candidate_id = pfi.fec_id 
                AND pfi.politician_id = p.id AND cn.employer_stem = $frm AND p.id=$to 
                GROUP BY year, p.lastname, p.firstname, cn.employer_stem, p.id
                ORDER BY year""",
                                     vars=locals()).list()

            if img:
                points = [c.amount for c in contributions]
                web.header('Content-Type', 'image/png')
                return simplegraphs.sparkline(points, i.get('point', 0))
            return render.contributions(frm, to, contributions)
        else:
            raise web.notfound()