Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Budget Stats generation & display #1712

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/assets/images/budgets/stats/gender.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ a {
background: $brand;
}

.uppercase {
text-transform: uppercase;
}

// 02. Header
// ----------

Expand Down
162 changes: 162 additions & 0 deletions app/assets/stylesheets/participation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// 06. Budget
// 07. Proposals successful
// 08. Polls
// 09. Budgets stats
//

// 01. Votes and supports
Expand Down Expand Up @@ -1620,3 +1621,164 @@
}
}
}

// 09. Budgets stats
// ----------------------

.budgets-stats {

.header {
background: $budget;

h1,
.back,
.icon-angle-left {
color: #fff;
}
}

.legend {
color: $text-medium;
margin-bottom: 0;
}

.title {
color: #000201;
font-size: rem-calc(40);
line-height: rem-calc(40);
text-transform: uppercase;

@include breakpoint(medium) {
font-size: rem-calc(60);
line-height: rem-calc(60);
}
}

h2 {
color: $brand;
}

.big-number-stat {
font-size: rem-calc(72);
font-weight: bold;
line-height: rem-calc(72);

&.budget {
color: $budget;
}
}

.progress {
background: none;
}

.progress-meter {
background: #00dae0;
height: $line-height / 2;

&.web {
background: #00ad51;
}

&.zero-ten {
background: #007dc3;
}

&.paper {
background: #ffdc08;
}
}

.progress-meter-text {
color: #000201;
font-weight: normal;
left: 0;
top: $line-height / 2;
transform: initial;
}

.label {

&.feasible {
background: #9cc56a;
}

&.unfeasible {
background: #e87461;
}

&.supports {
background: #d0cef6;
}

&.balloting {
background: #454372;
}
}

.border-left {
border-left: 1px solid $border;
}

.border-right {
border-right: 1px solid $border;
}

.table-width {

@include breakpoint(medium) {
width: rem-calc(200);
}
}
}

.stats-districts {

th {
text-transform: uppercase;
}

tr th {
border: 1px solid $border;
padding-left: 0;
padding-right: 0;
text-align: center;
}

.tiny {
font-size: rem-calc(11);
font-weight: normal;
}
}

@include breakpoint(medium down) {

.survey-districts thead {
font-size: rem-calc(12);

th {
width: 25%;
word-break: break-all;
}
}

.questions-table {

thead th {
font-size: rem-calc(13);
width: 20%;
word-break: break-all;
}

td {
font-size: rem-calc(13);
}
}
}

.age-groups {

th {
width: 20%;
}
}
23 changes: 23 additions & 0 deletions app/controllers/budgets/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Budgets
class StatsController < ApplicationController

before_action :load_budget
load_and_authorize_resource :budget

def show
authorize! :read_stats, @budget
@stats = load_stats
end

private

def load_stats
Budget::Stats.new(@budget).generate
end

def load_budget
@budget = Budget.find_by(slug: params[:id]) || Budget.find_by(id: params[:id])
end

end
end
1 change: 1 addition & 0 deletions app/models/abilities/everyone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def initialize(user)
can [:read], Budget::Group
can [:read, :print], Budget::Investment
can :read_results, Budget, phase: "finished"
can :read_stats, Budget, phase: ['reviewing_ballots', 'finished']
can :new, DirectMessage
can [:read, :debate, :draft_publication, :allegations, :result_publication], Legislation::Process, published: true
can [:read, :changes, :go_to_version], Legislation::DraftVersion
Expand Down
2 changes: 1 addition & 1 deletion app/models/budget/ballot/line.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Budget
class Ballot
class Line < ActiveRecord::Base
belongs_to :ballot
belongs_to :ballot, counter_cache: :ballot_lines_count
belongs_to :investment, counter_cache: :ballot_lines_count
belongs_to :heading
belongs_to :group
Expand Down
Loading