def stats(): campaign = request.values.get('campaign', 'default') stats = aggregate_stats(campaign) reps = {} for (repId, count) in stats['calls']['reps'].items(): member = data.get_legislator_by_id(repId) if member: member['name'] = ("%(firstname)s %(lastname)s" % member).decode('utf-8') reps[repId] = member elif repId.startswith('S_'): #probably special, parse it from json s = json.loads(repId.split('S_')[1]) d = { 'office': s['o'], 'name': s['p'], 'number': s['n'], 'title': s['i'] } reps[repId] = d else: print "weird", repId reps[repId] = repId stats['calls']['total'] = stats['total'][0][0] return render_template('stats.html', stats=stats, reps=reps, updated=datetime.now().isoformat())
def stats(): password = request.values.get("password", None) campaign = request.values.get("campaign", "default") if password == app.config["SECRET_KEY"]: return jsonify(aggregate_stats(campaign)) else: return jsonify(error="access denied")
def stats(): password = request.values.get('password', None) campaign = request.values.get('campaign', 'default') if password == app.config['SECRET_KEY']: return jsonify(aggregate_stats(campaign)) else: return jsonify(error="access denied")
def stats(): campaign = request.values.get('campaign', 'default') stats = aggregate_stats(campaign) reps = {} for (repId, count) in stats['calls']['reps'].items(): member = data.get_legislator_by_id(repId) if member: member['name'] = ("%(firstname)s %(lastname)s" % member).decode('utf-8') reps[repId] = member elif repId.startswith('S_'): #probably special, parse it from json s = json.loads(repId.split('S_')[1]) d = {'office': s['o'], 'name': s['p'], 'number': s['n'], 'title': s['i']} reps[repId] = d else: print "weird", repId reps[repId] = repId stats['calls']['total'] = stats['total'][0][0] return render_template('stats.html', stats=stats, reps=reps, updated=datetime.now().isoformat())
def stats(): campaign = get_campaign(request.values.get('campaignId', 'default')) if session['openid']['email'] in valid_users.values: return jsonify(aggregate_stats(campaign['id'])) else: return jsonify(error="access denied")