diff --git a/.rubocop.yml b/.rubocop.yml index 58cf10d34..cbb1bd0fb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -31,6 +31,9 @@ Style/FrozenStringLiteralComment: Style/PercentLiteralDelimiters: Enabled: false +Style/SymbolArray: + Enabled: false + Layout/EmptyLinesAroundClassBody: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 19e3a59a6..54a3f650f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -86,14 +86,6 @@ Performance/RedundantMatch: - 'app/controllers/valuation/spending_proposals_controller.rb' - 'app/helpers/embed_videos_helper.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: strict, flexible -Rails/Date: - Exclude: - - 'app/controllers/concerns/commentable_actions.rb' - - 'app/models/direct_message.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: Whitelist. @@ -138,35 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Rails/PluralizationGrammar: - Exclude: - - 'spec/features/admin/banners_spec.rb' - - 'spec/features/debates_spec.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/models/residence_spec.rb' - -# Offense count: 11 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: strict, flexible -Rails/TimeZone: - Exclude: - - 'lib/score_calculator.rb' - - 'spec/controllers/admin/api/stats_controller_spec.rb' - - 'spec/models/ahoy/data_source_spec.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/Validation: - Exclude: - - 'app/models/comment.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/verification/residence.rb' - - 'app/models/verification/sms.rb' - # Offense count: 9 Style/AccessorMethodName: Exclude: @@ -202,13 +165,6 @@ Layout/AlignParameters: - 'spec/models/user_spec.rb' - 'spec/rails_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/BlockEndNewline: - Exclude: - - 'app/models/banner.rb' - - 'spec/features/users_auth_spec.rb' - # Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -290,12 +246,6 @@ Layout/EmptyLines: - 'spec/features/verification/verified_user_spec.rb' - 'spec/support/verifiable.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - 'app/controllers/users_controller.rb' - # Offense count: 29 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. @@ -607,111 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceAfterColon: - Exclude: - - 'spec/models/user_spec.rb' - -# Offense count: 14 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Exclude: - - 'app/models/ahoy/data_source.rb' - - 'app/models/banner.rb' - - 'app/models/concerns/search_cache.rb' - - 'app/models/concerns/taggable.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/user.rb' - - 'spec/features/valuation/spending_proposals_spec.rb' - - 'spec/lib/census_api_spec.rb' - - 'spec/models/abilities/moderator_spec.rb' - - 'spec/models/verification/management/email_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceAfterNot: - Exclude: - - 'app/models/flag.rb' - -# Offense count: 20 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'app/helpers/cache_keys_helper.rb' - - 'app/helpers/proposals_helper.rb' - - 'app/helpers/spending_proposals_helper.rb' - - 'app/helpers/stats_helper.rb' - - 'app/helpers/tracks_helper.rb' - - 'app/helpers/valuation_helper.rb' - - 'app/mailers/devise_mailer.rb' - - 'app/models/comment.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/residence.rb' - - 'lib/acts_as_paranoid_aliases.rb' - - 'lib/capistrano/template.rb' - - 'lib/census_api.rb' - - 'lib/manager_authenticator.rb' - - 'spec/support/common_actions.rb' - -# Offense count: 66 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceAroundOperators: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'app/models/proposal.rb' - - 'spec/controllers/management/sessions_controller_spec.rb' - - 'spec/controllers/management/users_controller_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/factories.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: require_no_space, require_space -Layout/SpaceInLambdaLiteral: - Exclude: - - 'app/models/concerns/filterable.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/user.rb' - - 'app/models/verified_user.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -Layout/SpaceInsideParens: - Exclude: - - 'app/models/user.rb' - - 'lib/manager_authenticator.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/models/abilities/moderator_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'app/models/activity.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Exclude: - - 'app/controllers/stats_controller.rb' - - 'app/models/proposal.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. @@ -724,12 +569,6 @@ Style/SymbolProc: - 'lib/manager_authenticator.rb' - 'spec/factories.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/TrailingWhitespace: - Exclude: - - 'app/controllers/admin/api/stats_controller.rb' - # Offense count: 31 # Cop supports --auto-correct. Style/UnneededInterpolation: @@ -756,9 +595,3 @@ Style/VariableNumber: Style/WordArray: EnforcedStyle: percent MinSize: 3 - -# Offense count: 1 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'app/models/concerns/verification.rb' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a487eadb4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,38 @@ +### 0.9 - 2017-06-15 + +* New features + * Budgets + * Basic polls + * Collaborative legistlation + * Custom pages + * GraphQL API + * Improved admin section +* Enhancements + * Improved admin section + * Rails 4.2.8 + * Ruby 2.3.2 +* Bug fixes + * CKEditor locale compilation fixed + * Fixed bugs in mobile layouts +* Deprecations + * SpendingProposals are deprecated now in favor of Budgets + +### 0.8 - 2016-07-21 + +* New features + * Support for customization schema, vía specific custom files, assets and folders +* Enhancements + * Rails 2.4.7 + * Ruby 2.3.1 +* Bug fixes + * Fixed bug causing errors on user deletion + +### 0.7 - 2016-04-25 + +* New features + * Debates + * Proposals + * Basic Spending Proposals +* Enhancements + * Rails 2.4.6 + * Ruby 2.2.3 \ No newline at end of file diff --git a/CODE_OF_CONDUCT_EN.md b/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT_EN.md rename to CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING_EN.md b/CONTRIBUTING.md similarity index 83% rename from CONTRIBUTING_EN.md rename to CONTRIBUTING.md index 2c5f6a591..3147d1e4a 100644 --- a/CONTRIBUTING_EN.md +++ b/CONTRIBUTING.md @@ -1,15 +1,16 @@ # How to Contribute to this Project -## Team members +## Core team members -* Raimond Garcia [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) +* Raimond García [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) * Juanjo Bazán [github](https://github.com/xuanxu) | [twitter](https://twitter.com/xuanxu) * Enrique García Cota [github](https://github.com/kikito) | [twitter](https://twitter.com/otikik) -* Alberto Garcia Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto García Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto Calderón [github](https://github.com/bertocq) | [twitter](https://twitter.com/bertocq) ## Code of conduct -The team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT_EN.md](CODE_OF_CONDUCT_EN.md) file. +The core team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file. ## Report an issue diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md index 6be8be9cd..b981bc408 100644 --- a/CONTRIBUTING_ES.md +++ b/CONTRIBUTING_ES.md @@ -2,10 +2,11 @@ ## Miembros del equipo -* Raimond Garcia [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) +* Raimond García [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) * Juanjo Bazán [github](https://github.com/xuanxu) | [twitter](https://twitter.com/xuanxu) * Enrique García Cota [github](https://github.com/kikito) | [twitter](https://twitter.com/otikik) -* Alberto Garcia Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto García Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto Calderón [github](https://github.com/bertocq) | [twitter](https://twitter.com/bertocq) ## Código de conducta diff --git a/Gemfile b/Gemfile index 86ac55fd3..245ca2a88 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.8' +gem 'rails', '4.2.9' # Use PostgreSQL gem 'pg', '~> 0.20.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 6a9d8a1ce..de9002e3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,36 +2,36 @@ GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actionmailer (4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) + actionmailer (4.2.9) + actionpack (= 4.2.9) + actionview (= 4.2.9) + activejob (= 4.2.9) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.8) - actionview (= 4.2.8) - activesupport (= 4.2.8) + actionpack (4.2.9) + actionview (= 4.2.9) + activesupport (= 4.2.9) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.8) - activesupport (= 4.2.8) + actionview (4.2.9) + activesupport (= 4.2.9) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.8) - activesupport (= 4.2.8) + activejob (4.2.9) + activesupport (= 4.2.9) globalid (>= 0.3.0) - activemodel (4.2.8) - activesupport (= 4.2.8) + activemodel (4.2.9) + activesupport (= 4.2.9) builder (~> 3.1) - activerecord (4.2.8) - activemodel (= 4.2.8) - activesupport (= 4.2.8) + activerecord (4.2.9) + activemodel (= 4.2.9) + activesupport (= 4.2.9) arel (~> 6.0) - activesupport (4.2.8) + activesupport (4.2.9) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) @@ -174,8 +174,8 @@ GEM rspec-core (~> 3.0) ruby-progressbar (~> 1.4) geocoder (1.4.3) - globalid (0.3.7) - activesupport (>= 4.1.0) + globalid (0.4.0) + activesupport (>= 4.2.0) graphiql-rails (1.4.1) rails graphql (1.6.3) @@ -188,7 +188,7 @@ GEM htmlentities (4.3.4) httpi (2.4.1) rack - i18n (0.8.1) + i18n (0.8.4) i18n-tasks (0.9.15) activesupport (>= 4.0.2) ast (>= 2.1.0) @@ -248,8 +248,8 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mimemagic (0.3.2) - mini_portile2 (2.1.0) - minitest (5.10.1) + mini_portile2 (2.2.0) + minitest (5.10.2) mixlib-cli (1.7.0) mixlib-config (2.2.4) multi_json (1.12.1) @@ -259,8 +259,8 @@ GEM net-ssh (>= 2.6.5) net-ssh (4.1.0) newrelic_rpm (4.1.0.333) - nokogiri (1.7.2) - mini_portile2 (~> 2.1.0) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) nori (2.6.0) oauth (0.5.1) oauth2 (1.3.1) @@ -313,23 +313,23 @@ GEM public_suffix (2.0.5) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.5) + rack (1.6.8) rack-accept (0.4.5) rack (>= 0.4) rack-attack (5.0.1) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.8) - actionmailer (= 4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) - activemodel (= 4.2.8) - activerecord (= 4.2.8) - activesupport (= 4.2.8) + rails (4.2.9) + actionmailer (= 4.2.9) + actionpack (= 4.2.9) + actionview (= 4.2.9) + activejob (= 4.2.9) + activemodel (= 4.2.9) + activerecord (= 4.2.9) + activesupport (= 4.2.9) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.8) + railties (= 4.2.9) sprockets-rails rails-assets-markdown-it (8.2.1) rails-deprecated_sanitizer (1.0.3) @@ -340,9 +340,9 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.8) - actionpack (= 4.2.8) - activesupport (= 4.2.8) + railties (4.2.9) + actionpack (= 4.2.9) + activesupport (= 4.2.9) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) @@ -541,7 +541,7 @@ DEPENDENCIES pg_search poltergeist (~> 1.15.0) quiet_assets - rails (= 4.2.8) + rails (= 4.2.9) rails-assets-markdown-it! redcarpet (~> 3.4.0) responders (~> 2.4.0) diff --git a/README.md b/README.md index a9ec82550..380d03031 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Run the app locally: bin/rails s ``` -Prerequisites for testing: install PhantomJS >= 1.9.8 +Prerequisites for testing: install PhantomJS >= 2.1.1 Run the tests with: @@ -65,6 +65,8 @@ If you add SCSS code you can check it with: scss-lint ``` +To maintain accesibility level, if you add new colors use a [Color contrast checker](http://webaim.org/resources/contrastchecker/) (WCAG AA is mandatory, WCAG AAA is recommended) + If you work on Coffeescript code you can check it with [coffeelint](http://www.coffeelint.org/) (install with `npm install -g coffeelint`) : ``` @@ -100,4 +102,4 @@ Code published under AFFERO GPL v3 (see [LICENSE-AGPLv3.txt](LICENSE-AGPLv3.txt) ## Contributions -See [CONTRIBUTING_EN.md](CONTRIBUTING_EN.md) +See [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/README_ES.md b/README_ES.md index 81a7ba465..9a57b1f18 100644 --- a/README_ES.md +++ b/README_ES.md @@ -51,7 +51,7 @@ Para ejecutar la aplicación en local: bin/rails s ``` -Prerequisitos para los tests: tener instalado PhantomJS >= 1.9.8 +Prerequisitos para los tests: tener instalado PhantomJS >= 2.1.1 Para ejecutar los tests: @@ -65,6 +65,8 @@ Si añades código SCSS puedes revisarlo con: scss-lint ``` +Para mantener el nivel de accesibilidad, si añades colores nuevos utiliza un [Comprobador de contraste de color](http://webaim.org/resources/contrastchecker/) (WCAG AA es obligatorio, WCAG AAA es recomendable) + Si trabajas en código coffeescript puedes revisarlo con [coffeelint](http://www.coffeelint.org/) (instalalo con `npm install -g coffeelint`) : ``` diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 2bca33bf5..9673cdc88 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -825,23 +825,6 @@ form { margin: $line-height / 2 0 $line-height / 2 $line-height / 4; } - .note, - .note-marked { - display: block; - font-size: rem-calc(13); - margin-bottom: $line-height / 2; - } - - .note-marked { - background: #ff0; - display: inline-block; - - em { - background: #fff; - display: block; - } - } - .ckeditor { min-height: $line-height * 13; } diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index a9cde9f55..8af8071ea 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -494,6 +494,109 @@ } } +.tab-milestones ul { + margin-top: rem-calc(40); + position: relative; + + li { + margin: 0 auto; + position: relative; + width: 0; + } + + li::before { + background: $budget; + border-radius: rem-calc(20); + content: ''; + height: rem-calc(20); + position: absolute; + top: 5px; + transform: translateX(-50%); + width: rem-calc(20); + z-index: 2; + } + + li::after { + background: $light-gray; + bottom: 100%; + content: ''; + height: 100%; + position: absolute; + top: 25px; + width: 1px; + z-index: 1; + } +} + +.tab-milestones ul .milestone-content { + padding: $line-height / 6 $line-height / 2; + position: relative; + + h3 { + margin-bottom: 0; + } + + .milestone-date { + color: $text-medium; + font-size: $small-font-size; + } +} + +.tab-milestones .timeline ul li:nth-child(odd), +.tab-milestones .timeline ul li:nth-child(even) { + + .milestone-content { + + @include breakpoint(medium) { + width: rem-calc(300); + } + + @include breakpoint(large) { + width: rem-calc(450); + } + } +} + +.tab-milestones .timeline ul li:nth-child(odd) { + + .milestone-content { + text-align: right; + + @include breakpoint(medium) { + margin-left: rem-calc(-315); + } + + @include breakpoint(large) { + margin-left: rem-calc(-465); + } + } +} + +.tab-milestones .timeline ul li:nth-child(even) { + + .milestone-content { + left: 15px; + } +} + +.tab-milestones { + @include breakpoint(small only) { + + .timeline ul li { + width: 100%; + + &:nth-child(odd), + &:nth-child(even) { + + .milestone-content { + left: 15px; + text-align: left; + } + } + } + } +} + // 04. List participation // ---------------------- diff --git a/app/controllers/admin/budget_investment_milestones_controller.rb b/app/controllers/admin/budget_investment_milestones_controller.rb new file mode 100644 index 000000000..a4b8acc5d --- /dev/null +++ b/app/controllers/admin/budget_investment_milestones_controller.rb @@ -0,0 +1,55 @@ +class Admin::BudgetInvestmentMilestonesController < Admin::BaseController + + before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy] + before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy] + + def index + end + + def new + @milestone = Budget::Investment::Milestone.new + end + + def create + @milestone = Budget::Investment::Milestone.new(milestone_params) + @milestone.investment = @investment + if @milestone.save + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.create.notice') + else + render :new + end + end + + def edit + end + + def update + if @milestone.update(milestone_params) + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.update.notice') + else + render :edit + end + end + + def destroy + @milestone.destroy + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.delete.notice') + end + + private + + def milestone_params + params.require(:budget_investment_milestone) + .permit(:title, :description, :budget_investment_id) + end + + def load_budget_investment + @investment = Budget::Investment.find params[:budget_investment_id] + end + + def load_budget_investment_milestone + @milestone = Budget::Investment::Milestone.find params[:id] + end + + +end diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index 0b373c0bd..b37351028 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -14,10 +14,15 @@ class Admin::BudgetsController < Admin::BaseController @budget = Budget.includes(groups: :headings).find(params[:id]) end - def new - end + def new; end - def edit + def edit; end + + def calculate_winners + return unless @budget.balloting_process? + @budget.headings.each { |heading| Budget::Result.new(@budget, heading).calculate_winners } + redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'), + notice: I18n.t("admin.budgets.winners.calculated") end def update diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index eda5736b0..6046ffb48 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -67,6 +67,7 @@ class Admin::Poll::PollsController < Admin::BaseController end private + def load_geozones @geozones = Geozone.all.order(:name) end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d1dd1c79c..e36a6a4f0 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -4,7 +4,7 @@ class Admin::UsersController < Admin::BaseController def index if params[:search] s = params[:search] - @users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%","%#{s}%","%#{s}%").page(params[:page]) + @users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%", "%#{s}%", "%#{s}%").page(params[:page]) else @users = @users.page(params[:page]) end diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 469b09255..ea782d47c 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -93,7 +93,7 @@ module Budgets def set_random_seed if params[:order] == 'random' || params[:order].blank? - params[:random_seed] ||= rand(99)/100.0 + params[:random_seed] ||= rand(99) / 100.0 seed = Float(params[:random_seed]) rescue 0 Budget::Investment.connection.execute("select setseed(#{seed})") else diff --git a/app/controllers/legislation/answers_controller.rb b/app/controllers/legislation/answers_controller.rb index 6d3c33580..36f87de1f 100644 --- a/app/controllers/legislation/answers_controller.rb +++ b/app/controllers/legislation/answers_controller.rb @@ -19,13 +19,14 @@ class Legislation::AnswersController < Legislation::BaseController end else respond_to do |format| - format.js { render json: {} , status: :not_found } + format.js { render json: {}, status: :not_found } format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') } end end end private + def answer_params params.require(:legislation_answer).permit( :legislation_question_option_id, diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index 652d2b9a7..1fdf33911 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -20,7 +20,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController @investment.author = managed_user if @investment.save - notice= t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1) + notice = t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1) redirect_to management_budget_investment_path(@budget, @investment), notice: notice else render :new diff --git a/app/controllers/officing/final_recounts_controller.rb b/app/controllers/officing/final_recounts_controller.rb index e381240e7..8be6e1a91 100644 --- a/app/controllers/officing/final_recounts_controller.rb +++ b/app/controllers/officing/final_recounts_controller.rb @@ -28,6 +28,7 @@ class Officing::FinalRecountsController < Officing::BaseController end private + def load_poll @poll = Poll.expired.find(params[:poll_id]) end diff --git a/app/controllers/officing/recounts_controller.rb b/app/controllers/officing/recounts_controller.rb index 1c66e57fd..9e3989c05 100644 --- a/app/controllers/officing/recounts_controller.rb +++ b/app/controllers/officing/recounts_controller.rb @@ -27,6 +27,7 @@ class Officing::RecountsController < Officing::BaseController end private + def load_poll @poll = Poll.find(params[:poll_id]) end diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index ab6bedd6e..cd2efac6b 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -23,6 +23,6 @@ class StatsController < ApplicationController private def daily_cache(key, &block) - Rails.cache.fetch("public_stats/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &block) + Rails.cache.fetch("public_stats/#{Time.current.strftime('%Y-%m-%d')}/#{key}", &block) end end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index cbe43390b..ef1ef31de 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -30,7 +30,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController identity = Identity.first_or_create_from_oauth(auth) @user = current_user || identity.user || User.first_or_initialize_for_oauth(auth) - if save_user(@user) + if save_user identity.update(user: @user) sign_in_and_redirect @user, event: :authentication set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format? @@ -40,8 +40,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController end end - def save_user(user) + def save_user @user.save || @user.save_requiring_finish_signup end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9bd98aedd..07ff645e6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,6 +10,7 @@ class UsersController < ApplicationController end private + def set_activity_counts @activity_counts = HashWithIndifferentAccess.new( proposals: Proposal.where(author_id: @user.id).count, diff --git a/app/helpers/ballots_helper.rb b/app/helpers/ballots_helper.rb index ece1be9fa..8bdc5f231 100644 --- a/app/helpers/ballots_helper.rb +++ b/app/helpers/ballots_helper.rb @@ -1,7 +1,7 @@ module BallotsHelper def progress_bar_width(amount_available, amount_spent) - (amount_spent/amount_available.to_f * 100).to_s + "%" + (amount_spent / amount_available.to_f * 100).to_s + "%" end end \ No newline at end of file diff --git a/app/helpers/cache_keys_helper.rb b/app/helpers/cache_keys_helper.rb index 566b3cd81..75fc4a0ea 100644 --- a/app/helpers/cache_keys_helper.rb +++ b/app/helpers/cache_keys_helper.rb @@ -1,11 +1,11 @@ module CacheKeysHelper - def locale_and_user_status(authorable=nil) + def locale_and_user_status(authorable = nil) @cache_key_user ||= calculate_user_status(authorable) "#{I18n.locale}/#{@cache_key_user}" end - def calculate_user_status(authorable=nil) + def calculate_user_status(authorable = nil) user_status = "user" if user_signed_in? diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index cb077ef36..1034a7a59 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -11,7 +11,7 @@ module EmbedVideosHelper if server == "Vimeo" reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ - src = "https://player.vimeo.com/video/" + src = "https://player.vimeo.com/video/" elsif server == "YouTube" reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ src = "https://www.youtube.com/embed/" diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index f5bdb26ea..8ee97cf52 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -13,7 +13,7 @@ module OfficingHelper officer_assignments.each do |oa| options << [oa.booth_assignment.booth.name.to_s, oa.id] end - options.sort! {|x, y| x[0]<=>y[0]} + options.sort! {|x, y| x[0] <=> y[0]} options_for_select(options, params[:oa]) end diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb index c47402163..60e3da6d7 100644 --- a/app/helpers/poll_recounts_helper.rb +++ b/app/helpers/poll_recounts_helper.rb @@ -9,7 +9,7 @@ module PollRecountsHelper end def booth_assignment_sum_final_recounts(ba) - ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) :nil + ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil end end \ No newline at end of file diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 578cd1d8e..37425d573 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -18,7 +18,7 @@ module ProposalsHelper end end - def namespaced_proposal_path(proposal, options={}) + def namespaced_proposal_path(proposal, options = {}) @namespace_proposal_path ||= namespace case @namespace_proposal_path when "management" diff --git a/app/helpers/spending_proposals_helper.rb b/app/helpers/spending_proposals_helper.rb index 26026952f..81d16e5fd 100644 --- a/app/helpers/spending_proposals_helper.rb +++ b/app/helpers/spending_proposals_helper.rb @@ -4,7 +4,7 @@ module SpendingProposalsHelper ActsAsTaggableOn::Tag.spending_proposal_tags.pluck(:name) end - def namespaced_spending_proposal_path(spending_proposal, options={}) + def namespaced_spending_proposal_path(spending_proposal, options = {}) @namespace_spending_proposal_path ||= namespace case @namespace_spending_proposal_path when "management" diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index d8eff0ac2..19b54a5a2 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -1,27 +1,27 @@ module StatsHelper - def events_chart_tag(events, opt={}) + def events_chart_tag(events, opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(events: events) content_tag :div, "", opt end - def visits_chart_tag(opt={}) + def visits_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(visits: true) content_tag :div, "", opt end - def spending_proposals_chart_tag(opt={}) + def spending_proposals_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) content_tag :div, "", opt end - def budget_investments_chart_tag(opt={}) + def budget_investments_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(budget_investments: true) diff --git a/app/helpers/tracks_helper.rb b/app/helpers/tracks_helper.rb index 557d71802..0d6793e08 100644 --- a/app/helpers/tracks_helper.rb +++ b/app/helpers/tracks_helper.rb @@ -1,6 +1,6 @@ module TracksHelper - def track_event(data={}) + def track_event(data = {}) track_data = "" prefix = " data-track-event-" data.each do |key, value| diff --git a/app/helpers/valuation_helper.rb b/app/helpers/valuation_helper.rb index ded5fa0ed..4913b3d00 100644 --- a/app/helpers/valuation_helper.rb +++ b/app/helpers/valuation_helper.rb @@ -1,6 +1,6 @@ module ValuationHelper - def valuator_select_options(valuator=nil) + def valuator_select_options(valuator = nil) if valuator.present? Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }.prepend([valuator.description_or_email, valuator.id]) else diff --git a/app/helpers/verification_helper.rb b/app/helpers/verification_helper.rb index 62be1a5a8..44f921264 100644 --- a/app/helpers/verification_helper.rb +++ b/app/helpers/verification_helper.rb @@ -18,7 +18,7 @@ module VerificationHelper data_to_mask = match[2] email_provider = match[3] - data_to_display + "*"*data_to_mask.size + "@" + email_provider + data_to_display + "*" * data_to_mask.size + "@" + email_provider end end diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index 6c053cb52..a914477fe 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -5,7 +5,7 @@ class DeviseMailer < Devise::Mailer protected - def devise_mail(record, action, opts={}) + def devise_mail(record, action, opts = {}) I18n.with_locale record.locale do super(record, action, opts) end diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 1aba9dd7c..9d779299d 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -44,7 +44,7 @@ module Abilities can [:read, :update, :valuate, :destroy, :summary], SpendingProposal - can [:index, :read, :new, :create, :update, :destroy], Budget + can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading can [:hide, :update, :toggle_selection], Budget::Investment diff --git a/app/models/activity.rb b/app/models/activity.rb index 0fc35ad11..58a91cd18 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -2,7 +2,7 @@ class Activity < ActiveRecord::Base belongs_to :actionable, -> { with_hidden }, polymorphic: true belongs_to :user, -> { with_hidden } - VALID_ACTIONS = %w( hide block restore valuate ) + VALID_ACTIONS = %w(hide block restore valuate) validates :action, inclusion: {in: VALID_ACTIONS} diff --git a/app/models/ahoy/data_source.rb b/app/models/ahoy/data_source.rb index 2d52063bb..5c69af755 100644 --- a/app/models/ahoy/data_source.rb +++ b/app/models/ahoy/data_source.rb @@ -10,7 +10,7 @@ module Ahoy # chart def add(name, collection) collections.push data: collection, name: name - collection.each{ |k,v| add_key k } + collection.each{ |k, v| add_key k } end def build diff --git a/app/models/banner.rb b/app/models/banner.rb index c4f2295e6..2764785d1 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -12,9 +12,8 @@ class Banner < ActiveRecord::Base validates :post_started_at, presence: true validates :post_ended_at, presence: true - scope :with_active, -> {where("post_started_at <= ?", Time.current). - where("post_ended_at >= ?", Time.current) } + scope :with_active, -> { where("post_started_at <= ?", Time.current).where("post_ended_at >= ?", Time.current) } - scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } + scope :with_inactive, -> { where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } end diff --git a/app/models/budget.rb b/app/models/budget.rb index a5932921c..bc7231f29 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -67,8 +67,12 @@ class Budget < ActiveRecord::Base phase == "finished" end + def balloting_process? + balloting? || reviewing_ballots? + end + def balloting_or_later? - balloting? || reviewing_ballots? || finished? + balloting_process? || finished? end def on_hold? diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index b3b51996c..7ba0548e2 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -20,13 +20,14 @@ class Budget has_many :valuator_assignments, dependent: :destroy has_many :valuators, through: :valuator_assignments has_many :comments, as: :commentable + has_many :milestones validates :title, presence: true validates :author, presence: true validates :description, presence: true validates :heading_id, presence: true - validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? - validates_presence_of :price, if: :price_required? + validates :unfeasibility_explanation, presence: { if: :unfeasibility_explanation_required? } + validates :price, presence: { if: :price_required? } validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length } @@ -204,8 +205,8 @@ class Budget end def should_show_aside? - (budget.selecting? && !unfeasible?) || - (budget.balloting? && feasible?) || + (budget.selecting? && !unfeasible?) || + (budget.balloting? && feasible?) || (budget.valuating? && !unfeasible?) end diff --git a/app/models/budget/investment/milestone.rb b/app/models/budget/investment/milestone.rb new file mode 100644 index 000000000..9ecbe4dc3 --- /dev/null +++ b/app/models/budget/investment/milestone.rb @@ -0,0 +1,14 @@ +class Budget + class Investment + class Milestone < ActiveRecord::Base + belongs_to :investment + + validates :title, presence: true + validates :investment, presence: true + + def self.title_max_length + 80 + end + end + end +end diff --git a/app/models/budget/result.rb b/app/models/budget/result.rb index f29bc72cc..f835bce0c 100644 --- a/app/models/budget/result.rb +++ b/app/models/budget/result.rb @@ -12,11 +12,10 @@ class Budget reset_winners investments.each do |investment| @current_investment = investment - if inside_budget? - set_winner - end + set_winner if inside_budget? end end + handle_asynchronously :calculate_winners def investments heading.investments.selected.sort_by_ballots @@ -52,4 +51,4 @@ class Budget end end -end \ No newline at end of file +end diff --git a/app/models/comment.rb b/app/models/comment.rb index ffa02d09c..5c7f4dd4e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base validates :body, presence: true validates :user, presence: true - validates_inclusion_of :commentable_type, in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] + validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] } validate :validate_body_length @@ -44,7 +44,7 @@ class Comment < ActiveRecord::Base after_create :call_after_commented - def self.build(commentable, user, body, p_id=nil) + def self.build(commentable, user, body, p_id = nil) new commentable: commentable, user_id: user.id, body: body, @@ -64,7 +64,7 @@ class Comment < ActiveRecord::Base end def author=(author) - self.user= author + self.user = author end def total_votes diff --git a/app/models/concerns/conflictable.rb b/app/models/concerns/conflictable.rb index a1926aa36..b362ef1d1 100644 --- a/app/models/concerns/conflictable.rb +++ b/app/models/concerns/conflictable.rb @@ -3,7 +3,7 @@ module Conflictable def conflictive? return false unless flags_count > 0 && cached_votes_up > 0 - cached_votes_up/flags_count.to_f < 5 + cached_votes_up / flags_count.to_f < 5 end end diff --git a/app/models/concerns/filterable.rb b/app/models/concerns/filterable.rb index 68e844782..c5402d9b2 100644 --- a/app/models/concerns/filterable.rb +++ b/app/models/concerns/filterable.rb @@ -2,8 +2,8 @@ module Filterable extend ActiveSupport::Concern included do - scope :by_official_level, -> (official_level) { where(users: { official_level: official_level }).joins(:author) } - scope :by_date_range, -> (date_range) { where(created_at: date_range) } + scope :by_official_level, ->(official_level) { where(users: { official_level: official_level }).joins(:author) } + scope :by_date_range, ->(date_range) { where(created_at: date_range) } end class_methods do diff --git a/app/models/concerns/search_cache.rb b/app/models/concerns/search_cache.rb index a5b7acb5f..cf4d04f16 100644 --- a/app/models/concerns/search_cache.rb +++ b/app/models/concerns/search_cache.rb @@ -14,7 +14,7 @@ module SearchCache def searchable_values_sql searchable_values - .select{ |k,_| k.present? } + .select{ |k, _| k.present? } .collect{ |value, weight| set_tsvector(value, weight) } .join(" || ") end diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/taggable.rb index 9126e271a..57a30414d 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/taggable.rb @@ -9,7 +9,7 @@ module Taggable def tag_list_with_limit(limit = nil) return tags if limit.blank? - tags.sort{|a,b| b.taggings_count <=> a.taggings_count}[0, limit] + tags.sort{|a, b| b.taggings_count <=> a.taggings_count}[0, limit] end def tags_count_out_of_limit(limit = nil) diff --git a/app/models/concerns/verification.rb b/app/models/concerns/verification.rb index 4eb933204..88458a03d 100644 --- a/app/models/concerns/verification.rb +++ b/app/models/concerns/verification.rb @@ -47,7 +47,7 @@ module Verification end def failed_residence_verification? - !residence_verified? && failed_census_calls.size > 0 + !residence_verified? && !failed_census_calls.empty? end def no_phone_available? diff --git a/app/models/flag.rb b/app/models/flag.rb index 735ef89e9..824175b07 100644 --- a/app/models/flag.rb +++ b/app/models/flag.rb @@ -23,7 +23,7 @@ class Flag < ActiveRecord::Base def self.flagged?(user, flaggable) return false unless user - !! by_user_and_flaggable(user, flaggable).try(:first) + !!by_user_and_flaggable(user, flaggable).try(:first) end end diff --git a/app/models/geozone.rb b/app/models/geozone.rb index ad0fe9cd5..a52ab5d15 100644 --- a/app/models/geozone.rb +++ b/app/models/geozone.rb @@ -1,7 +1,7 @@ class Geozone < ActiveRecord::Base include Graphqlable - + has_many :proposals has_many :spending_proposals has_many :debates diff --git a/app/models/legislation/annotation.rb b/app/models/legislation/annotation.rb index 92fa9dd86..f2d419200 100644 --- a/app/models/legislation/annotation.rb +++ b/app/models/legislation/annotation.rb @@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base selector_end = "/html/body/#{range_end}" el_end = doc.at_xpath(selector_end) - remainder_el_start = el_start.text[0 .. range_start_offset-1] unless range_start_offset.zero? + remainder_el_start = el_start.text[0 .. range_start_offset - 1] unless range_start_offset.zero? remainder_el_end = el_end.text[range_end_offset .. -1] self.context = "#{remainder_el_start}#{quote}#{remainder_el_end}" diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 92333cc80..63250d041 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -6,14 +6,14 @@ class Officing::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :year_of_birth + validates :document_number, presence: true + validates :document_type, presence: true + validates :year_of_birth, presence: true validate :allowed_age validate :residence_in_madrid - def initialize(attrs={}) + def initialize(attrs = {}) super clean_document_number end diff --git a/app/models/organization.rb b/app/models/organization.rb index 94ef986a1..f3f8956d5 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,7 +1,7 @@ class Organization < ActiveRecord::Base include Graphqlable - + belongs_to :user, touch: true validates :name, presence: true diff --git a/app/models/proposal.rb b/app/models/proposal.rb index f37dff3d5..926cbe1ee 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -39,7 +39,7 @@ class Proposal < 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) } @@ -128,7 +128,7 @@ class Proposal < ActiveRecord::Base end def code - "#{Setting["proposal_code_prefix"]}-#{created_at.strftime('%Y-%m')}-#{id}" + "#{Setting['proposal_code_prefix']}-#{created_at.strftime('%Y-%m')}-#{id}" end def after_commented diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index 223e9adfe..b08d7533a 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -15,7 +15,7 @@ class SpendingProposal < ActiveRecord::Base validates :title, presence: true validates :author, presence: true validates :description, presence: true - validates_presence_of :feasible_explanation, if: :feasible_explanation_required? + validates :feasible_explanation, presence: { if: :feasible_explanation_required? } validates :title, length: { in: 4..SpendingProposal.title_max_length } validates :description, length: { maximum: SpendingProposal.description_max_length } @@ -31,9 +31,9 @@ class SpendingProposal < ActiveRecord::Base scope :not_unfeasible, -> { where("feasible IS ? OR feasible = ?", nil, true) } scope :with_supports, -> { where('cached_votes_up > 0') } - scope :by_admin, -> (admin) { where(administrator_id: admin.presence) } - scope :by_tag, -> (tag_name) { tagged_with(tag_name) } - scope :by_valuator, -> (valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } + scope :by_admin, ->(admin) { where(administrator_id: admin.presence) } + scope :by_tag, ->(tag_name) { tagged_with(tag_name) } + scope :by_valuator, ->(valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } scope :for_render, -> { includes(:geozone) } @@ -44,7 +44,7 @@ class SpendingProposal < ActiveRecord::Base end def self.filter_params(params) - params.select{|x,_| %w{geozone_id administrator_id tag_name valuator_id}.include? x.to_s } + params.select{|x, _| %w{geozone_id administrator_id tag_name valuator_id}.include? x.to_s } end def self.scoped_filter(params, current_filter) diff --git a/app/models/tag_cloud.rb b/app/models/tag_cloud.rb index 107ecbf1a..b0882af82 100644 --- a/app/models/tag_cloud.rb +++ b/app/models/tag_cloud.rb @@ -2,7 +2,7 @@ class TagCloud attr_accessor :resource_model, :scope - def initialize(resource_model, scope=nil) + def initialize(resource_model, scope = nil) @resource_model = resource_model @scope = scope end diff --git a/app/models/user.rb b/app/models/user.rb index 219671349..9df08c014 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,7 +56,7 @@ class User < ActiveRecord::Base scope :officials, -> { where("official_level > 0") } scope :newsletter, -> { where(newsletter: true) } scope :for_render, -> { includes(:organization) } - scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) } + scope :by_document, ->(document_type, document_number) { where(document_type: document_type, document_number: document_number) } scope :email_digest, -> { where(email_digest: true) } scope :active, -> { where(erased_at: nil) } scope :erased, -> { where.not(erased_at: nil) } @@ -74,7 +74,7 @@ class User < ActiveRecord::Base username: auth.info.name || auth.uid, email: oauth_email, oauth_email: oauth_email, - password: Devise.friendly_token[0,20], + password: Devise.friendly_token[0, 20], terms_of_service: '1', confirmed_at: oauth_email_confirmed ? DateTime.current : nil ) @@ -156,7 +156,7 @@ class User < ActiveRecord::Base def has_official_email? domain = Setting['email_domain_for_officials'] - email.present? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") ) + email.present? && ((email.end_with? "@#{domain}") || (email.end_with? ".#{domain}")) end def display_official_position_badge? diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index bafff129b..00f729d2c 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -7,17 +7,17 @@ class Verification::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :date_of_birth - validates_presence_of :postal_code + validates :document_number, presence: true + validates :document_type, presence: true + validates :date_of_birth, presence: true + validates :postal_code, presence: true validates :terms_of_service, acceptance: { allow_nil: false } validates :postal_code, length: { is: 5 } validate :allowed_age validate :document_number_uniqueness - def initialize(attrs={}) + def initialize(attrs = {}) self.date_of_birth = parse_date('date_of_birth', attrs) attrs = remove_date('date_of_birth', attrs) super diff --git a/app/models/verification/sms.rb b/app/models/verification/sms.rb index 1a013f1d8..7c1a1bfa6 100644 --- a/app/models/verification/sms.rb +++ b/app/models/verification/sms.rb @@ -3,7 +3,7 @@ class Verification::Sms attr_accessor :user, :phone, :confirmation_code - validates_presence_of :phone + validates :phone, presence: true validates :phone, format: { with: /\A[\d \+]+\z/ } validate :uniqness_phone diff --git a/app/models/verified_user.rb b/app/models/verified_user.rb index b0c5afd0c..6b0ddb822 100644 --- a/app/models/verified_user.rb +++ b/app/models/verified_user.rb @@ -1,8 +1,8 @@ class VerifiedUser < ActiveRecord::Base - scope :by_user, -> (user) { where(document_number: user.document_number) } + scope :by_user, ->(user) { where(document_number: user.document_number) } - scope :by_email, -> (email) { where(email: email) } - scope :by_phone, -> (phone) { where(phone: phone) } + scope :by_email, ->(email) { where(email: email) } + scope :by_phone, ->(phone) { where(phone: phone) } def self.phone?(user) by_user(user).by_phone(user.unconfirmed_phone).first.present? diff --git a/app/views/admin/budget_investment_milestones/_form.html.erb b/app/views/admin/budget_investment_milestones/_form.html.erb new file mode 100644 index 000000000..95237c2ca --- /dev/null +++ b/app/views/admin/budget_investment_milestones/_form.html.erb @@ -0,0 +1,7 @@ +<%= form_for [:admin, @investment.budget, @investment, @milestone] do |f| %> + + <%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %> + <%= f.text_area :description, rows: 5 %> + + <%= f.submit nil, class: "button success" %> +<% end %> diff --git a/app/views/admin/budget_investment_milestones/edit.html.erb b/app/views/admin/budget_investment_milestones/edit.html.erb new file mode 100644 index 000000000..c72cd840a --- /dev/null +++ b/app/views/admin/budget_investment_milestones/edit.html.erb @@ -0,0 +1,5 @@ +<%= back_link_to admin_budget_budget_investment_path(@investment.budget, @investment) %> + +
| <%= t("admin.milestones.index.table_id") %> | +<%= t("admin.milestones.index.table_title") %> | +<%= t("admin.milestones.index.table_description") %> | +<%= t("admin.milestones.index.table_actions") %> | +
|---|---|---|---|
| + <%= milestone.id %> + | ++ <%= link_to milestone.title, edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone) %> + | ++ <%= milestone.description %> + | ++ <%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone), + method: :delete, + class: 'button hollow alert expanded' %> + | +
+ <%= t('admin.milestones.index.no_milestones') %> +
+<% end %> diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb index a58110c94..f220c0955 100644 --- a/app/views/admin/budget_investments/show.html.erb +++ b/app/views/admin/budget_investments/show.html.erb @@ -47,3 +47,12 @@ <%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %> ++ <%= link_to t("admin.budget_investments.show.new_milestone"), new_admin_budget_budget_investment_budget_investment_milestone_path(@budget, @investment) %> +
diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index 5d323b45c..58a56d564 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -16,5 +16,15 @@ <%= f.select :currency_symbol, budget_currency_symbol_select_options %> - <%= f.submit nil, class: "button success" %> +<%= t("admin.questions.new.valid_answers_note") %>
- <%= f.text_field :valid_answers, label: false %> +<%= t("admin.questions.new.valid_answers_note") %>
+ <%= f.text_field :valid_answers, label: false, aria: {describedby: "valid-answers-help-text"} %><%= t("admin.signature_sheets.new.document_numbers_note") %>
- <%= f.text_area :document_numbers, rows: "6", label: false %> +<%= t("admin.signature_sheets.new.document_numbers_note") %>
+ <%= f.text_area :document_numbers, rows: "6", label: false, aria: {describedby: "document-numbers-help-text"} %> <%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %> <% end %> \ No newline at end of file diff --git a/app/views/budgets/investments/_filter_subnav.html.erb b/app/views/budgets/investments/_filter_subnav.html.erb new file mode 100644 index 000000000..a46c33b2d --- /dev/null +++ b/app/views/budgets/investments/_filter_subnav.html.erb @@ -0,0 +1,22 @@ +<%= t("budgets.investments.form.tags_instructions") %>
+<%= t("budgets.investments.form.tags_instructions") %>
diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb new file mode 100644 index 000000000..87cd1cdd6 --- /dev/null +++ b/app/views/budgets/investments/_milestones.html.erb @@ -0,0 +1,26 @@ +<%= milestone.description %>
+<%= t('management.user_invites.new.info') %>
- <%= text_area_tag "emails", nil, rows: 5, placeholder: t('management.user_invites.new.info') %> +<%= t('management.user_invites.new.info') %>
+ <%= text_area_tag "emails", nil, rows: 5, + placeholder: t('management.user_invites.new.info'), + aria: {describedby: "emails-help-text"} %><%= t("devise_views.organizations.registrations.new.responsible_name_note") %>
- <%= fo.text_field :responsible_name, placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), maxlength: Organization.responsible_name_max_length, label: false %> +<%= t("devise_views.organizations.registrations.new.responsible_name_note") %>
+ <%= fo.text_field :responsible_name, placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), + maxlength: Organization.responsible_name_max_length, label: false, + aria: {describedby: "responsible-name-help-text"} %> <% end %> <%= f.email_field :email, placeholder: t("devise_views.organizations.registrations.new.email_label") %> diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 3eda38cd1..232f65ac1 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -12,17 +12,21 @@<%= t("proposals.form.proposal_question_example_html") %> -
- <%= f.text_field :question, maxlength: Proposal.question_max_length, placeholder: t("proposals.form.proposal_question"), label: false %> + + <%= f.text_field :question, maxlength: Proposal.question_max_length, + placeholder: t("proposals.form.proposal_question"), + label: false, + aria: {describedby: "question-help-text"} %><%= t("proposals.form.proposal_summary_note") %>
+<%= t("proposals.form.proposal_summary_note") %>
<%= f.text_area :summary, rows: 4, maxlength: 200, label: false, - placeholder: t('proposals.form.proposal_summary') %> + placeholder: t('proposals.form.proposal_summary'), + aria: {describedby: "summary-help-text"} %><%= t("proposals.form.proposal_video_url_note") %>
- <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false %> +<%= t("proposals.form.proposal_video_url_note") %>
+ <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, + aria: {describedby: "video-url-help-text"} %><%= t("proposals.form.tags_instructions") %>
+<%= t("proposals.form.tags_instructions") %>
<% if current_user.unverified? %><%= t("proposals.form.proposal_responsible_name_note") %>
- <%= f.text_field :responsible_name, placeholder: t("proposals.form.proposal_responsible_name"), label: false %> +<%= t("proposals.form.proposal_responsible_name_note") %>
+ <%= f.text_field :responsible_name, placeholder: t("proposals.form.proposal_responsible_name"), label: false, + aria: {describedby: "responsible-name-help-text"} %>- <%= t("shared.suggest.#{resource_name}.found", - count: @resources.count, - query: @search_terms)%> +
+ + <%= t("shared.suggest.#{resource_name}.found", + count: @resources.count, + query: @search_terms)%> +
- <%= t("shared.suggest.#{resource_name}.message", - count: @resources.count, - query: @search_terms, - limit: @limit) %> +
+ + <%= t("shared.suggest.#{resource_name}.message", + count: @resources.count, + query: @search_terms, + limit: @limit) %> + <%= link_to t("shared.suggest.#{resource_name}.see_all"), polymorphic_url(resource_model, search: @search_terms)%>
@@ -26,4 +30,4 @@<%= t("devise_views.users.registrations.edit.leave_blank") %>
- <%= f.password_field :password, autocomplete: "off", label: false, placeholder: t("devise_views.users.registrations.edit.password_label") %> +<%= t("devise_views.users.registrations.edit.leave_blank") %>
+ <%= f.password_field :password, autocomplete: "off", label: false, + placeholder: t("devise_views.users.registrations.edit.password_label"), + aria: {describedby: "password-help-text"} %><%= t("devise_views.users.registrations.edit.need_current") %>
- <%= f.password_field :current_password, label: false, autocomplete: "off", placeholder: t("devise_views.users.registrations.edit.current_password_label") %> +<%= t("devise_views.users.registrations.edit.need_current") %>
+ <%= f.password_field :current_password, label: false, autocomplete: "off", + placeholder: t("devise_views.users.registrations.edit.current_password_label"), + aria: {describedby: "current-password-help-text"} %><%= t("devise_views.users.registrations.new.username_note") %>
- <%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, placeholder: t("devise_views.users.registrations.new.username_label"), label: false %> +<%= t("devise_views.users.registrations.new.username_note") %>
+ <%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, + placeholder: t("devise_views.users.registrations.new.username_label"), + label: false, + aria: {describedby: "username-help-text"} %> <%= f.invisible_captcha :family_name %> diff --git a/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb index 703e4b98f..2159d1a01 100644 --- a/app/views/verification/residence/new.html.erb +++ b/app/views/verification/residence/new.html.erb @@ -76,9 +76,9 @@<%= t("verification.residence.new.postal_code_note") %>
+<%= t("verification.residence.new.postal_code_note") %>
<%= t("verification.sms.new.phone_note") %>
- <%= f.text_field :phone, label: false, placeholder: t("verification.sms.new.phone_placeholder") %> +<%= t("verification.sms.new.phone_note") %>
+ <%= f.text_field :phone, label: false, + placeholder: t("verification.sms.new.phone_placeholder"), + aria: {describedby: "phone-help-text"} %>
- <%= comment_tree_title_text(commentable) %> - (<%= commentable.comments_count %>) -
+ <% if display_comments_count %> ++ <%= comment_tree_title_text(commentable) %> + (<%= commentable.comments_count %>) +
+ <% end %> <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index c88045f26..96a5337ca 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -17,11 +17,12 @@<%= t("debates.form.tags_instructions") %>
+<%= t("debates.form.tags_instructions") %>
<%= f.text_field :tag_list, value: @debate.tag_list.to_s, label: false, - placeholder: t("debates.form.tags_placeholder") %> + placeholder: t("debates.form.tags_placeholder"), + aria: {describedby: "tag-list-help-text"} %>