diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f8d4bb811..373bb213c 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,12 +1,12 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2017-07-07 21:23:30 +0200 using RuboCop version 0.49.1.
+# on 2017-10-17 22:05:23 +0200 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
-# Offense count: 45
+# Offense count: 40
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
# SupportedHashRocketStyles: key, separator, table
@@ -14,11 +14,10 @@
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
Exclude:
- - 'app/controllers/officing/results_controller.rb'
- 'spec/controllers/legislation/annotations_controller_spec.rb'
- 'spec/features/admin/banners_spec.rb'
-# Offense count: 50
+# Offense count: 52
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
@@ -33,7 +32,7 @@ Layout/ClosingParenthesisIndentation:
- 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb'
-# Offense count: 51
+# Offense count: 37
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
@@ -68,11 +67,10 @@ Layout/EmptyLines:
Exclude:
- 'app/controllers/admin/budget_investment_milestones_controller.rb'
-# Offense count: 2
+# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody:
Exclude:
- - 'app/models/abilities/administrator.rb'
- 'lib/graph_ql/api_types_creator.rb'
# Offense count: 2
@@ -126,13 +124,13 @@ Layout/IndentationConsistency:
- 'spec/models/legislation/draft_version_spec.rb'
- 'spec/models/proposal_spec.rb'
-# Offense count: 23
+# Offense count: 48
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Enabled: false
-# Offense count: 7
+# Offense count: 6
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
Exclude:
@@ -140,7 +138,6 @@ Layout/LeadingCommentSpace:
- 'app/controllers/budgets/ballot/lines_controller.rb'
- 'spec/features/budgets/ballots_spec.rb'
- 'spec/features/comments/poll_questions_spec.rb'
- - 'spec/features/officing/voters_spec.rb'
- 'spec/support/common_actions.rb'
# Offense count: 3
@@ -181,7 +178,7 @@ Layout/MultilineMethodCallBraceLayout:
- 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb'
-# Offense count: 71
+# Offense count: 59
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
@@ -201,7 +198,7 @@ Layout/MultilineMethodCallIndentation:
- 'spec/models/proposal_spec.rb'
- 'spec/models/user_spec.rb'
-# Offense count: 8
+# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
@@ -264,29 +261,11 @@ Lint/LiteralInCondition:
Exclude:
- 'app/models/budget/investment.rb'
-# Offense count: 51
-Lint/ParenthesesAsGroupedExpression:
- Exclude:
- - 'spec/factories.rb'
- - 'spec/features/admin/organizations_spec.rb'
- - 'spec/features/budgets/investments_spec.rb'
- - 'spec/features/campaigns_spec.rb'
- - 'spec/features/debates_spec.rb'
- - 'spec/features/management/managed_users_spec.rb'
- - 'spec/features/management/proposals_spec.rb'
- - 'spec/features/management/spending_proposals_spec.rb'
- - 'spec/features/management/users_spec.rb'
- - 'spec/features/proposals_spec.rb'
- - 'spec/models/debate_spec.rb'
-
-# Offense count: 13
+# Offense count: 3
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Exclude:
- - 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb'
- - 'app/models/poll/white_result.rb'
- - 'app/models/poll/total_result.rb'
# Offense count: 15
# Cop supports --auto-correct.
@@ -311,7 +290,7 @@ Lint/UnusedMethodArgument:
- 'app/mailers/mailer.rb'
- 'app/models/abilities/everyone.rb'
-# Offense count: 278
+# Offense count: 325
Lint/UselessAssignment:
Enabled: false
@@ -320,35 +299,46 @@ Lint/Void:
Exclude:
- 'app/controllers/polls_controller.rb'
-# Offense count: 74
+# Offense count: 86
Metrics/AbcSize:
- Max: 54
+ Max: 64
-# Offense count: 454
+# Offense count: 487
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
- Max: 1071
-
-# Offense count: 8
-# Configuration parameters: CountComments.
-Metrics/ClassLength:
- Max: 256
+ Max: 1227
# Offense count: 10
+# Configuration parameters: CountComments.
+Metrics/ClassLength:
+ Max: 262
+
+# Offense count: 13
Metrics/CyclomaticComplexity:
Max: 10
-# Offense count: 53
+# Offense count: 25
+# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
+# URISchemes: http, https
+Metrics/LineLength:
+ Max: 248
+
+# Offense count: 67
# Configuration parameters: CountComments.
Metrics/MethodLength:
- Max: 49
+ Max: 56
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
- Max: 214
+ Max: 242
-# Offense count: 7
+# Offense count: 3
+# Configuration parameters: CountKeywordArgs.
+Metrics/ParameterLists:
+ Max: 7
+
+# Offense count: 8
Metrics/PerceivedComplexity:
Max: 11
@@ -402,20 +392,20 @@ Rails/HttpPositionalArguments:
- 'spec/controllers/pages_controller_spec.rb'
- 'spec/controllers/users/registrations_controller_spec.rb'
-# Offense count: 20
+# Offense count: 18
Rails/OutputSafety:
Exclude:
- 'app/controllers/admin/legislation/draft_versions_controller.rb'
- 'app/controllers/admin/legislation/processes_controller.rb'
- 'app/controllers/admin/legislation/questions_controller.rb'
- 'app/controllers/budgets/investments_controller.rb'
+ - 'app/controllers/direct_uploads_controller.rb'
- 'app/controllers/spending_proposals_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/text_with_links_helper.rb'
- - 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb'
-# Offense count: 70
+# Offense count: 71
# Configuration parameters: Blacklist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
Rails/SkipsModelValidations:
@@ -431,7 +421,7 @@ Style/AccessorMethodName:
- 'app/controllers/proposals_controller.rb'
- 'lib/merged_comment_tree.rb'
-# Offense count: 1
+# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
@@ -441,7 +431,7 @@ Style/BracesAroundHashParameters:
- 'spec/features/budgets/investments_spec.rb'
- 'spec/features/proposals_spec.rb'
-# Offense count: 119
+# Offense count: 123
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
@@ -454,14 +444,13 @@ Style/ClassVars:
- 'app/models/organization.rb'
- 'app/models/user.rb'
-# Offense count: 12
+# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'app/controllers/admin/poll/booth_assignments_controller.rb'
- - 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/questions_controller.rb'
- 'app/controllers/comments_controller.rb'
- 'app/controllers/management/spending_proposals_controller.rb'
@@ -487,7 +476,7 @@ Style/FileName:
Style/GuardClause:
Enabled: false
-# Offense count: 12
+# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
@@ -498,19 +487,19 @@ Style/IfUnlessModifier:
- 'app/controllers/legislation/annotations_controller.rb'
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/verification/letter_controller.rb'
- - 'app/controllers/welcome_controller.rb'
- 'app/helpers/embed_videos_helper.rb'
- 'app/mailers/mailer.rb'
- 'app/models/proposal.rb'
- 'app/models/spending_proposal.rb'
-# Offense count: 4
+# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'app/models/comment.rb'
+ - 'app/models/concerns/followable.rb'
- 'app/models/direct_message.rb'
- 'app/models/vote.rb'
- 'lib/graph_ql/api_types_creator.rb'
@@ -526,17 +515,14 @@ Style/MultilineIfThen:
Exclude:
- 'app/controllers/management/users_controller.rb'
-# Offense count: 15
+# Offense count: 13
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'app/models/activity.rb'
- 'app/models/budget/reclassified_vote.rb'
- 'app/models/legislation/draft_version.rb'
- - 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb'
- - 'app/models/poll/white_result.rb'
- - 'app/models/poll/total_result.rb'
- 'app/models/proposal.rb'
- 'app/models/signature_sheet.rb'
- 'app/models/site_customization/content_block.rb'
@@ -552,7 +538,7 @@ Style/MutableConstant:
Style/NumericLiterals:
MinDigits: 9
-# Offense count: 19
+# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
@@ -580,7 +566,7 @@ Style/ParallelAssignment:
- 'lib/active_model/dates.rb'
- 'spec/support/common_actions.rb'
-# Offense count: 11
+# Offense count: 10
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
@@ -594,7 +580,6 @@ Style/PredicateName:
- 'app/helpers/debates_helper.rb'
- 'app/models/budget/ballot.rb'
- 'app/models/user.rb'
- - 'lib/census_api.rb'
# Offense count: 4
# Cop supports --auto-correct.
@@ -614,13 +599,14 @@ Style/RedundantBegin:
- 'app/controllers/graphql_controller.rb'
- 'app/models/legislation/annotation.rb'
-# Offense count: 3
+# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'app/helpers/embed_videos_helper.rb'
+ - 'app/models/poll/question/answer/video.rb'
- 'spec/customization_engine_spec.rb'
# Offense count: 6
@@ -639,22 +625,16 @@ Style/SafeNavigation:
Exclude:
- 'app/models/signature.rb'
-# Offense count: 9
-# Configuration parameters: SupportedStyles.
-# SupportedStyles: snake_case, camelCase
-Style/VariableName:
- EnforcedStyle: snake_case
-
-# Offense count: 107
+# Offense count: 93
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, normalcase, non_integer
Style/VariableNumber:
Enabled: false
-# Offense count: 31
+# Offense count: 34
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
- MinSize: 9
+ MinSize: 8
diff --git a/app/assets/fonts/icons.eot b/app/assets/fonts/icons.eot
index 5564a5c62..53439b281 100644
Binary files a/app/assets/fonts/icons.eot and b/app/assets/fonts/icons.eot differ
diff --git a/app/assets/fonts/icons.svg b/app/assets/fonts/icons.svg
index 0d94e5751..a0c854397 100644
--- a/app/assets/fonts/icons.svg
+++ b/app/assets/fonts/icons.svg
@@ -65,4 +65,9 @@
" + @token + "");
token_message.show()
false
+
+ $(".zoom-link").on "click", (event) ->
+ element = event.target
+ answer = $(element).closest('div.answer')
+
+ if $(answer).hasClass('medium-6')
+ $(answer).removeClass("medium-6");
+ $(answer).addClass("answer-divider");
+ unless $(answer).hasClass('first')
+ $(answer).insertBefore($(answer).prev('div.answer'));
+ else
+ $(answer).addClass("medium-6");
+ $(answer).removeClass("answer-divider");
+ unless $(answer).hasClass('first')
+ $(answer).insertAfter($(answer).next('div.answer'));
+
diff --git a/app/assets/stylesheets/icons.scss b/app/assets/stylesheets/icons.scss
index 96eb10a0d..b9f2735b4 100644
--- a/app/assets/stylesheets/icons.scss
+++ b/app/assets/stylesheets/icons.scss
@@ -268,3 +268,23 @@
.icon-search-minus::before {
content: '\35';
}
+
+.icon-calculator::before {
+ content: '\36';
+}
+
+.icon-map-marker::before {
+ content: '\37';
+}
+
+.icon-user-plus::before {
+ content: '\38';
+}
+
+.icon-file-text-o::before {
+ content: '\39';
+}
+
+.icon-file-text::before {
+ content: '\21';
+}
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index 160819795..06fdfd396 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -372,6 +372,10 @@ a {
display: table-cell;
}
+.off-canvas-content {
+ box-shadow: none;
+}
+
// 02. Header
// ----------
@@ -1135,8 +1139,13 @@ form {
color: #ecf00b;
font-size: rem-calc(10);
position: absolute;
- right: 8px;
+ left: 12px;
top: 6px;
+
+ @include breakpoint(medium) {
+ left: auto;
+ right: 8px;
+ }
}
}
diff --git a/app/assets/stylesheets/print.css b/app/assets/stylesheets/print.css
index 6b3e5d6f6..58d2bab5e 100644
--- a/app/assets/stylesheets/print.css
+++ b/app/assets/stylesheets/print.css
@@ -12,7 +12,7 @@
#print_link { display: none !important; }
-#responsive-menu { display: none !important; }
+#responsive_menu { display: none !important; }
.admin-sidebar { display: none !important; }
diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb
index fd62df8b3..7532362a7 100644
--- a/app/controllers/admin/poll/officer_assignments_controller.rb
+++ b/app/controllers/admin/poll/officer_assignments_controller.rb
@@ -25,7 +25,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
def search_officers
load_search
- @officers = User.joins(:poll_officer).search(@search).order(username: :asc)
+
+ poll_officers = User.where(id: @poll.officers.pluck(:user_id))
+ @officers = poll_officers.search(@search).order(username: :asc)
respond_to do |format|
format.js
diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb
index cce880ed4..5103275fb 100644
--- a/app/controllers/admin/poll/polls_controller.rb
+++ b/app/controllers/admin/poll/polls_controller.rb
@@ -54,7 +54,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
end
def poll_params
- params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description,
+ params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description,
geozone_ids: [],
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end
diff --git a/app/controllers/admin/poll/questions/answers/images_controller.rb b/app/controllers/admin/poll/questions/answers/images_controller.rb
index 1bf30907d..030e177a1 100644
--- a/app/controllers/admin/poll/questions/answers/images_controller.rb
+++ b/app/controllers/admin/poll/questions/answers/images_controller.rb
@@ -5,7 +5,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
end
def new
- @answer = ::Poll::Question::Answer.find(params[:answer_id])
+ @answer = ::Poll::Question::Answer.find(params[:answer_id])
end
def create
diff --git a/app/controllers/admin/poll/questions/answers/videos_controller.rb b/app/controllers/admin/poll/questions/answers/videos_controller.rb
index a231c1a20..e9262b6dd 100644
--- a/app/controllers/admin/poll/questions/answers/videos_controller.rb
+++ b/app/controllers/admin/poll/questions/answers/videos_controller.rb
@@ -33,11 +33,11 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
end
def destroy
- if @video.destroy
- notice = t("flash.actions.destroy.poll_question_answer_video")
- else
- notice = t("flash.actions.destroy.error")
- end
+ notice = if @video.destroy
+ t("flash.actions.destroy.poll_question_answer_video")
+ else
+ t("flash.actions.destroy.error")
+ end
redirect_to :back, notice: notice
end
diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb
index 1f60b2b4e..89bb68999 100644
--- a/app/controllers/admin/poll/shifts_controller.rb
+++ b/app/controllers/admin/poll/shifts_controller.rb
@@ -49,7 +49,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
end
def shift_params
- shift_params = params.require(:shift).permit(:booth_id, :officer_id, :task, date:[:vote_collection_date, :recount_scrutiny_date])
+ shift_params = params.require(:shift).permit(:booth_id, :officer_id, :task, date: [:vote_collection_date, :recount_scrutiny_date])
shift_params.merge(date: shift_params[:date]["#{shift_params[:task]}_date".to_sym])
end
end
diff --git a/app/controllers/direct_uploads_controller.rb b/app/controllers/direct_uploads_controller.rb
index ade7d631f..a067a5d04 100644
--- a/app/controllers/direct_uploads_controller.rb
+++ b/app/controllers/direct_uploads_controller.rb
@@ -18,8 +18,7 @@ class DirectUploadsController < ApplicationController
render json: { cached_attachment: @direct_upload.relation.cached_attachment,
filename: @direct_upload.relation.attachment.original_filename,
destroy_link: render_destroy_upload_link(@direct_upload).html_safe,
- attachment_url: @direct_upload.relation.attachment.url
- }
+ attachment_url: @direct_upload.relation.attachment.url}
else
@direct_upload.destroy_attachment
render json: { errors: @direct_upload.errors[:attachment].join(", ") },
@@ -28,7 +27,7 @@ class DirectUploadsController < ApplicationController
end
def destroy
- @direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user) )
+ @direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user))
@direct_upload.relation.set_attachment_from_cached_attachment
if @direct_upload.destroy_attachment
diff --git a/app/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb
index 8d9f85578..3fe56abd2 100644
--- a/app/helpers/documentables_helper.rb
+++ b/app/helpers/documentables_helper.rb
@@ -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)
diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb
index d7e8d1dea..70eb6a27f 100644
--- a/app/helpers/documents_helper.rb
+++ b/app/helpers/documents_helper.rb
@@ -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}"
diff --git a/app/helpers/imageables_helper.rb b/app/helpers/imageables_helper.rb
index b1c8059ce..8cae1b989 100644
--- a/app/helpers/imageables_helper.rb
+++ b/app/helpers/imageables_helper.rb
@@ -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
\ No newline at end of file
+end
diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb
index 4e2bdff0e..208ccf5ab 100644
--- a/app/helpers/images_helper.rb
+++ b/app/helpers/images_helper.rb
@@ -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
diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb
index dd4018be7..0d5b0a605 100644
--- a/app/helpers/polls_helper.rb
+++ b/app/helpers/polls_helper.rb
@@ -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
diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb
index dc9f97a91..3773014ac 100644
--- a/app/helpers/shifts_helper.rb
+++ b/app/helpers/shifts_helper.rb
@@ -1,19 +1,28 @@
module ShiftsHelper
def shift_vote_collection_dates(polls)
- date_options((start_date(polls)..end_date(polls)))
+ date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection])
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)
+ 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])
end
- def date_options(dates)
- dates.map { |date| [l(date, format: :long), l(date)] }
+ def date_options(dates, task_id)
+ valid_dates(dates, task_id).map { |date| [l(date, format: :long), l(date)] }
+ end
+
+ def valid_dates(dates, task_id)
+ dates.reject { |date| officer_shifts(task_id).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 +33,9 @@ module ShiftsHelper
officers.collect { |officer| [officer.name, officer.id] }
end
+ private
+
+ def officer_shifts(task_id)
+ @officer.shifts.where(task: task_id).map(&:date)
+ end
end
diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb
index 9f8c8c13e..0b483468f 100644
--- a/app/helpers/welcome_helper.rb
+++ b/app/helpers/welcome_helper.rb
@@ -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
diff --git a/app/models/concerns/followable.rb b/app/models/concerns/followable.rb
index fee1ebd7f..d635cadda 100644
--- a/app/models/concerns/followable.rb
+++ b/app/models/concerns/followable.rb
@@ -5,7 +5,7 @@ module Followable
has_many :follows, as: :followable, dependent: :destroy
has_many :followers, through: :follows, source: :user
- scope :followed_by_user, -> (user){
+ scope :followed_by_user, ->(user){
joins(:follows).where("follows.user_id = ?", user.id)
}
end
diff --git a/app/models/debate.rb b/app/models/debate.rb
index eb424c308..65c06345d 100644
--- a/app/models/debate.rb
+++ b/app/models/debate.rb
@@ -48,8 +48,8 @@ class Debate < ActiveRecord::Base
attr_accessor :link_required
def self.recommendations(user)
- tagged_with(user.interests, any: true).
- where("author_id != ?", user.id)
+ tagged_with(user.interests, any: true)
+ .where("author_id != ?", user.id)
end
def searchable_values
diff --git a/app/models/direct_upload.rb b/app/models/direct_upload.rb
index e597f9f12..6681aa7be 100644
--- a/app/models/direct_upload.rb
+++ b/app/models/direct_upload.rb
@@ -7,7 +7,7 @@ class DirectUpload
:relation, :resource_relation,
:attachment, :cached_attachment, :user
- validates_presence_of :attachment, :resource_type, :resource_relation, :user
+ validates :attachment, :resource_type, :resource_relation, :user, presence: true
validate :parent_resource_attachment_validations,
if: -> { attachment.present? && resource_type.present? && resource_relation.present? && user.present? }
@@ -19,15 +19,15 @@ class DirectUpload
if @resource_type.present? && @resource_relation.present? && (@attachment.present? || @cached_attachment.present?)
@resource = @resource_type.constantize.find_or_initialize_by(id: @resource_id)
- #Refactor
- if @resource.respond_to?(:images) &&
- ((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?)
- @relation = @resource.images.send("build", relation_attributtes)
- elsif @resource.class.reflections[@resource_relation].macro == :has_one
- @relation = @resource.send("build_#{resource_relation}", relation_attributtes)
- else
- @relation = @resource.send(@resource_relation).build(relation_attributtes)
- end
+ # Refactor
+ @relation = if @resource.respond_to?(:images) &&
+ ((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?)
+ @resource.images.send("build", relation_attributtes)
+ elsif @resource.class.reflections[@resource_relation].macro == :has_one
+ @resource.send("build_#{resource_relation}", relation_attributtes)
+ else
+ @resource.send(@resource_relation).build(relation_attributtes)
+ end
@relation.user = user
end
@@ -50,7 +50,7 @@ class DirectUpload
def parent_resource_attachment_validations
@relation.valid?
- if @relation.errors.has_key? :attachment
+ if @relation.errors.key? :attachment
errors[:attachment] = @relation.errors[:attachment]
end
end
diff --git a/app/models/document.rb b/app/models/document.rb
index f680bc04e..8843bbed9 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -44,7 +44,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
diff --git a/app/models/image.rb b/app/models/image.rb
index 84b38dd4a..99061f6f1 100644
--- a/app/models/image.rb
+++ b/app/models/image.rb
@@ -5,7 +5,7 @@ class Image < ActiveRecord::Base
TITLE_LEGHT_RANGE = 4..80
MIN_SIZE = 475
MAX_IMAGE_SIZE = 1.megabyte
- ACCEPTED_CONTENT_TYPE = %w(image/jpeg image/jpg)
+ ACCEPTED_CONTENT_TYPE = %w(image/jpeg image/jpg).freeze
has_attached_file :attachment, styles: { large: "x#{MIN_SIZE}", medium: "300x300#", thumb: "140x245#" },
url: "/system/:class/:prefix/:style/:hash.:extension",
@@ -52,7 +52,7 @@ class Image < 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
@@ -103,8 +103,8 @@ class Image < ActiveRecord::Base
def remove_cached_attachment
image = Image.new(imageable: imageable,
- cached_attachment: cached_attachment,
- user: user)
+ cached_attachment: cached_attachment,
+ user: user)
image.set_attachment_from_cached_attachment
image.attachment.destroy
end
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 8675ce49a..27125d8a1 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -2,6 +2,9 @@ class Poll < ActiveRecord::Base
include Imageable
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases
+
+ RECOUNT_DURATION = 1.week
+
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
has_many :booths, through: :booth_assignments
has_many :partial_results, through: :booth_assignments
@@ -22,6 +25,7 @@ class Poll < ActiveRecord::Base
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Date.current.beginning_of_day, Date.current.beginning_of_day) }
scope :incoming, -> { where('? < starts_at', Date.current.beginning_of_day) }
scope :expired, -> { where('ends_at < ?', Date.current.beginning_of_day) }
+ scope :recounting, -> { Poll.where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) }
scope :published, -> { where('published = ?', true) }
scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) }
@@ -47,6 +51,10 @@ class Poll < ActiveRecord::Base
current + incoming
end
+ def self.current_or_recounting_or_incoming
+ current + recounting + incoming
+ end
+
def answerable_by?(user)
user.present? &&
user.level_two_or_three_verified? &&
@@ -72,6 +80,10 @@ class Poll < ActiveRecord::Base
Poll::Voter.where(poll: self, user: user, origin: "booth").exists?
end
+ def voted_in_web?(user)
+ Poll::Voter.where(poll: self, user: user, origin: "web").exists?
+ end
+
def date_range
unless starts_at.present? && ends_at.present? && starts_at <= ends_at
errors.add(:starts_at, I18n.t('errors.messages.invalid_date_range'))
diff --git a/app/models/poll/null_result.rb b/app/models/poll/null_result.rb
deleted file mode 100644
index d10fe3cb0..000000000
--- a/app/models/poll/null_result.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class Poll::NullResult < ActiveRecord::Base
-
- VALID_ORIGINS = %w{web booth}
-
- belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
- belongs_to :booth_assignment
- belongs_to :officer_assignment
-
- validates :author, presence: true
- validates :origin, inclusion: {in: VALID_ORIGINS}
-
- scope :by_author, ->(author_id) { where(author_id: author_id) }
-
- before_save :update_logs
-
- def update_logs
- if amount_changed? && amount_was.present?
- self.amount_log += ":#{amount_was.to_s}"
- self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
- self.author_id_log += ":#{author_id_was.to_s}"
- end
- end
-end
diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb
index efcaf4635..90e528bd0 100644
--- a/app/models/poll/question.rb
+++ b/app/models/poll/question.rb
@@ -40,7 +40,7 @@ class Poll::Question < ActiveRecord::Base
end
def valid_answers
- (super.try(:split, ',').compact || []).map(&:strip)
+ (super.try(:split, ',')&.compact || []).map(&:strip)
end
def copy_attributes_from_proposal(proposal)
diff --git a/app/models/poll/total_result.rb b/app/models/poll/total_result.rb
deleted file mode 100644
index 2df01929e..000000000
--- a/app/models/poll/total_result.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class Poll::TotalResult < ActiveRecord::Base
-
- VALID_ORIGINS = %w{web booth}
-
- belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
- belongs_to :booth_assignment
- belongs_to :officer_assignment
-
- validates :author, presence: true
- validates :origin, inclusion: {in: VALID_ORIGINS}
-
- scope :by_author, ->(author_id) { where(author_id: author_id) }
-
- before_save :update_logs
-
- def update_logs
- if amount_changed? && amount_was.present?
- self.amount_log += ":#{amount_was.to_s}"
- self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
- self.author_id_log += ":#{author_id_was.to_s}"
- end
- end
-end
diff --git a/app/models/poll/voter.rb b/app/models/poll/voter.rb
index bc0118a88..778a5d88a 100644
--- a/app/models/poll/voter.rb
+++ b/app/models/poll/voter.rb
@@ -1,7 +1,7 @@
class Poll
class Voter < ActiveRecord::Base
- VALID_ORIGINS = %w{ web booth }
+ VALID_ORIGINS = %w{web booth}.freeze
belongs_to :poll
belongs_to :user
diff --git a/app/models/poll/white_result.rb b/app/models/poll/white_result.rb
deleted file mode 100644
index a4a4e5a4d..000000000
--- a/app/models/poll/white_result.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-class Poll::WhiteResult < ActiveRecord::Base
-
- VALID_ORIGINS = %w{web booth}
-
- belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
- belongs_to :booth_assignment
- belongs_to :officer_assignment
-
- validates :author, presence: true
- validates :origin, inclusion: {in: VALID_ORIGINS}
-
- scope :by_author, ->(author_id) { where(author_id: author_id) }
-
- before_save :update_logs
-
- def update_logs
- if amount_changed? && amount_was.present?
- self.amount_log += ":#{amount_was.to_s}"
- self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
- self.author_id_log += ":#{author_id_was.to_s}"
- end
- end
-end
diff --git a/app/models/proposal.rb b/app/models/proposal.rb
index 1a688ab30..3b0696d26 100644
--- a/app/models/proposal.rb
+++ b/app/models/proposal.rb
@@ -69,10 +69,10 @@ class Proposal < ActiveRecord::Base
scope :public_for_api, -> { all }
def self.recommendations(user)
- tagged_with(user.interests, any: true).
- where("author_id != ?", user.id).
- unsuccessful.
- not_followed_by_user(user)
+ tagged_with(user.interests, any: true)
+ .where("author_id != ?", user.id)
+ .unsuccessful
+ .not_followed_by_user(user)
end
def self.not_followed_by_user(user)
diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb
index 21dc7cffb..f2af2c116 100644
--- a/app/views/admin/_menu.html.erb
+++ b/app/views/admin/_menu.html.erb
@@ -136,7 +136,7 @@
<% if feature?(:legislation) %>
|
- <%= text_with_links comment.body %> - <% if comment.commentable.hidden? %> - (<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>) - <% else %> - <%= link_to comment.commentable.title, comment.commentable %> - <% end %> - |
-
- <%= link_to t("admin.actions.restore"),
- restore_admin_comment_path(comment, request.query_parameters),
- method: :put,
- data: { confirm: t("admin.actions.confirm") },
- class: "button hollow on-hover-block" %>
- <% unless comment.confirmed_hide? %>
- <%= link_to t("admin.actions.confirm_hide"),
- confirm_hide_admin_comment_path(comment, request.query_parameters),
+
|
+
|
- <%= debate.title %>
- -
- <%= debate.description %>
-
- |
-
- <%= link_to t("admin.actions.restore"),
- restore_admin_debate_path(debate, request.query_parameters),
- method: :put,
- data: { confirm: t("admin.actions.confirm") },
- class: "button hollow on-hover" %>
- <% unless debate.confirmed_hide? %>
- <%= link_to t("admin.actions.confirm_hide"),
- confirm_hide_admin_debate_path(debate, request.query_parameters),
+
|
+
|
- <%= link_to user.name, admin_hidden_user_path(user) %> - |
+
| <%= t("admin.hidden_users.index.user") %> | +<%= t("admin.shared.actions") %> | + + + <% @users.each do |user| %> +
|---|---|
|
+ <%= link_to user.name, admin_hidden_user_path(user) %> + |
- - <%= link_to t("admin.actions.restore"), - restore_admin_hidden_user_path(user, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow on-hover" %> - <% unless user.confirmed_hide? %> - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_hidden_user_path(user, request.query_parameters), - method: :put, - class: "button hollow warning on-hover" %> - <% end %> - | -+ <%= link_to t("admin.actions.restore"), + restore_admin_hidden_user_path(user, request.query_parameters), + method: :put, + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> + <% unless user.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_hidden_user_path(user, request.query_parameters), + method: :put, + class: "button" %> + <% end %> + | + + <% end %> + +
| <%= t("admin.poll_officer_assignments.index.table_name") %> | <%= t("admin.poll_officer_assignments.index.table_email") %> | diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb index 1a13edf45..4004a949b 100644 --- a/app/views/admin/poll/shifts/_form.html.erb +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -24,12 +24,12 @@
|---|
|
- <%= proposal.title %>
- -
-
- <%= proposal.summary %> - <%= proposal.description %> - <% if proposal.external_url.present? %> -<%= text_with_links proposal.external_url %> - <% end %> - <% if proposal.video_url.present? %> -<%= text_with_links proposal.video_url %> - <% end %> -<%= proposal.question %> - |
-
- <%= link_to t("admin.actions.restore"),
- restore_admin_proposal_path(proposal, request.query_parameters),
- method: :put,
- data: { confirm: t("admin.actions.confirm") },
- class: "button hollow on-hover-block" %>
- <% unless proposal.confirmed_hide? %>
- <%= link_to t("admin.actions.confirm_hide"),
- confirm_hide_admin_proposal_path(proposal, request.query_parameters),
+
|
+
| <%= t("admin.tags.index.topic") %> | +<%= t("admin.actions.actions") %> | + + <% @tags.each do |tag| %>|
|---|---|---|
| + | <%= form_for(tag, url: admin_tag_path(tag), as: :tag, - html: { id: "edit_tag_#{tag.id}", class: "text-right"}) do |f| %> + html: { id: "edit_tag_#{tag.id}"}) do |f| %> - - <%= tag.name %> - - - <%= link_to t("admin.tags.destroy"), admin_tag_path(tag), method: :delete, class: "button hollow alert on-hover" %> + <%= tag.name %> <% end %> | ++ <%= link_to t("admin.tags.destroy"), admin_tag_path(tag), method: :delete, class: "button hollow alert" %> + |