Merge branch 'master' into 1856-legislation_processes_proposals_phase

This commit is contained in:
decabeza
2017-10-25 11:52:31 +02:00
186 changed files with 3595 additions and 1550 deletions

View File

@@ -24,8 +24,8 @@ module DocumentablesHelper
def documentable_humanized_accepted_content_types(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 documentables_note(documentable)

View File

@@ -33,7 +33,7 @@ module DocumentsHelper
def render_attachment(builder, document)
klass = document.errors[:attachment].any? ? "error" : ""
klass = document.persisted? || document.cached_attachment.present? ? " hide" : ""
klass = document.persisted? || document.cached_attachment.present? ? " hide" : ""
html = builder.label :attachment,
t("documents.form.attachment_label"),
class: "button hollow #{klass}"

View File

@@ -12,7 +12,7 @@ module FlagsHelper
def flagged?(flaggable)
if flaggable.is_a? Comment
@comment_flags[flaggable.id]
@comment_flags[flaggable.id] unless flaggable.commentable_type == "Poll"
else
Flag.flagged?(current_user, flaggable)
end

View File

@@ -9,10 +9,10 @@ module ImageablesHelper
end
def imageable_max_file_size
bytesToMeg(Image::MAX_IMAGE_SIZE)
bytes_to_megabytes(Image::MAX_IMAGE_SIZE)
end
def bytesToMeg(bytes)
def bytes_to_megabytes(bytes)
bytes / Numeric::MEGABYTE
end
@@ -22,19 +22,19 @@ module ImageablesHelper
def imageable_accepted_content_types_extensions
Image::ACCEPTED_CONTENT_TYPE
.collect{ |content_type| ".#{content_type.split("/").last}" }
.join(",")
.collect{ |content_type| ".#{content_type.split('/').last}" }
.join(",")
end
def imageable_humanized_accepted_content_types
Image::ACCEPTED_CONTENT_TYPE
.collect{ |content_type| content_type.split("/").last }
.join(", ")
.collect{ |content_type| content_type.split("/").last }
.join(", ")
end
def imageables_note(imageable)
def imageables_note(_imageable)
t "images.form.note", accepted_content_types: imageable_humanized_accepted_content_types,
max_file_size: imageable_max_file_size
end
end
end

View File

@@ -22,7 +22,7 @@ module ImagesHelper
image.errors[:attachment].join(', ') if image.errors.key?(:attachment)
end
def image_bytesToMeg(bytes)
def image_bytes_to_megabytes(bytes)
bytes / Numeric::MEGABYTE
end

View File

@@ -44,7 +44,7 @@ module PollsHelper
def poll_voter_token(poll, user)
Poll::Voter.where(poll: poll, user: user, origin: "web").first&.token || ''
end
def voted_before_sign_in(question)
question.answers.where(author: current_user).any? { |vote| current_user.current_sign_in_at >= vote.updated_at }
end

View File

@@ -1,19 +1,30 @@
module ShiftsHelper
def shift_vote_collection_dates(polls)
date_options((start_date(polls)..end_date(polls)))
def shift_vote_collection_dates(booth, polls)
return [] if polls.blank?
date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection], booth)
end
def shift_recount_scrutiny_dates(polls)
date_options(polls.map(&:ends_at).map(&:to_date).sort.inject([]) { |total, date| total << (date..date + 1.week).to_a }.flatten.uniq)
def shift_recount_scrutiny_dates(booth, polls)
return [] if polls.blank?
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
initial_date = date < Date.current ? Date.current : date
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
end
date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny], booth)
end
def date_options(dates)
dates.map { |date| [l(date, format: :long), l(date)] }
def date_options(dates, task_id, booth)
valid_dates(dates, task_id, booth).map { |date| [l(date, format: :long), l(date)] }
end
def valid_dates(dates, task_id, booth)
dates.reject { |date| officer_shifts(task_id, booth).include?(date) }
end
def start_date(polls)
polls.map(&:starts_at).min.to_date
start_date = polls.map(&:starts_at).min.to_date
start_date < Date.current ? Date.current : start_date
end
def end_date(polls)
@@ -24,4 +35,9 @@ module ShiftsHelper
officers.collect { |officer| [officer.name, officer.id] }
end
private
def officer_shifts(task_id, booth)
@officer.shifts.where(task: task_id, booth: booth).map(&:date)
end
end

View File

@@ -52,12 +52,8 @@ module UsersHelper
current_user && current_user.manager?
end
def current_poll_officer?
current_user && current_user.poll_officer?
end
def show_admin_menu?
current_administrator? || current_moderator? || current_valuator? || current_manager? || current_poll_officer?
current_administrator? || current_moderator? || current_valuator? || current_manager?
end
def interests_title_text(user)

View File

@@ -1,11 +1,11 @@
module WelcomeHelper
def active_class(index)
"is-active is-in" if index == 0
"is-active is-in" if index.zero?
end
def slide_display(index)
"display: none;" if index > 0
"display: none;" if index.positive?
end
def recommended_path(recommended)
@@ -46,17 +46,13 @@ module WelcomeHelper
end
def calculate_offset(debates, proposals, apply_offset)
if (debates.any? && proposals.any?)
if apply_offset
offset = "medium-offset-2 large-offset-2"
else
offset = "end"
end
if debates.any? && proposals.any?
offset = if apply_offset
"medium-offset-2 large-offset-2"
else
"end"
end
end
end
def highlight_background
(feature?("user.recommendations") && current_user) ? "highlight" : ""
end
end