From 4c225aac62c52c09b178f8fbdd8f1461398a9b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Mon, 11 Sep 2017 14:39:58 +0200 Subject: [PATCH 01/33] Remove document cached_attachment value after destroy_upload action. --- app/controllers/documents_controller.rb | 1 + spec/shared/features/documentable.rb | 35 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index ceb7d191f..7e00a99e5 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -48,6 +48,7 @@ class DocumentsController < ApplicationController def destroy_upload @document = Document.new(cached_attachment: params[:path]) @document.set_attachment_from_cached_attachment + @document.cached_attachment = nil @document.documentable = @documentable if @document.attachment.destroy diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb index b8b5ebe1c..80da9499b 100644 --- a/spec/shared/features/documentable.rb +++ b/spec/shared/features/documentable.rb @@ -251,6 +251,41 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path, expect(find("input[name='document[cached_attachment]']", visible: false).value).to include("empty.pdf") end + scenario "Should not show 'Choose document' button after valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + + expect(page).not_to have_content "Choose document" + end + + scenario "Should show 'Remove document' button after valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + + expect(page).to have_link("Remove document") + end + + scenario "Should show 'Choose document' button after remove valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + click_link "Remove document" + sleep 1 + + expect(page).to have_content "Choose document" + end + scenario "Should not update document cached_attachment field after unvalid file upload", :js do login_as documentable.author visit new_document_path(documentable_type: documentable.class.name, From 78c231bef61a1bb66f0704d4b43bf4b79aae0735 Mon Sep 17 00:00:00 2001 From: iagirre Date: Wed, 13 Sep 2017 17:34:58 +0200 Subject: [PATCH 02/33] Added db/schema after migration --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index ba856107c..0b3c30a99 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -974,7 +974,7 @@ ActiveRecord::Schema.define(version: 20170908175149) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2017-09-06 18:19:39', null: false + t.datetime "password_changed_at", default: '2017-06-22 11:21:30', null: false t.boolean "created_from_signature", default: false t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" From 2c2646d0a76a56123e620a23740c9b3f350f6e74 Mon Sep 17 00:00:00 2001 From: Manuel Lucena Date: Wed, 13 Sep 2017 17:40:55 +0200 Subject: [PATCH 03/33] =?UTF-8?q?20170912=20-=20Disabled=20user=20question?= =?UTF-8?q?s=20for=20polls=20into=20budgets=20view.=20=20=E2=80=A6=20=20Co?= =?UTF-8?q?mmitter:=20Manuel=20Lucena=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On branch mlucena-admin-menu Changes to be committed: modified: app/views/admin/_menu.html.erb --- app/views/admin/_menu.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index e629f5807..ce7c6357c 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -65,7 +65,7 @@ <%= link_to t('admin.menu.polls'), admin_polls_path %> -
  • > +
  • > <%= link_to t("admin.menu.poll_questions"), admin_questions_path %>
  • From e4e78c8f166f92c3dd8671ffb2a93c8172117c00 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 13:18:37 +0200 Subject: [PATCH 04/33] Rubocop autocorrections --- Gemfile | 2 +- app/controllers/admin/poll/shifts_controller.rb | 2 +- app/controllers/communities_controller.rb | 2 +- app/controllers/documents_controller.rb | 6 +++--- app/controllers/proposals_controller.rb | 2 +- app/helpers/documentables_helper.rb | 4 ++-- app/helpers/documents_helper.rb | 8 ++++---- app/models/community.rb | 2 +- app/models/concerns/documentable.rb | 2 +- app/models/document.rb | 4 ++-- app/models/poll/booth.rb | 2 +- app/models/poll/shift.rb | 8 ++++---- app/models/topic.rb | 2 +- app/models/user.rb | 6 +++--- spec/features/admin/poll/booths_spec.rb | 6 +++--- spec/features/admin/poll/shifts_spec.rb | 14 +++++++------- spec/features/budgets/investments_spec.rb | 2 +- spec/features/comments/debates_spec.rb | 2 +- spec/features/proposals_spec.rb | 2 +- spec/lib/tasks/communities_spec.rb | 2 +- spec/models/poll/booth_spec.rb | 8 ++++---- spec/models/poll/shift_spec.rb | 12 ++++++------ spec/models/topic_spec.rb | 1 - spec/shared/features/documentable.rb | 2 +- spec/shared/features/nested_documentable.rb | 6 ++---- 25 files changed, 53 insertions(+), 56 deletions(-) diff --git a/Gemfile b/Gemfile index 3f17d753b..a6c1dc71e 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,7 @@ gem 'graphql', '~> 1.6.3' gem 'groupdate', '~> 3.2.0' gem 'initialjs-rails', '~> 0.2.0.5' gem 'invisible_captcha', '~> 0.9.2' +gem 'jquery-fileupload-rails' gem 'jquery-rails', '~> 4.3.1' gem 'jquery-ui-rails', '~> 6.0.1' gem 'kaminari', '~> 1.0.1' @@ -33,7 +34,6 @@ gem 'omniauth-facebook', '~> 4.0.0' gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'omniauth-twitter', '~> 1.4.0' gem 'paperclip', '~> 5.1.0' -gem 'jquery-fileupload-rails' gem 'paranoia', '~> 2.3.1' gem 'pg', '~> 0.21.0' gem 'pg_search', '~> 2.0.1' diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb index 168284474..4294045e5 100644 --- a/app/controllers/admin/poll/shifts_controller.rb +++ b/app/controllers/admin/poll/shifts_controller.rb @@ -1,5 +1,5 @@ class Admin::Poll::ShiftsController < Admin::BaseController - + before_action :load_booth before_action :load_polls before_action :load_officer diff --git a/app/controllers/communities_controller.rb b/app/controllers/communities_controller.rb index ff74f208b..f6f1e4816 100644 --- a/app/controllers/communities_controller.rb +++ b/app/controllers/communities_controller.rb @@ -7,7 +7,7 @@ class CommunitiesController < ApplicationController skip_authorization_check def show - redirect_to root_path unless Setting['feature.community'].present? + redirect_to root_path if Setting['feature.community'].blank? end private diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index ceb7d191f..a48f182ab 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -1,8 +1,8 @@ class DocumentsController < ApplicationController before_action :authenticate_user! - before_filter :find_documentable, except: :destroy - before_filter :prepare_new_document, only: [:new, :new_nested] - before_filter :prepare_document_for_creation, only: :create + before_action :find_documentable, except: :destroy + before_action :prepare_new_document, only: [:new, :new_nested] + before_action :prepare_document_for_creation, only: :create load_and_authorize_resource except: :upload skip_authorization_check only: :upload diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index cedc4e8ef..06e170ee2 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -78,7 +78,7 @@ class ProposalsController < ApplicationController def proposal_params params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, - documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id] ) + documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id]) end def retired_params diff --git a/app/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb index 4fd737908..a4a840785 100644 --- a/app/helpers/documentables_helper.rb +++ b/app/helpers/documentables_helper.rb @@ -18,8 +18,8 @@ module DocumentablesHelper def accepted_content_types_extensions(documentable_class) documentable_class.accepted_content_types - .collect{ |content_type| ".#{content_type.split("/").last}" } - .join(",") + .collect{ |content_type| ".#{content_type.split('/').last}" } + .join(",") end def humanized_accepted_content_types(documentable) diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index 17d70068b..a8ae6c973 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -80,10 +80,10 @@ module DocumentsHelper def document_direct_upload_url(document) upload_documents_url( - documentable_type: document.documentable_type, - documentable_id: document.documentable_id, - format: :js - ) + documentable_type: document.documentable_type, + documentable_id: document.documentable_id, + format: :js + ) end end diff --git a/app/models/community.rb b/app/models/community.rb index 3fa1cebaa..7d7073412 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -11,7 +11,7 @@ class Community < ActiveRecord::Base end def from_proposal? - self.proposal.present? + proposal.present? end private diff --git a/app/models/concerns/documentable.rb b/app/models/concerns/documentable.rb index 4aeaf6eab..729a0b0f8 100644 --- a/app/models/concerns/documentable.rb +++ b/app/models/concerns/documentable.rb @@ -10,7 +10,7 @@ module Documentable private - def documentable(options= {}) + def documentable(options = {}) @max_documents_allowed = options[:max_documents_allowed] @max_file_size = options[:max_file_size] @accepted_content_types = options[:accepted_content_types] diff --git a/app/models/document.rb b/app/models/document.rb index 7fd82ea33..3556d4c0a 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -40,7 +40,7 @@ class Document < ActiveRecord::Base attachment.instance.prefix(attachment, style) end - def prefix(attachment, style) + def prefix(attachment, _style) if !attachment.instance.persisted? "cached_attachments/user/#{attachment.instance.user_id}" else @@ -75,7 +75,7 @@ class Document < ActiveRecord::Base end def remove_cached_document - File.delete(cached_attachment) if File.exists?(cached_attachment) + File.delete(cached_attachment) if File.exist?(cached_attachment) end end diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index 0aca6eecb..04f9d3dea 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -5,7 +5,7 @@ class Poll has_many :shifts validates :name, presence: true, uniqueness: true - + def self.search(terms) return Booth.none if terms.blank? Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%") diff --git a/app/models/poll/shift.rb b/app/models/poll/shift.rb index cc6a43425..37a8658f3 100644 --- a/app/models/poll/shift.rb +++ b/app/models/poll/shift.rb @@ -1,13 +1,13 @@ class Poll class Shift < ActiveRecord::Base - belongs_to :booth - belongs_to :officer + belongs_to :booth + belongs_to :officer validates :booth_id, presence: true validates :officer_id, presence: true validates :date, presence: true validates :date, uniqueness: { scope: [:officer_id, :booth_id] } - + before_create :persist_data after_create :create_officer_assignments @@ -20,7 +20,7 @@ class Poll end end - def persist_data + def persist_data self.officer_name = officer.name self.officer_email = officer.email end diff --git a/app/models/topic.rb b/app/models/topic.rb index 34abed0e3..e0a73d58b 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -13,6 +13,6 @@ class Topic < ActiveRecord::Base scope :sort_by_newest, -> { order(created_at: :desc) } scope :sort_by_oldest, -> { order(created_at: :asc) } - scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } + scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } end diff --git a/app/models/user.rb b/app/models/user.rb index ef6ab7832..006d1a09e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,13 +57,13 @@ 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) } scope :public_for_api, -> { all } - scope :by_comments, -> (query, topics_ids) { joins(:comments).where(query, topics_ids).uniq } - scope :by_authors, -> (author_ids) { where("users.id IN (?)", author_ids) } + scope :by_comments, ->(query, topics_ids) { joins(:comments).where(query, topics_ids).uniq } + scope :by_authors, ->(author_ids) { where("users.id IN (?)", author_ids) } before_validation :clean_document_number diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index fd8fb9e84..13f3af2ff 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -44,13 +44,13 @@ feature 'Admin booths' do current_poll = create(:poll, :current) incoming_poll = create(:poll, :incoming) expired_poll = create(:poll, :expired) - + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) - + visit admin_root_path - + within('#side_menu') do click_link "Manage shifts" end diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 761a79536..65396267b 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -8,13 +8,13 @@ feature 'Admin shifts' do end scenario "Show" do - poll = create(:poll) + poll = create(:poll) officer = create(:poll_officer) booth1 = create(:poll_booth) booth2 = create(:poll_booth) - - shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today) + + shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today) shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Date.tomorrow) visit new_admin_booth_shift_path(booth1) @@ -36,7 +36,7 @@ feature 'Admin shifts' do officer = create(:poll_officer) visit admin_booths_path - + within("#booth_#{booth.id}") do click_link "Manage shifts" end @@ -47,7 +47,7 @@ feature 'Admin shifts' do select I18n.l(poll.starts_at.to_date, format: :long), from: 'shift_date' click_button "Add shift" - + expect(page).to have_content "Shift added" within("#shifts") do @@ -63,7 +63,7 @@ feature 'Admin shifts' do officer = create(:poll_officer) visit admin_booths_path - + within("#booth_#{booth.id}") do click_link "Manage shifts" end @@ -84,7 +84,7 @@ feature 'Admin shifts' do shift = create(:poll_shift, officer: officer, booth: booth) visit admin_booths_path - + within("#booth_#{booth.id}") do click_link "Manage shifts" end diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 4040717f1..820ebb520 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -341,7 +341,7 @@ feature 'Budget Investments' do scenario 'Can not access the community' do Setting['feature.community'] = false - + investment = create(:budget_investment, heading: heading) visit budget_investment_path(budget_id: budget.id, id: investment.id) expect(page).not_to have_content "Access the community" diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index 28166784a..77cab01d9 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -33,7 +33,7 @@ feature 'Commenting debates' do expect(page).to have_content second_child.body expect(page).to have_link "Go back to #{debate.title}", href: debate_path(debate) - + expect(page).to have_selector("ul#comment_#{parent_comment.id}>li", count: 2) expect(page).to have_selector("ul#comment_#{first_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index f9bef400c..a7c7880a8 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -102,7 +102,7 @@ feature 'Proposals' do scenario 'Can not access the community' do Setting['feature.community'] = false - + proposal = create(:proposal) visit proposal_path(proposal) expect(page).not_to have_content "Access the community" diff --git a/spec/lib/tasks/communities_spec.rb b/spec/lib/tasks/communities_spec.rb index 20c1af841..3a8819147 100644 --- a/spec/lib/tasks/communities_spec.rb +++ b/spec/lib/tasks/communities_spec.rb @@ -41,7 +41,7 @@ describe 'Communities Rake' do expect(investment.community).to be_present end - + end end diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index d340d8197..8c2729c79 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -25,20 +25,20 @@ describe :booth do end describe "#available" do - + it "returns booths associated to current or incoming polls" do booth_for_current_poll = create(:poll_booth) booth_for_incoming_poll = create(:poll_booth) booth_for_expired_poll = create(:poll_booth) - + current_poll = create(:poll, :current) incoming_poll = create(:poll, :incoming) expired_poll = create(:poll, :expired) - + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) - + expect(Poll::Booth.available).to include(booth_for_current_poll) expect(Poll::Booth.available).to include(booth_for_incoming_poll) expect(Poll::Booth.available).to_not include(booth_for_expired_poll) diff --git a/spec/models/poll/shift_spec.rb b/spec/models/poll/shift_spec.rb index 409e38f93..b7918b95c 100644 --- a/spec/models/poll/shift_spec.rb +++ b/spec/models/poll/shift_spec.rb @@ -43,7 +43,7 @@ describe :shift do officer_assignments = Poll::OfficerAssignment.all expect(officer_assignments.count).to eq(2) - + oa1 = officer_assignments.first oa2 = officer_assignments.second @@ -59,10 +59,10 @@ describe :shift do end describe "#persist_data" do - - let(:user) { create(:user, username: "Ana", email: "ana@example.com") } - let(:officer) { create(:poll_officer, user: user) } - let(:shift) { create(:poll_shift, officer: officer) } + + let(:user) { create(:user, username: "Ana", email: "ana@example.com") } + let(:officer) { create(:poll_officer, user: user) } + let(:shift) { create(:poll_shift, officer: officer) } it "should maintain officer data after destroying associated user" do shift.officer.user.destroy @@ -79,5 +79,5 @@ describe :shift do end end - + end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 9acc47633..5071439fa 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -71,5 +71,4 @@ describe Topic do end - end diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb index b8b5ebe1c..e9a82c63c 100644 --- a/spec/shared/features/documentable.rb +++ b/spec/shared/features/documentable.rb @@ -60,7 +60,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path, login_as(user) visit send(documentable_path, arguments) - click_link "Upload document" + click_link "Upload document" expect(page).to have_selector("h1", text: "Upload document") end diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index d03841d36..253deacda 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -11,10 +11,8 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum before do create(:administrator, user: administrator) - if documentable_path_arguments - documentable_path_arguments.each do |argument_name, path_to_value| + documentable_path_arguments&.each do |argument_name, path_to_value| arguments.merge!("#{argument_name}": documentable.send(path_to_value)) - end end end @@ -222,7 +220,7 @@ shared_examples "nested documentable" do |documentable_factory_name, path, docum send(fill_resource_method_name) if fill_resource_method_name documentable.class.max_documents_allowed.times.each do |index| - attach_new_file(documentable_factory_name, index , "spec/fixtures/files/empty.pdf") + attach_new_file(documentable_factory_name, index, "spec/fixtures/files/empty.pdf") end click_on submit_button From f1eb535bdec0abf628b72599cad1b606f6d1ade1 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 14 Sep 2017 16:54:49 +0200 Subject: [PATCH 05/33] The arrows of the datepicker for changing the month didn't appear. There was a link for it, but no icons. The CSS file "theme" from jquery-ui was missing. Cambios para hacer commit: modificado: app/assets/stylesheets/application.scss modificado: app/assets/stylesheets/datepicker_overrides.scss nuevo archivo: app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb --- app/assets/stylesheets/application.scss | 2 ++ app/assets/stylesheets/datepicker_overrides.scss | 5 ++++- app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 19c73de32..ea5a5d653 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -14,6 +14,8 @@ @import 'c3'; @import 'annotator.min'; @import 'annotator_overrides'; +@import 'jquery-ui/theme'; +@import 'jquery-ui-theme_overrides'; @import 'jquery-ui/datepicker'; @import 'datepicker_overrides'; @import 'documentable'; diff --git a/app/assets/stylesheets/datepicker_overrides.scss b/app/assets/stylesheets/datepicker_overrides.scss index d4c07802e..2e8518e6f 100644 --- a/app/assets/stylesheets/datepicker_overrides.scss +++ b/app/assets/stylesheets/datepicker_overrides.scss @@ -45,9 +45,12 @@ color: #fff; cursor: pointer; font-weight: normal; - font-size: $small-font-size; line-height: $line-height; top: 0; + position: absolute; + top: 2px; + width: 1.8em; + height: 1.8em; } table { diff --git a/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb b/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb new file mode 100644 index 000000000..c3d39a27c --- /dev/null +++ b/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb @@ -0,0 +1,6 @@ +//Overrides icon color for the jquery-ui theme + +.ui-icon, +.ui-widget-content .ui-icon { + background-image: url(<%= image_path("jquery-ui/ui-icons_ffffff_256x240.png") %>)/*{Make icons white}*/; +} \ No newline at end of file From a7e570ed248d20b900f53e1fb1ef83d76f6439d2 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 14 Sep 2017 17:09:02 +0200 Subject: [PATCH 06/33] Added new line at the end of the file. --- app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb b/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb index c3d39a27c..2da19413e 100644 --- a/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb +++ b/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb @@ -3,4 +3,4 @@ .ui-icon, .ui-widget-content .ui-icon { background-image: url(<%= image_path("jquery-ui/ui-icons_ffffff_256x240.png") %>)/*{Make icons white}*/; -} \ No newline at end of file +} From 0611e0f4eaacef3ef0b5cd87e73b33ec1b0ca598 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Thu, 14 Sep 2017 09:01:56 -0400 Subject: [PATCH 07/33] Validate presence of 'poll_id' attribute on Poll::Question model Fixes #1831 On branch aperez-validate-poll-question-is-selected Changes to be committed: modified: app/models/poll/question.rb modified: spec/models/poll/question_spec.rb modified: spec/features/admin/poll/polls_spec.rb --- app/models/poll/question.rb | 1 + spec/features/admin/poll/polls_spec.rb | 2 +- spec/models/poll/question_spec.rb | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 8e02dcfe2..a46f28a8c 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -20,6 +20,7 @@ class Poll::Question < ActiveRecord::Base validates :title, presence: true validates :author, presence: true + validates :poll_id, presence: true validates :title, length: { minimum: 4 } validates :description, length: { maximum: Poll::Question.description_max_length } diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index ee90d2ada..13ec0db58 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -183,7 +183,7 @@ feature 'Admin polls' do scenario 'Add question to poll', :js do poll = create(:poll) - question = create(:poll_question, poll: nil, title: 'Should we rebuild the city?') + question = create(:poll_question, title: 'Should we rebuild the city?') visit admin_poll_path(poll) diff --git a/spec/models/poll/question_spec.rb b/spec/models/poll/question_spec.rb index 057dfebca..db6a0f762 100644 --- a/spec/models/poll/question_spec.rb +++ b/spec/models/poll/question_spec.rb @@ -9,6 +9,20 @@ RSpec.describe Poll::Question, type: :model do end end + describe "#poll_question_id" do + it "should be invalid if a poll is not selected" do + q = create(:poll_question) + q.poll_id = nil + expect(q).to_not be_valid + end + + it "should be valid if a poll is selected" do + q = create(:poll_question) + q.poll_id = 1 + expect(q).to be_valid + end + end + describe "#copy_attributes_from_proposal" do it "copies the attributes from the proposal" do create_list(:geozone, 3) From 354d07c1a60d1478f901aa5deb9eb168a1766566 Mon Sep 17 00:00:00 2001 From: iagirre Date: Fri, 15 Sep 2017 10:02:18 +0200 Subject: [PATCH 08/33] Changes suggested in the PR https://github.com/consul/consul/pull/1869 made. Use the icons of consul instead of icons from jquery-ui. Cambios para hacer commit: modificado: app/assets/stylesheets/application.scss modificado: app/assets/stylesheets/datepicker_overrides.scss borrado: app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb --- app/assets/stylesheets/application.scss | 2 -- .../stylesheets/datepicker_overrides.scss | 29 +++++++++++-------- .../jquery-ui-theme_overrides.scss.erb | 6 ---- 3 files changed, 17 insertions(+), 20 deletions(-) delete mode 100644 app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ea5a5d653..19c73de32 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -14,8 +14,6 @@ @import 'c3'; @import 'annotator.min'; @import 'annotator_overrides'; -@import 'jquery-ui/theme'; -@import 'jquery-ui-theme_overrides'; @import 'jquery-ui/datepicker'; @import 'datepicker_overrides'; @import 'documentable'; diff --git a/app/assets/stylesheets/datepicker_overrides.scss b/app/assets/stylesheets/datepicker_overrides.scss index 2e8518e6f..cfa0ce671 100644 --- a/app/assets/stylesheets/datepicker_overrides.scss +++ b/app/assets/stylesheets/datepicker_overrides.scss @@ -32,25 +32,30 @@ padding: 0; z-index: 4 !important; - .ui-datepicker-prev { - left: 12px; - } - - .ui-datepicker-next { - right: 12px; - } - .ui-datepicker-prev, .ui-datepicker-next { color: #fff; cursor: pointer; + font-family: "icons" !important; + font-size: rem-calc(24); font-weight: normal; + height: rem-calc(30); line-height: $line-height; - top: 0; position: absolute; - top: 2px; - width: 1.8em; - height: 1.8em; + width: 4px; + width: rem-calc(30); + + &:hover { + text-decoration: none; + } + } + + .ui-datepicker-prev::after { + content: '\62'; + } + + .ui-datepicker-next::after { + content: '\63'; } table { diff --git a/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb b/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb deleted file mode 100644 index 2da19413e..000000000 --- a/app/assets/stylesheets/jquery-ui-theme_overrides.scss.erb +++ /dev/null @@ -1,6 +0,0 @@ -//Overrides icon color for the jquery-ui theme - -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url(<%= image_path("jquery-ui/ui-icons_ffffff_256x240.png") %>)/*{Make icons white}*/; -} From 823031af3193ee7ae3fca6eebe549ee889ff5b20 Mon Sep 17 00:00:00 2001 From: Manuel Lucena Date: Fri, 15 Sep 2017 10:38:08 +0200 Subject: [PATCH 09/33] 20170915 - Fixed behavior for sub menus under legislation section On branch mlucena-admin-menu Changes to be committed: modified: app/views/admin/_menu.html.erb --- app/views/admin/_menu.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index ce7c6357c..ebb76d301 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -59,8 +59,8 @@ <%= t("admin.menu.title_polls") %> - -
      > + +
        >
      • > <%= link_to t('admin.menu.polls'), admin_polls_path %>
      • From e93ac4e570b2f7d1b58029a62c9be619eeb04cb4 Mon Sep 17 00:00:00 2001 From: Manuel Lucena Date: Fri, 15 Sep 2017 11:10:48 +0200 Subject: [PATCH 10/33] 20170915 - fixed additional spacing and implemented suggested change of controller conditions --- app/views/admin/_menu.html.erb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index ebb76d301..37fe96544 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -59,13 +59,13 @@ <%= t("admin.menu.title_polls") %> - -
          > -
        • > + +
            > +
          • > <%= link_to t('admin.menu.polls'), admin_polls_path %>
          • -
          • > +
          • > <%= link_to t("admin.menu.poll_questions"), admin_questions_path %>
          • @@ -73,13 +73,13 @@ <%= link_to t('admin.menu.poll_officers'), admin_officers_path %> -
          • > <%= link_to t('admin.menu.poll_booths'), admin_booths_path %>
          • -
          • > <%= link_to t('admin.menu.poll_shifts'), available_admin_booths_path %>
          • From d629aef3b9df44568fa8ced43d2ad189c7cb86ea Mon Sep 17 00:00:00 2001 From: iagirre Date: Fri, 15 Sep 2017 12:33:31 +0200 Subject: [PATCH 11/33] When "Profiles" submenus are selected, the "Site custom" menu doesn't open. Moreover, when "Site custom" submenus are selected, the menu remains opened. --- app/helpers/admin_helper.rb | 4 ++++ app/views/admin/_menu.html.erb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index d56c658bd..f9c2e8c69 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -36,6 +36,10 @@ module AdminHelper ["banners"].include? controller_name end + def menu_customization? + ["pages", "images", "content_blocks"].include? controller_name + end + def official_level_options options = [["", 0]] (1..5).each do |i| diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index e629f5807..2cd7013c5 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -158,8 +158,8 @@ <%= t("admin.menu.title_site_customization") %> -
              > -
            • > +
                > +
              • > <%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
              • From 7be1f0315eae75bb07b4276b9f2b839b7bbf368c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 15 Sep 2017 12:37:42 +0200 Subject: [PATCH 12/33] Update Officing Polls final condition up to 2 weeks after poll ending --- app/controllers/officing/polls_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/officing/polls_controller.rb b/app/controllers/officing/polls_controller.rb index ba2a5c01a..46bcf9f37 100644 --- a/app/controllers/officing/polls_controller.rb +++ b/app/controllers/officing/polls_controller.rb @@ -7,7 +7,7 @@ class Officing::PollsController < Officing::BaseController def final @polls = if current_user.poll_officer? - current_user.poll_officer.final_days_assigned_polls.select {|poll| poll.ends_at > 1.week.ago && poll.expired?} + current_user.poll_officer.final_days_assigned_polls.select {|poll| poll.ends_at > 2.week.ago && poll.expired?} else [] end From 4bcb9ba81b89e30275a65600ffd9bea70a2f8ed2 Mon Sep 17 00:00:00 2001 From: iagirre Date: Fri, 15 Sep 2017 13:19:58 +0200 Subject: [PATCH 13/33] Extra indentation spaces erased. --- app/views/admin/_menu.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 2cd7013c5..a7724de91 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -158,8 +158,8 @@ <%= t("admin.menu.title_site_customization") %> -
                  > -
                • > +
                    > +
                  • > <%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
                  • From 8bf0d6f74960540071c524711f459e387b70571a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 15 Sep 2017 13:51:04 +0200 Subject: [PATCH 14/33] Correct i18n tasks config to check for any file under custom language folder --- config/i18n-tasks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 9357927ba..e766f66d5 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -21,7 +21,7 @@ data: # - config/locales/**/*.%{locale}.yml ## Another gem (replace %#= with %=): # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml" - - config/locales/custom/%{locale}/custom.yml + - config/locales/custom/%{locale}/*.yml - config/locales/%{locale}/general.yml - config/locales/%{locale}/activerecord.yml - config/locales/%{locale}/activemodel.yml From a3428ee589f7c09860ab589bf5893c26b18689d5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:15:19 +0200 Subject: [PATCH 15/33] Use snake_case for method names --- app/helpers/documentables_helper.rb | 4 ++-- app/helpers/documents_helper.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb index a4a840785..edbf88131 100644 --- a/app/helpers/documentables_helper.rb +++ b/app/helpers/documentables_helper.rb @@ -9,7 +9,7 @@ module DocumentablesHelper end def max_file_size(documentable) - bytesToMeg(documentable.class.max_file_size) + bytes_to_mega(documentable.class.max_file_size) end def accepted_content_types(documentable) @@ -38,4 +38,4 @@ module DocumentablesHelper documentable.documents.count >= documentable.class.max_documents_allowed end -end \ No newline at end of file +end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index a8ae6c973..72ebbf021 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -8,7 +8,7 @@ module DocumentsHelper document.errors[:attachment].join(', ') if document.errors.key?(:attachment) end - def bytesToMeg(bytes) + def bytes_to_mega(bytes) bytes / Numeric::MEGABYTE end From 20aca263d773d996db24b6c449e2879f361fc636 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:17:41 +0200 Subject: [PATCH 16/33] Use correct Predicate name on function --- app/helpers/communities_helper.rb | 2 +- app/views/communities/_participant.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/communities_helper.rb b/app/helpers/communities_helper.rb index bb770a948..22bc76617 100644 --- a/app/helpers/communities_helper.rb +++ b/app/helpers/communities_helper.rb @@ -12,7 +12,7 @@ module CommunitiesHelper community.from_proposal? ? t("community.show.description.proposal") : t("community.show.description.investment") end - def is_author?(community, participant) + def author?(community, participant) if community.from_proposal? community.proposal.author_id == participant.id else diff --git a/app/views/communities/_participant.html.erb b/app/views/communities/_participant.html.erb index 5e4f02900..91f991383 100644 --- a/app/views/communities/_participant.html.erb +++ b/app/views/communities/_participant.html.erb @@ -9,7 +9,7 @@ <%= link_to participant.name, user_path(participant)%> - <% if is_author?(@community, participant) %> + <% if author?(@community, participant) %>  •  <%= t("comments.comment.author") %> From 485b94eab9037cbccefa5b73a5c7d03306043dde Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:18:48 +0200 Subject: [PATCH 17/33] Correct end at file ending --- app/models/poll/shift.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/poll/shift.rb b/app/models/poll/shift.rb index 37a8658f3..d894df5a4 100644 --- a/app/models/poll/shift.rb +++ b/app/models/poll/shift.rb @@ -26,4 +26,4 @@ class Poll end end - end \ No newline at end of file +end From 97fe4642320ffa88eca5bbabeb3eb534b655e1ae Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:23:10 +0200 Subject: [PATCH 18/33] Use datetime always with zone --- spec/features/admin/poll/shifts_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 65396267b..1e5bb6328 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -14,19 +14,19 @@ feature 'Admin shifts' do booth1 = create(:poll_booth) booth2 = create(:poll_booth) - shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today) - shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Date.tomorrow) + shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Time.zone.today) + shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Time.zone.tomorrow) visit new_admin_booth_shift_path(booth1) expect(page).to have_css(".shift", count: 1) - expect(page).to have_content I18n.l(Date.today, format: :long) + expect(page).to have_content I18n.l(Time.zone.today, format: :long) expect(page).to have_content officer.name visit new_admin_booth_shift_path(booth2) expect(page).to have_css(".shift", count: 1) - expect(page).to have_content I18n.l(Date.tomorrow, format: :long) + expect(page).to have_content I18n.l(Time.zone.tomorrow, format: :long) expect(page).to have_content officer.name end From b889d23fe622b5cfed343dc760e03e05f3ee948c Mon Sep 17 00:00:00 2001 From: iagirre Date: Mon, 18 Sep 2017 08:19:47 +0200 Subject: [PATCH 19/33] Fixed width property, changed to top. --- app/assets/stylesheets/datepicker_overrides.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/datepicker_overrides.scss b/app/assets/stylesheets/datepicker_overrides.scss index cfa0ce671..79414ad99 100644 --- a/app/assets/stylesheets/datepicker_overrides.scss +++ b/app/assets/stylesheets/datepicker_overrides.scss @@ -42,7 +42,7 @@ height: rem-calc(30); line-height: $line-height; position: absolute; - width: 4px; + top: 4px; width: rem-calc(30); &:hover { From 2b3cbac5bcb1b3a01c5fec5e432c0ae3711dd25d Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 18 Sep 2017 14:21:38 +0200 Subject: [PATCH 20/33] moves author actions to sidebar on proposal show --- app/assets/stylesheets/participation.scss | 10 ++++- app/helpers/proposals_helper.rb | 16 ++++++++ app/views/proposals/show.html.erb | 47 ++++++++++++++--------- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 84e80f01f..8c380caf1 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -395,8 +395,6 @@ } } - &.tags, - &.geozone { li { margin-bottom: 0; @@ -610,6 +608,14 @@ } } +.show-actions-menu { + + [class^="icon-"] { + display: inline-block; + vertical-align: middle; + } +} + // 04. List participation // ---------------------- diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 37425d573..f6060603f 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -32,4 +32,20 @@ module ProposalsHelper Proposal::RETIRE_OPTIONS.collect { |option| [ t("proposals.retire_options.#{option}"), option ] } end + def can_create_document? + can?(:create, @document) && @proposal.documents.size < Proposal.max_documents_allowed + end + + def author_of_proposal? + author_of?(@proposal, current_user) + end + + def current_editable? + current_user && @proposal.editable_by?(current_user) + end + + def show_actions_menu? + can_create_document? || author_of_proposal? || current_editable? + end + end \ No newline at end of file diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 1dc918e8e..46db56ce6 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -16,24 +16,6 @@
                    <%= back_link_to %> - <% if can?(:create, @document) && @proposal.documents.size < Proposal.max_documents_allowed %> - <%= link_to t("documents.upload_document"), - new_document_path(documentable_id: @proposal, documentable_type: @proposal.class.name, from: request.url), - class: 'button hollow float-right' %> - <% end %> - - <% if author_of?(@proposal, current_user) %> - <%= link_to t("proposals.show.send_notification"), - new_proposal_notification_path(proposal_id: @proposal.id), - class: 'button hollow float-right' %> - <% end %> - - <% if current_user && @proposal.editable_by?(current_user) %> - <%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow float-right' do %> - <%= t("proposals.show.edit_proposal_link") %> - <% end %> - <% end %> -

                    <%= @proposal.title %>

                    <% if @proposal.retired? %>
                    @@ -122,6 +104,35 @@