diff --git a/.gitignore b/.gitignore index 7bb7a3090..a6f2826c3 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,3 @@ public/sitemap.xml public/system/ - -#Netbeans projects files -/nbproject diff --git a/.travis.yml b/.travis.yml index 7d5f6169a..8836964a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ before_script: - "for i in config/*.example; do cp \"$i\" \"${i/.example}\"; done" - bundle exec rake db:setup script: + - "bundle exec rake assets:precompile RAILS_ENV=test" - "bundle exec rake knapsack:rspec" env: global: 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/assets/stylesheets/datepicker_overrides.scss b/app/assets/stylesheets/datepicker_overrides.scss index d4c07802e..79414ad99 100644 --- a/app/assets/stylesheets/datepicker_overrides.scss +++ b/app/assets/stylesheets/datepicker_overrides.scss @@ -32,22 +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; - font-size: $small-font-size; + height: rem-calc(30); line-height: $line-height; - top: 0; + position: absolute; + top: 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/participation.scss b/app/assets/stylesheets/participation.scss index 84e80f01f..8c6fc5415 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -395,8 +395,8 @@ } } - &.tags, - &.geozone { + .tags, + .geozone { li { margin-bottom: 0; @@ -478,6 +478,7 @@ .tags { display: block; + margin-bottom: 0; a { margin-right: rem-calc(6); @@ -610,6 +611,14 @@ } } +.show-actions-menu { + + [class^="icon-"] { + display: inline-block; + vertical-align: middle; + } +} + // 04. List participation // ---------------------- 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..8f085e27f 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 @@ -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/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 diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 75b3996fb..069445bc9 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/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/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/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb index 4fd737908..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) @@ -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) @@ -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 17d70068b..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 @@ -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/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 845cf83ce..6ef3be75d 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -40,4 +40,17 @@ module ProposalsHelper end end + + def can_create_document?(document, proposal) + can?(:create, document) && proposal.documents.size < Proposal.max_documents_allowed + end + + def author_of_proposal?(proposal) + author_of?(proposal, current_user) + end + + def current_editable?(proposal) + current_user && proposal.editable_by?(current_user) + 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/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/app/models/poll/shift.rb b/app/models/poll/shift.rb index cc6a43425..d894df5a4 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,10 +20,10 @@ class Poll end end - def persist_data + def persist_data self.officer_name = officer.name self.officer_email = officer.email end end - end \ No newline at end of file +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 427683298..80cf75f61 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/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index e629f5807..11d58adc8 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -60,12 +60,12 @@ <%= t("admin.menu.title_polls") %> -