Skip to content

Commit

Permalink
added in top ideas per agency
Browse files Browse the repository at this point in the history
  • Loading branch information
jessykate committed Feb 25, 2010
1 parent 16eed94 commit b278a70
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 5 deletions.
17 changes: 17 additions & 0 deletions dashboard.py
Expand Up @@ -25,6 +25,7 @@ def get(self):
# get the top ideas in each category across all agencies
kwargs['stats_by_agency'] = stats_by_agency
kwargs['all_ideas'] = all_ideas
kwargs['pie_charts'] = self.pie_charts(stats_by_agency.keys(), all_ideas)
kwargs['top_ideas_by_agency'] = top_ideas_by_agency
kwargs['top_ideas_by_category'] = self.top_ideas_by_category(top_ideas_by_agency)
kwargs['participation_chart'] = self.construct_participation_chart(stats_by_agency)
Expand Down Expand Up @@ -146,6 +147,22 @@ def least_comments(self, stats_by_agency):
return {'agency': agency, 'count':least_comments}


def pie_charts(self, agencies, all_ideas):
pie_urls = {}
for agency in agencies:
ideas = agency_ideas(all_ideas, agency)
categories = {}
for idea in ideas:
category = idea['category']
categories[category] = categories.get(category,0) + 1
# convert the counts to strings for use in the pie chart url
for category in categories.keys():
categories[category] = str(categories[category])

pie_url = '''http://chart.apis.google.com/chart?chs=200x80&chd=t:%s&chco=3e81ac&cht=p&chf=bg,s,E3EEF1& chl=%s''' % (','.join(categories.values()), '|'.join(categories.keys()))
pie_urls[agency] = pie_url
return pie_urls

def construct_participation_chart(self, stats_by_agency):

# get the agency names out into a list so we can be sure the
Expand Down
63 changes: 60 additions & 3 deletions static/style.css
Expand Up @@ -359,10 +359,8 @@ p.doing_great {

.agency_stat {
position: relative;
margin-left: 10px;
margin-right: 10px;
text-align: center;
width: 200px;
width: 150px;
float: left;
}

Expand All @@ -371,6 +369,7 @@ p.doing_great {
font-weight: bold;
text-align:center;
width: 200px;
height: 60px;
}

.agency_stat_name {
Expand Down Expand Up @@ -406,6 +405,7 @@ p.doing_great {
.idea_list {
text-align: justify;
padding-bottom: 50px;
width: 1000px;
}

.spacer {
Expand All @@ -430,3 +430,60 @@ a.agency_heading_active:hover {
padding-right: 5px;
font-size: 120%;
}

.agency_category {
width: 200px;
height: 300px;
float: left;
margin: 15px 50px 0px 0px;
padding-bottom: 20px;
}

.agency_category_title {
font-size: 170%;
width: 200px;
height: 30px;
margin: 5px;
font-weight: bold;
}

.agency_category_idea_title {
font-size: 120%;
width: 200px;
margin: 5px;
min-height: 40px;
}

.agency_category_author {
font-weight: bold;
width: 200px;
margin: 5px;
height: 15px;
}

.agency_category_idea_text {
width: 200px;
height: 100px;
margin: 5px 5px 10px 5px;
}

.agency_category_num {
font-size: 200%;
width: 80px;
text-align: center;
height: 30px;
margin: 5px 10px;
float: left;
}

.agency_category_num_title{
width: 80px;
text-align: center;
margin: 5px 10px;
float: left;
}

.agency_report_logo {
width:75px;
height: 75px;
}
58 changes: 57 additions & 1 deletion templates/agency_report.html
Expand Up @@ -13,8 +13,13 @@ <h1>Agency Reports</h1>
{% for agency, stats in stats_by_agency.iteritems() %}
<div>
<a name="{{agency}}"></a>

<div class="agency_stats">

<div class="agency_stat">
<img src="{{ get_logo(agency) }}" class="agency_report_logo">
</div>

<div class="agency_stat">
<div class="med_num">{{ stats["ideas"]}}</div>
<div class="agency_stat_name">Ideas</div>
Expand All @@ -35,9 +40,60 @@ <h1>Agency Reports</h1>
<div class="agency_stat_name">Idea Authors</div>
</div>

<div class="agency_stat">
<div class="pie_chart"><img src="{{ pie_charts[agency] }}"></div>
</div>
</div>


{% for category, idea_info in top_ideas_by_agency[agency].iteritems() %}
{% if idea_info['idea'] %}

<div class="agency_category">
<div class="agency_category_title">
{{ category.title() }}
</div>
<div class="agency_category_idea_title">
<a href="{{ idea_info['idea']['url'] }}" title="Click to visit this idea">
{{ idea_info['idea']['title'] }}
</a>
</div>
<div class="agency_category_author">
<a href="{{ idea_info['idea']['authorInfo']['url'] }}">
{{ idea_info['idea']['author'].title() }}
</a>
</div>
<div class="agency_category_idea_text">
{{ truncate(idea_info['idea']['text'], 35) }}
</div>
<div class="agency_category_num">
{{ idea_info['votes'] }}
</div>
<div class="agency_category_num">
{{ idea_info['comments'] }}
</div>
<div class="agency_category_num_title">
Votes
</div>
<div class="agency_category_num_title">
Comments
</div>
</div>

{% else %}
<div class="agency_category">
<div class="agency_category_title">
{{ category.title() }}
</div>

<p>Oh No! No Idea Here. </p>
</div>

{% end %}
{% end %}

<div class="idea_list">
<h2>Have Your Say on These Ideas</h2>
<h2>Check Out These Other Ideas...</h2>
{% for idea in agency_ideas(all_ideas, agency) %}

{% if idea['category'] == "innovation" %}
Expand Down
3 changes: 2 additions & 1 deletion templates/index.html
Expand Up @@ -69,7 +69,8 @@ <h3>If you use your voice, it will be here to stay. Get involved.</h3>
<h1>Top Ideas Across Government</h1>
</div>
{% for category, idea_info in top_ideas_by_category.iteritems() %}
<div class="category"> <!-- onclick="location.href='__ idea_link __';" style="cursor:pointer;" -->

<div class="category">
<div class="category_title">
{{ category.title() }}
</div>
Expand Down

0 comments on commit b278a70

Please sign in to comment.