diff --git a/CONTRIBUTING_EN.md b/CONTRIBUTING_EN.md index 0c322d506..17f93bc63 100644 --- a/CONTRIBUTING_EN.md +++ b/CONTRIBUTING_EN.md @@ -34,6 +34,16 @@ If you want to contribute code to solve an issue: * Follow these [best practices](https://github.com/styleguide/ruby) * Open a *pull request* to the main repository describing what issue you are addressing. +## Cleaning up + +In the rush of time sometimes things get messy, you can help us cleaning things up: + +* implement [pending specs](https://travis-ci.org/consul/consul) +* increase [code coverage](https://coveralls.io/github/consul/consul?branch=master) +* improve [code quality](https://codeclimate.com/github/consul/consul) +* update [dependencies](https://gemnasium.com/consul/consul) +* make [code consistent](https://github.com/bbatsov/rubocop) + ## Other ways of contributing without coding * If you think there's a feature missing, or find a bug, create an issue (make sure it has not already been reported). diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md index 7a8d10877..aaee9ec92 100644 --- a/CONTRIBUTING_ES.md +++ b/CONTRIBUTING_ES.md @@ -34,6 +34,16 @@ Cuando quieras resolver una incidencia mediante código: * Sigue estas [buenas prácticas](https://github.com/styleguide/ruby) * Envía una *pull request* al repositorio principal indicando la incidencia que se está arreglando +## Limpiar + +En la urgencia del momento, las cosas a veces se ensucian, puedes ayudarnos a limpiar la casa: + +* implementando [tests pendientes](https://travis-ci.org/consul/consul) +* incrementando la [cobertura de tests](https://coveralls.io/github/consul/consul?branch=master) +* mejorando la [calidad del código](https://codeclimate.com/github/consul/consul) +* actualizando [dependecias](https://gemnasium.com/consul/consul) +* haciendo el [código consistente](https://github.com/bbatsov/rubocop) + ## Otras formas de contribuir sin código * Si crees que hay una funcionalidad que hace falta, o descubres un problema, abre una incidencia (asegúrate de que diff --git a/Gemfile b/Gemfile index 4559c4f57..6d7f660f3 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem 'whenever', require: false gem 'pg_search' gem 'ahoy_matey', '~> 1.4.2' -gem 'groupdate', '~> 3.1.0' # group temporary data +gem 'groupdate', '~> 3.1.0' # group temporary data gem 'tolk', '~> 2.0.0' # Web interface for translations gem 'browser' @@ -88,6 +88,7 @@ group :development, :test do gem 'capistrano3-delayed-job', '~> 1.0' gem "bullet" gem "faker" + gem 'rubocop', '~> 0.45.0', require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index b872cf8f5..9638fae74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,7 +59,7 @@ GEM ancestry (2.2.1) activerecord (>= 3.0.0) arel (6.0.3) - ast (2.2.0) + ast (2.3.0) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) @@ -274,7 +274,7 @@ GEM orm_adapter (0.5.0) paranoia (2.2.0) activerecord (>= 4.0, < 5.1) - parser (2.3.0.6) + parser (2.3.1.4) ast (~> 2.2) pg (0.19.0) pg_search (1.0.6) @@ -285,6 +285,7 @@ GEM capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) + powerpack (0.1.1) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.4) @@ -318,6 +319,7 @@ GEM activesupport (= 4.2.7.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (2.1.0) raindrops (0.16.0) rake (11.3.0) redcarpet (3.3.4) @@ -349,6 +351,12 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) + rubocop (0.45.0) + parser (>= 2.3.1.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) safe_yaml (1.0.4) safely_block (0.1.1) @@ -415,6 +423,7 @@ GEM thread_safe (~> 0.1) uglifier (3.0.3) execjs (>= 0.3.0, < 3) + unicode-display_width (1.1.1) unicorn (5.1.0) kgio (~> 2.6) raindrops (~> 0.7) @@ -499,6 +508,7 @@ DEPENDENCIES rinku (~> 2.0.2) rollbar (~> 2.13.3) rspec-rails (~> 3.5) + rubocop (~> 0.45.0) sass-rails (~> 5.0, >= 5.0.4) savon social-share-button diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7fb92b5e3..10339e995 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -45,6 +45,7 @@ //= require valuation_spending_proposal_form //= require embed_video //= require banners +//= require social_share //= require custom var initialize_modules = function() { @@ -66,6 +67,7 @@ var initialize_modules = function() { App.ValuationSpendingProposalForm.initialize(); App.EmbedVideo.initialize(); App.Banners.initialize(); + App.SocialShare.initialize(); }; $(function(){ diff --git a/app/assets/javascripts/social_share.js.coffee b/app/assets/javascripts/social_share.js.coffee new file mode 100644 index 000000000..a61f2d8f4 --- /dev/null +++ b/app/assets/javascripts/social_share.js.coffee @@ -0,0 +1,7 @@ +App.SocialShare = + + initialize: -> + $(".social-share-button a").each -> + element = $(this) + site = element.data('site') + element.append("#{site}") \ No newline at end of file diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss index 242a03b82..4149020fa 100644 --- a/app/assets/stylesheets/_settings.scss +++ b/app/assets/stylesheets/_settings.scss @@ -51,6 +51,7 @@ $base-font-size: rem-calc(17); $base-line: rem-calc(26); $small-font-size: rem-calc(14); $line-height: rem-calc(24); +$tiny-font-size: rem-calc(12); $brand: #004A83; $dark: darken($brand, 10%); @@ -66,7 +67,6 @@ $link-hover: darken($link, 20%); $debates: #008CCF; -$votes: #26AEEE; $like: #7BD2A8; $unlike: #EF8585; @@ -79,7 +79,7 @@ $budget: #454372; $budget-hover: #7571BF; $highlight: #E7F2FC; -$featured: #FED900; +$featured: #FFDC5C; $footer-border: #BFC1C3; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index c3dded973..6c6d739af 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -475,8 +475,16 @@ header { &.active { border-bottom: 2px solid $brand; color: $brand; + + &:hover { + text-decoration: none; + } } } + + h2 { + font-size: $base-font-size; + } } .search-form-header input[type=text] { @@ -1247,13 +1255,14 @@ table { } .share-supported { + text-align: center; .social-share-button { display: inline-block; } .ssb-twitter { - background: none; + background: #45B0E3; color: white; height: $line-height; position: relative; @@ -1276,7 +1285,7 @@ table { } .ssb-facebook { - background: none; + background: #3B5998; color: white; height: rem-calc(24); position: relative; @@ -1299,7 +1308,7 @@ table { } .ssb-google_plus { - background: none; + background: #DE4C34; color: white; height: rem-calc(24); position: relative; @@ -1550,7 +1559,7 @@ table { .comment-votes { color: $text-medium; - font-size: rem-calc(14); + font-size: $small-font-size; line-height: $line-height; a { @@ -1560,12 +1569,21 @@ table { &:hover { color: $text-medium; + text-decoration: none; + + .icon-like { + color: $like; + } + + .icon-unlike { + color: $unlike; + } } } [class^="icon-"] { - font-size: rem-calc(20); - vertical-align: middle; + font-size: $base-font-size; + vertical-align: sub; } } @@ -1685,7 +1703,8 @@ table { } .flag-disable, .flag-active { - vertical-align: middle; + line-height: 0; + vertical-align: sub; } .flag-disable { diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 1ab1eb726..6dbaac394 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -12,14 +12,21 @@ // ---------------------- @mixin votes { - background: $votes; - margin: 0 rem-calc(-12); - padding: rem-calc(14) rem-calc(12); + border-top: 1px solid $border; + margin-top: $line-height; + padding: $line-height 0; position: relative; + @include breakpoint(medium) { + border-left: 1px solid $border; + border-top: 0; + margin-top: 0; + padding-top: $line-height*2; + } + .icon-like, .icon-unlike { background: white; - border: 2px solid $votes; + border: 2px solid $text-light; border-radius: rem-calc(3); color: $text-light; display: inline-block; @@ -29,7 +36,6 @@ position: relative; &:hover, &:active { - border-color: white; color: white; cursor: pointer; opacity: 1 !important; @@ -40,6 +46,7 @@ &:hover, &:active { background: $like; + border: 2px solid $like; } } @@ -47,50 +54,64 @@ &:hover, &:active { background: $unlike; + border: 2px solid $unlike; } } .like, .unlike { line-height: rem-calc(48); vertical-align: super; + text-decoration: none; span.percentage { - color: white; + color: $text; display: inline-block; - font-size: rem-calc(16); + font-size: $small-font-size; line-height: $line-height*2; - padding-left: rem-calc(8); + padding-right: $line-height/2; vertical-align: top; + + @include breakpoint(medium) { + display: block; + line-height: $line-height; + padding-right: 0; + } } } .voted { .icon-like, .icon-unlike { - border-color: white; color: white; } .icon-like { background: $like; + border: 2px solid $like; } .icon-unlike { background: $unlike; + border: 2px solid $unlike; } } .no-voted { .icon-like, .icon-unlike { - opacity: .5; + opacity: .3; } } .total-votes { - color: white; + font-weight: bold; float: right; line-height: $line-height*2; + + @include breakpoint(medium) { + display: block; + float: none; + } } .divider { @@ -99,64 +120,65 @@ } @mixin supports { - background: $proposals; - margin: 0 rem-calc(-12); - padding: rem-calc(14) rem-calc(12); + padding: $line-height 0; position: relative; .progress { - background-color: rgba(255,255,255,.8); - height: $line-height/2; + background: lighten($proposals, 35%); + border: 1px solid lighten($proposals, 35%); + height: rem-calc(14); + position: relative; .meter { - background: $like; + background: $proposals; + border-radius: 0; + border-bottom-right-radius: rem-calc(3); + border-top-right-radius: rem-calc(3); display: block; height: $line-height/2; } } .percentage { - font-size: rem-calc(10); - color: $brand; - vertical-align: top; + color: $text; + font-size: $tiny-font-size; position: absolute; - top: 13px; - right: 20px; + right: 6px; + top: -2px; + vertical-align: top; } abbr { - color: white; + color: $text-medium; &[title] { - border-bottom: 1px dotted white; + border-bottom: 1px dotted $text-medium; } } .button-support { - background: white; + background: $proposals; color: $text; display: inline-block; font-size: $small-font-size; margin-top: rem-calc(12); - &:hover { - background: darken($proposals, 35%); - color: white; + &:hover, &:active { + background: lighten($proposals, 25%); cursor: pointer; } - - &:active { - opacity: .75; - } } .total-supports { - color: white; + color: $text; + display: block; + font-weight: bold; text-align: center; - font-size: $small-font-size; span { display: block; + font-size: $small-font-size; + font-weight: normal; } } @@ -165,23 +187,17 @@ } .supported { - color: white; + color: $text; margin-top: rem-calc(12); } } -.message { - @include supports; - background: none; - border-top: 0; +.supports-container { + border-top: 1px solid $border; @include breakpoint(medium) { border-left: 1px solid $border; - margin: $line-height rem-calc(-25) 0 rem-calc(12); - } - - p { - font-size: $small-font-size; + border-top: 0; } } @@ -276,7 +292,9 @@ // 03. Show participation // ---------------------- -.debate-show, .proposal-show, .investment-project-show { +.debate-show, +.proposal-show, +.investment-project-show { p { word-wrap: break-word; @@ -413,47 +431,8 @@ } } - .votes { - @include votes; - border: 0; - border-radius: 0; - margin: 0; - - .total-votes { - display: block; - float: none; - line-height: $line-height; - } - - @include breakpoint(small + rem-calc(1) and medium down) { - .in-favor, .against { - text-align: left; - width: rem-calc(100); - } - } - - .divider { - display: none; - } - - @include breakpoint(medium) { - .divider { - display: inline-block; - } - } - } - .supports { @include supports; - border: 0; - border-radius: 0; - margin: 0; - - .total-supports { - display: block; - float: none; - line-height: $line-height; - } } .leave-comment { @@ -478,6 +457,17 @@ word-break: break-word; } +.proposal-show, .investment-project-show { + + .supports { + padding: $line-height/2 0 0; + } + + .share-supported { + display: none; + } +} + // 04. List participation // ---------------------- @@ -496,8 +486,7 @@ } .debate, .proposal, .investment-project { - margin-bottom: 0; - margin-top: 0; + margin: $line-height/4 0; .panel { background: white; @@ -651,107 +640,30 @@ } } -.debate { +.debate, .debate-show { .votes { @include votes; - border: 1px solid $votes; - margin: 0 rem-calc(-12); - @include breakpoint(medium) { - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - margin: 0 rem-calc(-25) 0 rem-calc(12); - } - - &:after { - content: none; - position: absolute; - display: block; - border-style: solid; - border-color: #166387 transparent transparent transparent; - bottom: -14px; - border-left-width: 0; - border-right-color: transparent; - right: -1px; - border-width: 13px 13px 0 0; - - @include breakpoint(medium) { - content: ""; - } - } - - .total-votes { - display: inline-block; - line-height: $line-height; - margin-left: rem-calc(24); - padding-top: rem-calc(12); - vertical-align: top; - - @include breakpoint(medium) { - display: block; - float: none; - line-height: $line-height*2; - margin-left: 0; - padding-top: 0; - } + .against { + margin-left: $line-height/4; } @include breakpoint(medium) { - .like, .unlike { - - span.percentage { - display: block; - line-height: $line-height/2; - } - } + text-align: center; } } } +.debate-show .votes { + border: 0; + padding: $line-height/2 0; +} + .proposal { .supports { @include supports; - border: 1px solid $proposals; - margin: 0 rem-calc(-12); - - @include breakpoint(medium) { - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - margin: 0 rem-calc(-25) 0 rem-calc(12); - } - - &:after { - content: none; - position: absolute; - display: block; - border-style: solid; - border-color: #664212 transparent transparent transparent; - bottom: -14px; - border-left-width: 0; - border-right-color: transparent; - right: -1px; - border-width: 13px 13px 0 0; - - @include breakpoint(medium) { - content: ""; - } - } - - .total-supports { - display: inline-block; - line-height: $line-height; - padding-top: rem-calc(12); - vertical-align: top; - - @include breakpoint(medium) { - display: block; - float: none; - margin-left: 0; - padding-top: 0; - } - } } } @@ -759,20 +671,6 @@ .supports { @include supports; - background: none; - border: 0; - border-left: 1px solid $border; - margin: 0 rem-calc(-12); - min-height: rem-calc(180); - padding-top: 0; - - @include breakpoint(medium) { - padding-top: $line-height*1.5; - } - - &:after { - content: none; - } .investment-project-amount { color: $budget; @@ -802,33 +700,14 @@ font-weight: bold; } - .supported { - color: $budget; - margin-top: 0; - width: 100%; - } - .remove .icon-check-circle { display: block; font-size: rem-calc(70); line-height: rem-calc(70); } - - .share-supported { - - .ssb-twitter, - .ssb-facebook, - .ssb-google_plus { - color: $budget; - } - } } } -.investment-project-show .supports { - border: 0; -} - .proposals-summary { .panel { @@ -903,7 +782,14 @@ } .button-support { + background: $text; + color: $featured; margin-top: 0; + + &:hover { + background: white; + color: $text; + } } .participation-not-allowed { @@ -924,6 +810,7 @@ .supported { margin-top: 0; + font-size: $small-font-size; } .share-supported { @@ -931,7 +818,10 @@ .ssb-twitter, .ssb-facebook, .ssb-google_plus { - height: rem-calc(33); + background: none; + color: $text; + height: rem-calc(33) !important; + &:before { font-size: rem-calc(18); diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index c3d814b38..c46b6e42f 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -29,4 +29,4 @@ class AccountController < ApplicationController end end -end +end \ No newline at end of file diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb index dbf683b9a..c96c7c72b 100644 --- a/app/controllers/admin/banners_controller.rb +++ b/app/controllers/admin/banners_controller.rb @@ -38,6 +38,7 @@ class Admin::BannersController < Admin::BaseController end private + def banner_params params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at) end @@ -53,4 +54,5 @@ class Admin::BannersController < Admin::BaseController def banner_imgs @banner_imgs = Setting.all.banner_img.map { |banner_img| [banner_img.value, banner_img.key.split('.')[1]] } end + end \ No newline at end of file diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index a0272f367..1f3d8e837 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -20,8 +20,9 @@ class Admin::CommentsController < Admin::BaseController end private + def load_comment @comment = Comment.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index f7aa5c440..5fb5e3c13 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -3,4 +3,4 @@ class Admin::DashboardController < Admin::BaseController def index end -end +end \ No newline at end of file diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb index 0b0b31b8b..bbe4a06d7 100644 --- a/app/controllers/admin/debates_controller.rb +++ b/app/controllers/admin/debates_controller.rb @@ -29,4 +29,4 @@ class Admin::DebatesController < Admin::BaseController @debate = Debate.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/officials_controller.rb b/app/controllers/admin/officials_controller.rb index 2d570c2dc..e0a0a86ca 100644 --- a/app/controllers/admin/officials_controller.rb +++ b/app/controllers/admin/officials_controller.rb @@ -25,8 +25,9 @@ class Admin::OfficialsController < Admin::BaseController end private + def user_params params.require(:user).permit(:official_position, :official_level) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index 77f71ed65..b85460459 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -27,4 +27,4 @@ class Admin::OrganizationsController < Admin::BaseController redirect_to request.query_parameters.merge(action: :index) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index e7c4934fa..2a6dfd718 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -25,4 +25,4 @@ class Admin::ProposalsController < Admin::BaseController @proposal = Proposal.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 17bd364f3..f17afff4c 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -15,7 +15,9 @@ class Admin::SettingsController < Admin::BaseController end private + def settings_params params.require(:setting).permit(:value) end + end \ No newline at end of file diff --git a/app/controllers/admin/spending_proposals_controller.rb b/app/controllers/admin/spending_proposals_controller.rb index e4c13e612..b5923f2f6 100644 --- a/app/controllers/admin/spending_proposals_controller.rb +++ b/app/controllers/admin/spending_proposals_controller.rb @@ -54,4 +54,4 @@ class Admin::SpendingProposalsController < Admin::BaseController @tags = ActsAsTaggableOn::Tag.spending_proposal_tags end -end +end \ No newline at end of file diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index 7e5b902e9..3624174a5 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -32,4 +32,5 @@ class Admin::StatsController < Admin::BaseController @direct_messages = DirectMessage.count @users_who_have_sent_message = DirectMessage.select(:sender_id).distinct.count end -end + +end \ No newline at end of file diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index eed1c4fea..1e17e1c2d 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -30,4 +30,4 @@ class Admin::UsersController < Admin::BaseController @user = User.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/valuators_controller.rb b/app/controllers/admin/valuators_controller.rb index 3e403c9fc..4b52a753e 100644 --- a/app/controllers/admin/valuators_controller.rb +++ b/app/controllers/admin/valuators_controller.rb @@ -30,8 +30,10 @@ class Admin::ValuatorsController < Admin::BaseController end private + def create_params params[:valuator][:description] = nil if params[:valuator][:description].blank? params.require(:valuator).permit(:user_id, :description) end -end + +end \ No newline at end of file diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index df928aa02..0a0018c9f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -77,4 +77,4 @@ class CommentsController < ApplicationController Notification.add(notifiable.author_id, notifiable) unless comment.author_id == notifiable.author_id end -end +end \ No newline at end of file diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 3f4398797..ef5e60dcb 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -155,4 +155,4 @@ module CommentableActions nil end -end +end \ No newline at end of file diff --git a/app/controllers/concerns/moderate_actions.rb b/app/controllers/concerns/moderate_actions.rb index 792dacde0..05aa0e97f 100644 --- a/app/controllers/concerns/moderate_actions.rb +++ b/app/controllers/concerns/moderate_actions.rb @@ -4,9 +4,9 @@ module ModerateActions def index @resources = @resources.send(@current_filter) - .send("sort_by_#{@current_order}") - .page(params[:page]) - .per(50) + .send("sort_by_#{@current_order}") + .page(params[:page]) + .per(50) set_resources_instance end diff --git a/app/controllers/concerns/polymorphic.rb b/app/controllers/concerns/polymorphic.rb index 51c5768c9..10d64698d 100644 --- a/app/controllers/concerns/polymorphic.rb +++ b/app/controllers/concerns/polymorphic.rb @@ -1,6 +1,7 @@ module Polymorphic private + def resource @resource ||= instance_variable_get("@#{resource_name}") end diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 7d2149cad..fd10e503c 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -21,8 +21,8 @@ class DebatesController < ApplicationController respond_to :html, :js def index_customization - @featured_debates = @debates.featured - @proposal_successfull_exists = Proposal.successfull.exists? + @featured_debates = @debates.featured + @proposal_successfull_exists = Proposal.successfull.exists? end def show @@ -55,4 +55,4 @@ class DebatesController < ApplicationController Debate end -end +end \ No newline at end of file diff --git a/app/controllers/management/account_controller.rb b/app/controllers/management/account_controller.rb index 85b9feea4..64e0ddf4d 100644 --- a/app/controllers/management/account_controller.rb +++ b/app/controllers/management/account_controller.rb @@ -6,6 +6,7 @@ class Management::AccountController < Management::BaseController end private + def only_verified_users check_verified_user t("management.account.alert.unverified_user") end diff --git a/app/controllers/management/dashboard_controller.rb b/app/controllers/management/dashboard_controller.rb index abb605341..87b134270 100644 --- a/app/controllers/management/dashboard_controller.rb +++ b/app/controllers/management/dashboard_controller.rb @@ -3,4 +3,4 @@ class Management::DashboardController < Management::BaseController def index end -end +end \ No newline at end of file diff --git a/app/controllers/management/document_verifications_controller.rb b/app/controllers/management/document_verifications_controller.rb index 1b8fabcc2..510e4fa93 100644 --- a/app/controllers/management/document_verifications_controller.rb +++ b/app/controllers/management/document_verifications_controller.rb @@ -33,17 +33,17 @@ class Management::DocumentVerificationsController < Management::BaseController private - def document_verification_params - params.require(:document_verification).permit(:document_type, :document_number) - end + def document_verification_params + params.require(:document_verification).permit(:document_type, :document_number) + end - def set_document - session[:document_type] = params[:document_verification][:document_type] - session[:document_number] = params[:document_verification][:document_number] - end + def set_document + session[:document_type] = params[:document_verification][:document_type] + session[:document_number] = params[:document_verification][:document_number] + end - def clean_document_number - params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? - end + def clean_document_number + params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? + end end \ No newline at end of file diff --git a/app/controllers/management/email_verifications_controller.rb b/app/controllers/management/email_verifications_controller.rb index 3558e6fbf..7d511fe4b 100644 --- a/app/controllers/management/email_verifications_controller.rb +++ b/app/controllers/management/email_verifications_controller.rb @@ -16,8 +16,8 @@ class Management::EmailVerificationsController < Management::BaseController private - def email_verification_params - params.require(:email_verification).permit(:document_type, :document_number, :email) - end + def email_verification_params + params.require(:email_verification).permit(:document_type, :document_number, :email) + end end \ No newline at end of file diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 2ce74d6d5..1a30526f5 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -53,4 +53,4 @@ class Management::ProposalsController < Management::BaseController @comment_flags = managed_user ? managed_user.comment_flags(comments) : {} end -end +end \ No newline at end of file diff --git a/app/controllers/management/sessions_controller.rb b/app/controllers/management/sessions_controller.rb index bca17bf4c..5d0587ae5 100644 --- a/app/controllers/management/sessions_controller.rb +++ b/app/controllers/management/sessions_controller.rb @@ -42,4 +42,4 @@ class Management::SessionsController < ActionController::Base end end -end +end \ No newline at end of file diff --git a/app/controllers/management/user_invites_controller.rb b/app/controllers/management/user_invites_controller.rb index cbe3d1914..4d9b4909f 100644 --- a/app/controllers/management/user_invites_controller.rb +++ b/app/controllers/management/user_invites_controller.rb @@ -10,4 +10,4 @@ class Management::UserInvitesController < Management::BaseController end end -end +end \ No newline at end of file diff --git a/app/controllers/moderation/users_controller.rb b/app/controllers/moderation/users_controller.rb index 3255bb6cc..cd1fff9a5 100644 --- a/app/controllers/moderation/users_controller.rb +++ b/app/controllers/moderation/users_controller.rb @@ -21,13 +21,13 @@ class Moderation::UsersController < Moderation::BaseController private - def load_users - @users = User.with_hidden.search(params[:name_or_email]).page(params[:page]).for_render - end + def load_users + @users = User.with_hidden.search(params[:name_or_email]).page(params[:page]).for_render + end - def block_user - @user.block - Activity.log(current_user, :block, @user) - end + def block_user + @user.block + Activity.log(current_user, :block, @user) + end end \ No newline at end of file diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index 503c26bc0..a77534d8c 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -24,6 +24,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController end protected + def after_inactive_sign_up_path_for(resource) organizations_sign_up_success_path end diff --git a/app/controllers/proposal_ballots_controller.rb b/app/controllers/proposal_ballots_controller.rb index 4e3e99671..4171fcda8 100644 --- a/app/controllers/proposal_ballots_controller.rb +++ b/app/controllers/proposal_ballots_controller.rb @@ -5,4 +5,4 @@ class ProposalBallotsController < ApplicationController @proposal_ballots = Proposal.successfull.sort_by_confidence_score end -end +end \ No newline at end of file diff --git a/app/controllers/proposal_notifications_controller.rb b/app/controllers/proposal_notifications_controller.rb index fc9cdf3d8..36e265e38 100644 --- a/app/controllers/proposal_notifications_controller.rb +++ b/app/controllers/proposal_notifications_controller.rb @@ -26,8 +26,8 @@ class ProposalNotificationsController < ApplicationController private - def proposal_notification_params - params.require(:proposal_notification).permit(:title, :body, :proposal_id) - end + def proposal_notification_params + params.require(:proposal_notification).permit(:title, :body, :proposal_id) + end end \ No newline at end of file diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index ede5b0f5d..9523a0df2 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -107,4 +107,4 @@ class ProposalsController < ApplicationController @proposal_successfull_exists = Proposal.successfull.exists? end -end +end \ No newline at end of file diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 81eaa08cb..cbe43390b 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -44,4 +44,4 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController @user.save || @user.save_requiring_finish_signup end -end +end \ No newline at end of file diff --git a/app/controllers/valuation/spending_proposals_controller.rb b/app/controllers/valuation/spending_proposals_controller.rb index d3bc585b1..623c9ac46 100644 --- a/app/controllers/valuation/spending_proposals_controller.rb +++ b/app/controllers/valuation/spending_proposals_controller.rb @@ -58,7 +58,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController end def params_for_current_valuator - params.merge({valuator_id: current_user.valuator.id}) + params.merge({valuator_id: current_user.valuator.id}) end def restrict_access_to_assigned_items @@ -77,4 +77,4 @@ class Valuation::SpendingProposalsController < Valuation::BaseController @spending_proposal.errors.empty? end -end +end \ No newline at end of file diff --git a/app/controllers/verification/letter_controller.rb b/app/controllers/verification/letter_controller.rb index bf5033b32..998f42766 100644 --- a/app/controllers/verification/letter_controller.rb +++ b/app/controllers/verification/letter_controller.rb @@ -56,5 +56,4 @@ class Verification::LetterController < ApplicationController end end - -end +end \ No newline at end of file diff --git a/app/controllers/verification/verified_user_controller.rb b/app/controllers/verification/verified_user_controller.rb index 23045e451..e637bb232 100644 --- a/app/controllers/verification/verified_user_controller.rb +++ b/app/controllers/verification/verified_user_controller.rb @@ -9,6 +9,7 @@ class Verification::VerifiedUserController < ApplicationController end private + def user_data_present? return false if @verified_users.blank? diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index fc43f5357..d0c650fa3 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,5 +16,4 @@ class WelcomeController < ApplicationController redirect_to verification_path if signed_in? end - end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 515a54deb..62d31cd05 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -5,7 +5,7 @@ module AdminHelper end def official_level_options - options = [["",0]] + options = [["", 0]] (1..5).each do |i| options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i] end diff --git a/app/helpers/banners_helper.rb b/app/helpers/banners_helper.rb index 548513c7d..a1505a39e 100644 --- a/app/helpers/banners_helper.rb +++ b/app/helpers/banners_helper.rb @@ -1,5 +1,7 @@ module BannersHelper + def has_banners @banners.count > 0 end + end \ No newline at end of file diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 9d9d08075..13884237b 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -39,4 +39,5 @@ module CommentsHelper "" # Default not author class end end -end + +end \ No newline at end of file diff --git a/app/helpers/debates_helper.rb b/app/helpers/debates_helper.rb index 3c1aa02a7..8db989f61 100644 --- a/app/helpers/debates_helper.rb +++ b/app/helpers/debates_helper.rb @@ -1,6 +1,7 @@ module DebatesHelper - def has_featured? + def has_featured? Debate.all.featured.count > 0 end + end \ No newline at end of file diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index b48799bf5..8633549f4 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -9,15 +9,15 @@ module EmbedVideosHelper end if server == "Vimeo" - regExp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ + reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ src = "https://player.vimeo.com/video/" elsif server == "YouTube" - regExp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ + reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ src = "https://www.youtube.com/embed/" end - if regExp - match = link.match(regExp) + if reg_exp + match = link.match(reg_exp) end if match and match[2] diff --git a/app/helpers/flags_helper.rb b/app/helpers/flags_helper.rb index b5ba67f41..715937c0f 100644 --- a/app/helpers/flags_helper.rb +++ b/app/helpers/flags_helper.rb @@ -26,4 +26,4 @@ module FlagsHelper end end -end +end \ No newline at end of file diff --git a/app/helpers/locales_helper.rb b/app/helpers/locales_helper.rb index 7954cc908..717be9e9b 100644 --- a/app/helpers/locales_helper.rb +++ b/app/helpers/locales_helper.rb @@ -5,4 +5,4 @@ module LocalesHelper I18n.backend.translate(locale, "i18n.language.name", default: default) end -end +end \ No newline at end of file diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 2b907535f..7342393a7 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,4 +1,2 @@ module NotificationsHelper - - end diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 9eaa88549..578cd1d8e 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -2,19 +2,19 @@ module ProposalsHelper def progress_bar_percentage(proposal) case proposal.cached_votes_up - when 0 then 0 - when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor - else 100 + when 0 then 0 + when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor + else 100 end end def supports_percentage(proposal) percentage = (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success) case percentage - when 0 then "0%" - when 0..(0.1) then "0.1%" - when (0.1)..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1) - else "100%" + when 0 then "0%" + when 0..(0.1) then "0.1%" + when (0.1)..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1) + else "100%" end end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index cd90a8a39..ad844e29f 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -8,4 +8,4 @@ module SettingsHelper @all_settings ||= Hash[ Setting.all.map{|s| [s.key, s.value.presence]} ] end -end +end \ No newline at end of file diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index 097711b88..e481ef7e1 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -20,4 +20,5 @@ module StatsHelper opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) content_tag :div, "", opt end + end diff --git a/app/helpers/tracks_helper.rb b/app/helpers/tracks_helper.rb index 53c110d49..557d71802 100644 --- a/app/helpers/tracks_helper.rb +++ b/app/helpers/tracks_helper.rb @@ -1,4 +1,5 @@ module TracksHelper + def track_event(data={}) track_data = "" prefix = " data-track-event-" @@ -9,4 +10,5 @@ module TracksHelper track_data end end + end \ No newline at end of file diff --git a/app/models/comment.rb b/app/models/comment.rb index 47beb5050..0bfb6a320 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -24,8 +24,8 @@ class Comment < ActiveRecord::Base scope :not_as_admin_or_moderator, -> { where("administrator_id IS NULL").where("moderator_id IS NULL")} scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - scope :sort_by_most_voted , -> { order(confidence_score: :desc, created_at: :desc) } - scope :sort_descendants_by_most_voted , -> { order(confidence_score: :desc, created_at: :asc) } + scope :sort_by_most_voted, -> { order(confidence_score: :desc, created_at: :desc) } + scope :sort_descendants_by_most_voted, -> { order(confidence_score: :desc, created_at: :asc) } scope :sort_by_newest, -> { order(created_at: :desc) } scope :sort_descendants_by_newest, -> { order(created_at: :desc) } @@ -95,7 +95,7 @@ class Comment < ActiveRecord::Base end def self.body_max_length - Setting['comments_body_max_length'].to_i + Setting['comments_body_max_length'].to_i end def calculate_confidence_score diff --git a/app/models/debate.rb b/app/models/debate.rb index 840b9c4b5..020259d80 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -28,7 +28,7 @@ class Debate < ActiveRecord::Base before_save :calculate_hot_score, :calculate_confidence_score scope :for_render, -> { includes(:tags) } - scope :sort_by_hot_score , -> { reorder(hot_score: :desc) } + scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) } scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } diff --git a/app/models/notification.rb b/app/models/notification.rb index c6c32eb8d..e993e55f8 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -49,4 +49,5 @@ class Notification < ActiveRecord::Base def linkable_resource notifiable.is_a?(ProposalNotification) ? notifiable.proposal : notifiable end + end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 916c3d0b9..44250109c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User < ActiveRecord::Base include Verification - devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, + devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :async, :password_expirable, :secure_validatable acts_as_voter @@ -246,6 +246,7 @@ class User < ActiveRecord::Base delegate :can?, :cannot?, to: :ability private + def clean_document_number self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank? end @@ -257,4 +258,4 @@ class User < ActiveRecord::Base validator.validate(self) end -end +end \ No newline at end of file diff --git a/app/views/comments/_votes.html.erb b/app/views/comments/_votes.html.erb index 0de92a675..93af5b2dd 100644 --- a/app/views/comments/_votes.html.erb +++ b/app/views/comments/_votes.html.erb @@ -6,13 +6,17 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'yes'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.agree') do %> + <%= t('votes.agree') %> <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.agree') %> + + <% end %> <% end %> <%= comment.total_likes %> @@ -20,13 +24,15 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'no'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.disagree') do %> + <%= t('votes.disagree') %> <% end %> <% else %> - + + <%= t('votes.disagree') %> + <% end %> <%= comment.total_dislikes %> @@ -40,26 +46,40 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'yes'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.agree') do %> + + <%= t('votes.agree') %> + <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.agree') %> + + <% end %> <% end %> <%= comment.total_likes %> + <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'no'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.disagree') do %> + + <%= t('votes.disagree') %> + <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.disagree') %> + + <% end %> <% end %> <%= comment.total_dislikes %> - + + -
+
<%= render 'debates/votes', debate: debate %>
diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 2cd3f2d53..45d27bd56 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -6,6 +6,8 @@ <% end %>
+

<%= t("shared.outline.debates") %>

+
diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 9625ab42d..dca39677e 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -45,10 +45,8 @@