diff --git a/.gitignore b/.gitignore index f4b9c99fb..35f5651a4 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ # Mac finder artifacts .DS_Store .ruby-gemset + +public/sitemap.xml \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..be2d522a4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,56 @@ +inherit_from: .rubocop_todo.yml + +AllCops: + Include: + - '**/Rakefile' + - '**/config.ru' + Exclude: + - 'db/**/*' + - 'config/**/*' + - 'script/**/*' + TargetRubyVersion: 2.3 + +Rails: + Enabled: true + +Documentation: + Enabled: false + +Metrics/LineLength: + Max: 140 + +Style/IndentationConsistency: + EnforcedStyle: rails + +Style/StringLiterals: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false + +Style/PercentLiteralDelimiters: + Enabled: false + +Style/EmptyLinesAroundClassBody: + Enabled: false + +Style/EmptyLinesAroundBlockBody: + Enabled: false + +Style/EmptyLinesAroundModuleBody: + Enabled: false + +Style/SpaceBeforeBlockBraces: + Enabled: false + +Style/SpaceInsideBrackets: + Enabled: false + +Style/SpaceInsideHashLiteralBraces: + Enabled: false + +Style/SpaceInsideBlockBraces: + Enabled: false + +Style/TrailingBlankLines: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..443782795 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,838 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-11-25 13:34:56 +0100 using RuboCop version 0.45.0. +# 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: 3 +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'app/helpers/verification_helper.rb' + - 'spec/features/verification/residence_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'app/controllers/management/sessions_controller.rb' + - 'app/models/notification.rb' + - 'lib/capistrano/template.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AlignWith, SupportedStyles. +# SupportedStyles: either, start_of_block, start_of_line +Lint/BlockAlignment: + Exclude: + - 'spec/features/tracks_spec.rb' + - 'spec/models/proposal_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. +# SupportedStyles: start_of_line, def +Lint/DefEndAlignment: + Exclude: + - 'app/controllers/comments_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: runtime_error, standard_error +Lint/InheritException: + Exclude: + - 'app/controllers/concerns/feature_flags.rb' + +# Offense count: 7 +Lint/NestedMethodDefinition: + Exclude: + - 'lib/acts_as_paranoid_aliases.rb' + +# Offense count: 13 +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'spec/features/admin/organizations_spec.rb' + - 'spec/features/debates_spec.rb' + - 'spec/features/proposals_spec.rb' + - 'spec/models/debate_spec.rb' + +# Offense count: 1 +Lint/UnderscorePrefixedVariableName: + Exclude: + - 'lib/manager_authenticator.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'app/controllers/admin/spending_proposals_controller.rb' + - 'app/models/ahoy/data_source.rb' + - 'spec/spec_helper.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'app/controllers/organizations/registrations_controller.rb' + - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'app/controllers/users/registrations_controller.rb' + - 'app/models/abilities/everyone.rb' + - 'app/models/abilities/valuator.rb' + +# Offense count: 135 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 41 +Metrics/AbcSize: + Max: 44 + +# Offense count: 4 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 205 + +# Offense count: 5 +Metrics/CyclomaticComplexity: + Max: 8 + +# Offense count: 52 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives. +# URISchemes: http, https +Metrics/LineLength: + Max: 307 + +# Offense count: 28 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 38 + +# Offense count: 2 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 193 + +# Offense count: 3 +Metrics/PerceivedComplexity: + Max: 11 + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'app/mailers/mailer.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/helpers/embed_videos_helper.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: strict, flexible +Rails/Date: + Exclude: + - 'app/controllers/concerns/commentable_actions.rb' + - 'app/models/direct_message.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist. +# Whitelist: find_by_sql +Rails/DynamicFindBy: + Exclude: + - 'app/controllers/users/confirmations_controller.rb' + - 'app/controllers/users/registrations_controller.rb' + - 'spec/features/management/users_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/FindBy: + Exclude: + - 'app/models/setting.rb' + - 'app/models/verification/email.rb' + - 'app/models/verification/management/email.rb' + - 'app/models/verification/residence.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: spec/**/*, test/**/* +Rails/HttpPositionalArguments: + Exclude: + - 'spec/controllers/admin/api/stats_controller_spec.rb' + - 'spec/controllers/concerns/has_filters_spec.rb' + - 'spec/controllers/concerns/has_orders_spec.rb' + - 'spec/controllers/debates_controller_spec.rb' + - 'spec/controllers/management/sessions_controller_spec.rb' + - 'spec/controllers/pages_controller_spec.rb' + - 'spec/controllers/users/registrations_controller_spec.rb' + +# Offense count: 12 +Rails/OutputSafety: + Exclude: + - '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: 6 +# Cop supports --auto-correct. +Rails/PluralizationGrammar: + Exclude: + - 'spec/features/admin/banners_spec.rb' + - 'spec/features/debates_spec.rb' + - 'spec/features/proposals_spec.rb' + - 'spec/models/residence_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: referer, referrer +Rails/RequestReferer: + Exclude: + - 'app/controllers/users/sessions_controller.rb' + +# Offense count: 11 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'lib/score_calculator.rb' + - 'spec/controllers/admin/api/stats_controller_spec.rb' + - 'spec/models/ahoy/data_source_spec.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/Validation: + Exclude: + - 'app/models/comment.rb' + - 'app/models/spending_proposal.rb' + - 'app/models/verification/residence.rb' + - 'app/models/verification/sms.rb' + +# Offense count: 9 +Style/AccessorMethodName: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/concerns/commentable_actions.rb' + - 'app/controllers/management/proposals_controller.rb' + - 'app/controllers/management/spending_proposals_controller.rb' + - 'app/controllers/proposals_controller.rb' + +# Offense count: 30 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Style/AlignHash: + Exclude: + - 'spec/features/admin/banners_spec.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Style/AlignParameters: + Exclude: + - 'app/helpers/search_helper.rb' + - 'app/models/verification/management/email.rb' + - 'bin/rspec' + - 'bin/spring' + - 'spec/features/admin/spending_proposals_spec.rb' + - 'spec/features/spending_proposals_spec.rb' + - 'spec/features/valuation/spending_proposals_spec.rb' + - 'spec/features/verification/verified_user_spec.rb' + - 'spec/i18n_spec.rb' + - 'spec/models/user_spec.rb' + - 'spec/rails_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'app/helpers/embed_videos_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'spec/features/users_auth_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/BlockEndNewline: + Exclude: + - 'app/models/banner.rb' + - 'spec/features/users_auth_spec.rb' + +# Offense count: 19 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/models/concerns/searchable.rb' + - 'app/models/verification/residence.rb' + - 'lib/manager_authenticator.rb' + - 'spec/controllers/management/users_controller_spec.rb' + - 'spec/features/admin/spending_proposals_spec.rb' + - 'spec/lib/manager_authenticator_spec.rb' + - 'spec/models/residence_spec.rb' + - 'spec/models/user_spec.rb' + +# Offense count: 57 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 5 +Style/ClassVars: + Exclude: + - 'app/models/concerns/measurable.rb' + - 'app/models/organization.rb' + - 'app/models/user.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ClosingParenthesisIndentation: + Exclude: + - 'spec/rails_helper.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'app/controllers/comments_controller.rb' + - 'app/controllers/management/spending_proposals_controller.rb' + - 'app/controllers/spending_proposals_controller.rb' + - 'app/controllers/verification/sms_controller.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: leading, trailing +Style/DotPosition: + Exclude: + - 'app/models/banner.rb' + - 'app/models/tag_cloud.rb' + - 'app/models/verification/management/managed_user.rb' + +# Offense count: 1 +Style/DoubleNegation: + Exclude: + - 'app/models/flag.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EmptyCaseCondition: + Exclude: + - 'app/models/concerns/verification.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/EmptyLines: + Exclude: + - 'app/models/concerns/search_cache.rb' + - 'app/models/notification.rb' + - 'spec/features/admin/spending_proposals_spec.rb' + - 'spec/features/admin/verifications_spec.rb' + - 'spec/features/debates_spec.rb' + - 'spec/features/registration_form_spec.rb' + - 'spec/features/users_auth_spec.rb' + - 'spec/features/verification/verified_user_spec.rb' + - 'spec/support/verifiable.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EmptyLinesAroundAccessModifier: + Exclude: + - 'app/controllers/users_controller.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Style/ExtraSpacing: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Style/FirstParameterIndentation: + Exclude: + - 'app/controllers/users_controller.rb' + +# Offense count: 32 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'lib/sms_api.rb' + - 'spec/factories.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Exclude: + - 'app/controllers/annotations_controller.rb' + - 'app/controllers/verification/letter_controller.rb' + - 'app/controllers/welcome_controller.rb' + - 'app/helpers/embed_videos_helper.rb' + - 'app/models/proposal.rb' + - 'app/models/spending_proposal.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Style/IndentArray: + EnforcedStyle: consistent + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Style/IndentHash: + EnforcedStyle: consistent + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: normal, rails +Style/IndentationConsistency: + Exclude: + - 'spec/features/tracks_spec.rb' + - 'spec/models/proposal_spec.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: Width. +Style/IndentationWidth: + Exclude: + - 'app/controllers/annotations_controller.rb' + - 'app/helpers/flags_helper.rb' + - 'app/mailers/devise_mailer.rb' + - 'app/mailers/mailer.rb' + - 'app/models/ahoy/data_source.rb' + - 'app/models/comment_notifier.rb' + - 'app/models/concerns/search_cache.rb' + - 'spec/features/comments/proposals_spec.rb' + - 'spec/features/moderation/users_spec.rb' + - 'spec/features/tracks_spec.rb' + - 'spec/features/verification/verified_user_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: line_count_dependent, lambda, literal +Style/Lambda: + Exclude: + - 'app/models/banner.rb' + - 'app/models/direct_message.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MethodCallParentheses: + Exclude: + - 'app/controllers/management/document_verifications_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'spec/helpers/comments_helper_spec.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Style/MultilineArrayBraceLayout: + Exclude: + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/helpers/search_helper.rb' + +# Offense count: 1 +Style/MultilineBlockChain: + Exclude: + - 'app/controllers/valuation/spending_proposals_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineBlockLayout: + Exclude: + - 'app/models/banner.rb' + - 'spec/features/users_auth_spec.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Style/MultilineHashBraceLayout: + Exclude: + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/models/debate.rb' + - 'app/models/proposal.rb' + - 'app/models/spending_proposal.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'app/controllers/management/users_controller.rb' + - 'lib/census_api.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Style/MultilineMethodCallBraceLayout: + Exclude: + - 'app/controllers/users_controller.rb' + - 'app/models/comment.rb' + - 'app/models/organization.rb' + - 'app/models/user.rb' + - 'spec/rails_helper.rb' + +# Offense count: 33 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Style/MultilineMethodCallIndentation: + Exclude: + - 'app/models/banner.rb' + - 'app/models/tag_cloud.rb' + - 'app/models/verification/management/managed_user.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/debate_spec.rb' + - 'spec/models/proposal_spec.rb' + - 'spec/models/user_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Style/MultilineOperationIndentation: + Exclude: + - 'app/helpers/users_helper.rb' + - 'app/helpers/valuation_helper.rb' + - 'app/models/verification/letter.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'app/models/activity.rb' + - 'app/models/proposal.rb' + - 'lib/tag_sanitizer.rb' + - 'lib/wysiwyg_sanitizer.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NegatedIf: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Style/NestedParenthesizedCalls: + Exclude: + - 'spec/features/debates_spec.rb' + - 'spec/features/valuation/spending_proposals_spec.rb' + - 'spec/helpers/settings_helper_spec.rb' + - 'spec/helpers/verification_helper_spec.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +Style/NumericLiterals: + MinDigits: 9 + +# Offense count: 19 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'app/controllers/users_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/helpers/banners_helper.rb' + - 'app/helpers/debates_helper.rb' + - 'app/helpers/votes_helper.rb' + - 'app/models/concerns/conflictable.rb' + - 'app/models/concerns/taggable.rb' + - 'app/models/concerns/verification.rb' + - 'app/models/debate.rb' + - 'app/models/lock.rb' + - 'app/models/user.rb' + - 'app/models/verification/management/email.rb' + - 'lib/score_calculator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/ParallelAssignment: + Exclude: + - 'lib/active_model/dates.rb' + - 'spec/support/common_actions.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment. +Style/ParenthesesAroundCondition: + Exclude: + - 'app/controllers/proposals_controller.rb' + - 'app/models/debate.rb' + - 'app/models/proposal.rb' + +# Offense count: 6 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +Style/PredicateName: + Exclude: + - 'spec/**/*' + - 'app/controllers/concerns/has_filters.rb' + - 'app/controllers/concerns/has_orders.rb' + - 'app/helpers/banners_helper.rb' + - 'app/helpers/debates_helper.rb' + - 'app/models/user.rb' + - 'lib/census_api.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'app/controllers/management/base_controller.rb' + - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'app/controllers/admin/settings_controller.rb' + - 'app/helpers/proposals_helper.rb' + - 'spec/features/admin/organizations_spec.rb' + - 'spec/features/debates_spec.rb' + - 'spec/features/proposals_spec.rb' + - 'spec/models/debate_spec.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'app/models/ahoy/data_source.rb' + - 'app/models/verification/management/document.rb' + - 'lib/capistrano/template.rb' + - 'lib/census_api.rb' + +# Offense count: 49 +# Cop supports --auto-correct. +Style/RedundantSelf: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'app/helpers/embed_videos_helper.rb' + - 'spec/customization_engine_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'app/controllers/concerns/commentable_actions.rb' + - 'app/controllers/verification/sms_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SpaceAfterColon: + Exclude: + - 'spec/models/user_spec.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +Style/SpaceAfterComma: + Exclude: + - 'app/models/ahoy/data_source.rb' + - 'app/models/banner.rb' + - 'app/models/concerns/search_cache.rb' + - 'app/models/concerns/taggable.rb' + - 'app/models/spending_proposal.rb' + - 'app/models/user.rb' + - 'spec/features/valuation/spending_proposals_spec.rb' + - 'spec/lib/census_api_spec.rb' + - 'spec/models/abilities/moderator_spec.rb' + - 'spec/models/verification/management/email_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SpaceAfterNot: + Exclude: + - 'app/models/flag.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Style/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'app/helpers/cache_keys_helper.rb' + - 'app/helpers/proposals_helper.rb' + - 'app/helpers/spending_proposals_helper.rb' + - 'app/helpers/stats_helper.rb' + - 'app/helpers/tracks_helper.rb' + - 'app/helpers/valuation_helper.rb' + - 'app/mailers/devise_mailer.rb' + - 'app/models/comment.rb' + - 'app/models/tag_cloud.rb' + - 'app/models/verification/residence.rb' + - 'lib/acts_as_paranoid_aliases.rb' + - 'lib/capistrano/template.rb' + - 'lib/census_api.rb' + - 'lib/manager_authenticator.rb' + - 'spec/support/common_actions.rb' + +# Offense count: 66 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Style/SpaceAroundOperators: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +Style/SpaceBeforeComma: + Exclude: + - 'app/models/proposal.rb' + - 'spec/controllers/management/sessions_controller_spec.rb' + - 'spec/controllers/management/users_controller_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Style/SpaceBeforeFirstArg: + Exclude: + - 'spec/factories.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: require_no_space, require_space +Style/SpaceInLambdaLiteral: + Exclude: + - 'app/models/concerns/filterable.rb' + - 'app/models/spending_proposal.rb' + - 'app/models/user.rb' + - 'app/models/verified_user.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/SpaceInsideParens: + Exclude: + - 'app/models/user.rb' + - 'lib/manager_authenticator.rb' + - 'spec/features/proposals_spec.rb' + - 'spec/models/abilities/moderator_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/SpaceInsidePercentLiteralDelimiters: + Exclude: + - 'app/models/activity.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'app/controllers/stats_controller.rb' + - 'app/models/proposal.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'app/controllers/admin/settings_controller.rb' + - 'app/controllers/notifications_controller.rb' + - 'app/controllers/organizations/registrations_controller.rb' + - 'lib/manager_authenticator.rb' + - 'spec/factories.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/TrailingWhitespace: + Exclude: + - 'app/controllers/admin/api/stats_controller.rb' + +# Offense count: 31 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'spec/factories.rb' + - 'spec/features/campaigns_spec.rb' + - 'spec/features/management/managed_users_spec.rb' + - 'spec/features/management/proposals_spec.rb' + - 'spec/features/management/spending_proposals_spec.rb' + - 'spec/models/residence_spec.rb' + - 'spec/models/spending_proposal_spec.rb' + +# Offense count: 13 +# Configuration parameters: SupportedStyles. +# SupportedStyles: snake_case, normalcase, non_integer +Style/VariableNumber: + EnforcedStyle: normalcase + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'app/models/concerns/verification.rb' diff --git a/.ruby-version b/.ruby-version index a6254504e..e7034819f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.1 \ No newline at end of file +2.3.2 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a45f36990..54460ab58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,13 @@ language: ruby addons: postgresql: "9.4" rvm: - - "2.2.3" + - "2.3.2" cache: bundler before_script: - "for i in config/*.example; do cp \"$i\" \"${i/.example}\"; done" - bundle exec rake db:setup -script: bundle exec rake +script: + - "bundle exec rake knapsack:rspec" +env: + - CI_NODE_TOTAL=2 CI_NODE_INDEX=0 + - CI_NODE_TOTAL=2 CI_NODE_INDEX=1 \ No newline at end of file diff --git a/CONTRIBUTING_EN.md b/CONTRIBUTING_EN.md index 0c322d506..17f93bc63 100644 --- a/CONTRIBUTING_EN.md +++ b/CONTRIBUTING_EN.md @@ -34,6 +34,16 @@ If you want to contribute code to solve an issue: * Follow these [best practices](https://github.com/styleguide/ruby) * Open a *pull request* to the main repository describing what issue you are addressing. +## Cleaning up + +In the rush of time sometimes things get messy, you can help us cleaning things up: + +* implement [pending specs](https://travis-ci.org/consul/consul) +* increase [code coverage](https://coveralls.io/github/consul/consul?branch=master) +* improve [code quality](https://codeclimate.com/github/consul/consul) +* update [dependencies](https://gemnasium.com/consul/consul) +* make [code consistent](https://github.com/bbatsov/rubocop) + ## Other ways of contributing without coding * If you think there's a feature missing, or find a bug, create an issue (make sure it has not already been reported). diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md index 7a8d10877..aaee9ec92 100644 --- a/CONTRIBUTING_ES.md +++ b/CONTRIBUTING_ES.md @@ -34,6 +34,16 @@ Cuando quieras resolver una incidencia mediante código: * Sigue estas [buenas prácticas](https://github.com/styleguide/ruby) * Envía una *pull request* al repositorio principal indicando la incidencia que se está arreglando +## Limpiar + +En la urgencia del momento, las cosas a veces se ensucian, puedes ayudarnos a limpiar la casa: + +* implementando [tests pendientes](https://travis-ci.org/consul/consul) +* incrementando la [cobertura de tests](https://coveralls.io/github/consul/consul?branch=master) +* mejorando la [calidad del código](https://codeclimate.com/github/consul/consul) +* actualizando [dependecias](https://gemnasium.com/consul/consul) +* haciendo el [código consistente](https://github.com/bbatsov/rubocop) + ## Otras formas de contribuir sin código * Si crees que hay una funcionalidad que hace falta, o descubres un problema, abre una incidencia (asegúrate de que diff --git a/CUSTOMIZE_ES.md b/CUSTOMIZE_ES.md index 71c3701e4..09fdfe62c 100644 --- a/CUSTOMIZE_ES.md +++ b/CUSTOMIZE_ES.md @@ -1,38 +1,39 @@ # Personalización -Puedes modificar consul y ponerle tu propia imagen, para esto debes primero hacer un fork de https://github.com/consul/consul creando un repositorio nuevo en Github. Puedes usar otro servicio como Gitlab, pero no te olvides de poner el enlace en el footer a tu repositorio en cumplimiento con la licencia de este proyecto (GPL Affero 3). +Puedes modificar consul y ponerle tu propia imagen, para esto debes primero hacer un fork de [https://github.com/consul/consul](https://github.com/consul/consul) creando un repositorio nuevo en Github. Puedes usar otro servicio como Gitlab, pero no te olvides de poner el enlace en el footer a tu repositorio en cumplimiento con la licencia de este proyecto (GPL Affero 3). -Hemos creado una estructura específica donde puedes sobreescribir y personalizar la aplicación para que puedas actualizar sin que tengas problemas al hacer merge y se sobreescriban por error tus cambios. Intentamos que Consul sea una aplicación Ruby on Rails lo más plain vanilla posible para facilitar el acceso de nuevas desarrolladoras. +Hemos creado una estructura específica donde puedes sobreescribir y personalizar la aplicación para que puedas actualizar sin que tengas problemas al hacer merge y se sobreescriban por error tus cambios. Intentamos que Consul sea una aplicación Ruby on Rails lo más plain vanilla posible para facilitar el acceso de nuevas desarrolladoras. ## Ficheros y directorios especiales Para adaptarlo puedes hacerlo a través de los directorios que están en custom dentro de: -* config/locales/custom/ -* app/assets/images/custom/ -* app/views/custom/ -* app/controllers/custom/ -* app/models/custom/ +* `config/locales/custom/` +* `app/assets/images/custom/` +* `app/views/custom/` +* `app/controllers/custom/` +* `app/models/custom/` Aparte de estos directorios también cuentas con ciertos ficheros para: -* app/assets/stylesheets/custom.css -* app/assets/javascripts/custom.js -* Gemfile_custom -* config/application.custom.rb +* `app/assets/stylesheets/custom.css` +* `app/assets/javascripts/custom.js` +* `Gemfile_custom` +* `config/application.custom.rb` -### Internacionalización +### Internacionalización -Si quieres modificar algún texto de la web deberías encontrarlos en los ficheros formato YML disponibles en *config/locales/*. Puedes leer la [guía de internacionalización](http://guides.rubyonrails.org/i18n.html) de Ruby on Rails sobre como funciona este sistema. +Si quieres modificar algún texto de la web deberías encontrarlos en los ficheros formato YML disponibles en `config/locales/`. Puedes leer la [guía de internacionalización](http://guides.rubyonrails.org/i18n.html) de Ruby on Rails sobre como funciona este sistema. -Las adaptaciones los debes poner en el directorio *config/locales/custom/*, recomendamos poner solo los textos que quieras personalizar. Por ejemplo si quieres personalizar el texto de "Ayuntamiento de Madrid, 2016" que se encuentra en el footer en todas las páginas, primero debemos ubicar en que plantilla se encuentra (app/views/layouts/_footer.html.erb), vemos que en el código pone lo siguiente: -``` -<%= t("layouts.footer.copyright", year: Time.now.year) %> +Las adaptaciones los debes poner en el directorio `config/locales/custom/`, recomendamos poner solo los textos que quieras personalizar. Por ejemplo si quieres personalizar el texto de "Ayuntamiento de Madrid, 2016" que se encuentra en el footer en todas las páginas, primero debemos ubicar en que plantilla se encuentra (`app/views/layouts/_footer.html.erb`), vemos que en el código pone lo siguiente: + +```ruby +<%= t("layouts.footer.copyright", year: Time.current.year) %> ``` -Y que en el fichero config/locales/es.yml sigue esta estructura (solo ponemos lo relevante para este caso): +Y que en el fichero `config/locales/es.yml` sigue esta estructura (solo ponemos lo relevante para este caso): -``` +```yml es: layouts: footer: @@ -40,11 +41,11 @@ es: ``` -Si creamos el fichero config/locales/custom/es.yml y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros config/locales/ e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir. +Si creamos el fichero `config/locales/custom/es.yml` y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros `config/locales/` e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir. ### Imágenes -Si quieres sobreescribir alguna imagen debes primero fijarte el nombre que tiene, por defecto se encuentran en *app/assets/images*. Por ejemplo si quieres modificar *app/assets/images/logo_header.png* debes poner otra con ese mismo nombre en el directorio app/assets/images/custom. Los iconos que seguramente quieras modificar son: +Si quieres sobreescribir alguna imagen debes primero fijarte el nombre que tiene, por defecto se encuentran en `app/assets/images`. Por ejemplo si quieres modificar `app/assets/images/logo_header.png` debes poner otra con ese mismo nombre en el directorio `app/assets/images/custom`. Los iconos que seguramente quieras modificar son: * apple-touch-icon-200.png * icon_home.png @@ -55,25 +56,25 @@ Si quieres sobreescribir alguna imagen debes primero fijarte el nombre que tiene ### Vistas (HTML) -Si quieres modificar el HTML de alguna página puedes hacerlo copiando el HTML de *app/views* y poniendolo en *app/views/custom* respetando los subdirectorios que encuentres ahí. Por ejemplo si quieres modificar *app/views/pages/conditions.html* debes copiarlo y modificarla en app/views/custom/pages/conditions.html.erb +Si quieres modificar el HTML de alguna página puedes hacerlo copiando el HTML de `app/views` y poniendolo en `app/views/custom` respetando los subdirectorios que encuentres ahí. Por ejemplo si quieres modificar `app/views/pages/conditions.html` debes copiarlo y modificarla en `app/views/custom/pages/conditions.html.erb` ### CSS -Si quieres cambiar algun selector CSS (de las hojas de estilo) puedes hacerlo en el fichero *app/assets/stylesheets/custom.scss*. Por ejemplo si quieres cambiar el color del header (.top-links) puedes hacerlo agregando: +Si quieres cambiar algun selector CSS (de las hojas de estilo) puedes hacerlo en el fichero `app/assets/stylesheets/custom.scss`. Por ejemplo si quieres cambiar el color del header (`.top-links`) puedes hacerlo agregando: -``` +```css .top-links { background: red; } ``` -Usamos un preprocesador de CSS, [SASS, con la sintaxis SCSS](http://sass-lang.com/guide). +Usamos un preprocesador de CSS, [SASS, con la sintaxis SCSS](http://sass-lang.com/guide). ### Javascript -Si quieres agregar código Javascript puedes hacerlo en el fichero *app/assets/javascripts/custom.js". Por ejemplo si quieres que salga una alerta puedes poner lo siguiente: +Si quieres agregar código Javascript puedes hacerlo en el fichero `app/assets/javascripts/custom.js`. Por ejemplo si quieres que salga una alerta puedes poner lo siguiente: -``` +```js $(function(){ alert('foobar'); }); @@ -81,11 +82,11 @@ $(function(){ ### Modelos -Si quieres agregar modelos nuevos, o modificar o agregar métodos a uno ya existente puedes hacerlo en *app/models/custom*. En el caso de los modelos antiguos debes primero hacer un require de la dependencia. +Si quieres agregar modelos nuevos, o modificar o agregar métodos a uno ya existente puedes hacerlo en `app/models/custom`. En el caso de los modelos antiguos debes primero hacer un require de la dependencia. -Por ejemplo en el caso del Ayuntamiento de Madrid se requiere comprobar que el código postal durante la verificación sigue un cierto formato (empieza con 280). Esto se realiza creando este fichero en *app/models/custom/verification/residence.rb*: +Por ejemplo en el caso del Ayuntamiento de Madrid se requiere comprobar que el código postal durante la verificación sigue un cierto formato (empieza con 280). Esto se realiza creando este fichero en `app/models/custom/verification/residence.rb`: -``` +```ruby require_dependency Rails.root.join('app', 'models', 'verification', 'residence').to_s class Verification::Residence @@ -116,17 +117,17 @@ class Verification::Residence end ``` -No olvides poner los tests relevantes en *spec/models/custom*, siguiendo con el ejemplo pondriamos lo siguiente en *spec/models/custom/residence_spec.rb*: +No olvides poner los tests relevantes en `spec/models/custom`, siguiendo con el ejemplo pondriamos lo siguiente en `spec/models/custom/residence_spec.rb`: -``` +```ruby require 'rails_helper' describe Verification::Residence do - + let(:residence) { build(:verification_residence, document_number: "12345678Z") } - describe "verification" do + describe "verification" do describe "postal code" do it "should be valid with postal codes starting with 280" do @@ -162,20 +163,20 @@ TODO ### Gemfile -Para agregar librerías (gems) nuevas puedes hacerlo en el fichero *Gemfile_custom*. Por ejemplo si quieres agregar la gema [rails-footnotes](https://github.com/josevalim/rails-footnotes) debes hacerlo agregandole +Para agregar librerías (gems) nuevas puedes hacerlo en el fichero `Gemfile_custom`. Por ejemplo si quieres agregar la gema [rails-footnotes](https://github.com/josevalim/rails-footnotes) debes hacerlo agregandole -``` +```ruby gem 'rails-footnotes', '~> 4.0' ``` -Y siguiendo el flujo clásico en Ruby on Rails (bundle install y seguir con los pasos específicos de la gema en la documentación) +Y siguiendo el flujo clásico en Ruby on Rails (`bundle install` y seguir con los pasos específicos de la gema en la documentación) -### application.rb +### application.rb -Cuando necesites extender o modificar el *config/application.rb* puedes hacerlo a través del fichero *config/application_custom.rb*. Por ejemplo si quieres modificar el idioma por defecto al inglés pondrías lo siguiente: +Cuando necesites extender o modificar el `config/application.rb` puedes hacerlo a través del fichero `config/application_custom.rb`. Por ejemplo si quieres modificar el idioma por defecto al inglés pondrías lo siguiente: -``` +```ruby module Consul class Application < Rails::Application config.i18n.default_locale = :en @@ -198,15 +199,15 @@ TODO TODO -## Actualizar +## Actualizar -Te recomendamos que agregues el remote de consul para facilitar este proceso de merge: +Te recomendamos que agregues el remote de consul para facilitar este proceso de merge: ``` -$ git remote add consul https://github.com/consul/consul +$ git remote add consul https://github.com/consul/consul ``` -Con esto puedes actualizarte con +Con esto puedes actualizarte con ``` git checkout -b consul_update diff --git a/Capfile b/Capfile index 0f53b8e9a..1a33b63f0 100644 --- a/Capfile +++ b/Capfile @@ -4,13 +4,13 @@ require 'capistrano/setup' # Include default deployment tasks require 'capistrano/deploy' -require 'capistrano/rvm' -require 'capistrano/bundler' +require "capistrano/bundler" require 'capistrano/rails/assets' require 'capistrano/rails/migrations' #require 'capistrano/passenger' require 'capistrano/delayed_job' require 'whenever/capistrano' +require 'rvm1/capistrano3' # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index a57c2a7f1..07b629886 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'pg', '~> 0.19.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0', '>= 5.0.4' # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 3.0.3' +gem 'uglifier', '>= 3.0.4' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2.1' # See https://github.com/rails/execjs#readme for more supported runtimes @@ -32,7 +32,7 @@ gem 'omniauth-facebook', '~> 3.0.0' gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'kaminari' -gem 'ancestry', '~> 2.2.1' +gem 'ancestry', '~> 2.2.2' gem 'acts-as-taggable-on' gem 'responders', '~> 2.3.0' gem 'foundation-rails', '~> 6.2.4.0' @@ -52,12 +52,13 @@ gem 'rollbar', '~> 2.13.3' gem 'delayed_job_active_record', '~> 4.1.0' gem 'daemons' gem 'devise-async' -gem 'newrelic_rpm', '~> 3.17.0.325' +gem 'newrelic_rpm', '~> 3.17.1.326' gem 'whenever', require: false gem 'pg_search' +gem 'sitemap_generator' gem 'ahoy_matey', '~> 1.4.2' -gem 'groupdate', '~> 3.1.0' # group temporary data +gem 'groupdate', '~> 3.1.0' # group temporary data gem 'tolk', '~> 2.0.0' # Web interface for translations gem 'browser' @@ -79,12 +80,14 @@ group :development, :test do gem 'letter_opener_web', '~> 1.3.0' gem 'i18n-tasks' gem 'capistrano', '3.5.0', require: false - gem "capistrano-bundler", '1.1.4', require: false + gem 'capistrano-bundler', '~> 1.2', require: false gem "capistrano-rails", '1.1.8', require: false - gem "capistrano-rvm", require: false + gem 'rvm1-capistrano3', require: false gem 'capistrano3-delayed-job', '~> 1.0' gem "bullet" gem "faker" + gem 'rubocop', '~> 0.45.0', require: false + gem 'knapsack' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 5e99a8030..fe1948752 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,18 +56,18 @@ GEM akami (1.3.1) gyoku (>= 0.4.0) nokogiri - ancestry (2.2.1) + ancestry (2.2.2) activerecord (>= 3.0.0) arel (6.0.3) - ast (2.2.0) + ast (2.3.0) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) bcrypt (3.1.11) - browser (2.2.0) + browser (2.3.0) builder (3.2.2) - bullet (5.2.0) + bullet (5.4.2) activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) byebug (9.0.6) @@ -78,16 +78,13 @@ GEM i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (1.1.4) + capistrano-bundler (1.2.0) capistrano (~> 3.1) sshkit (~> 1.2) capistrano-harrow (0.5.3) capistrano-rails (1.1.8) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rvm (0.1.2) - capistrano (~> 3.0) - sshkit (~> 1.2) capistrano3-delayed-job (1.7.2) capistrano (~> 3.0, >= 3.0.0) capybara (2.7.1) @@ -114,12 +111,12 @@ GEM execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.2) - coveralls (0.8.15) + coveralls (0.8.17) json (>= 1.8, < 3) simplecov (~> 0.12.0) term-ansicolor (~> 1.3) thor (~> 0.19.1) - tins (>= 1.6.0, < 2) + tins (~> 1.6) daemons (1.2.4) dalli (2.7.6) database_cleaner (1.5.3) @@ -173,8 +170,8 @@ GEM activesupport (>= 4.1) railties (>= 4.1) tzinfo (~> 1.2, >= 1.2.2) - fuubar (2.1.1) - rspec (~> 3.0) + fuubar (2.2.0) + rspec-core (~> 3.0) ruby-progressbar (~> 1.4) geocoder (1.4.0) globalid (0.3.7) @@ -183,13 +180,13 @@ GEM activesupport (>= 3) gyoku (1.3.1) builder (>= 2.1.2) - hashie (3.4.3) + hashie (3.4.6) highline (1.7.8) htmlentities (4.3.4) httpi (2.4.1) rack i18n (0.7.0) - i18n-tasks (0.9.5) + i18n-tasks (0.9.6) activesupport (>= 4.0.2) ast (>= 2.1.0) easy_translate (>= 0.5.0) @@ -215,6 +212,9 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.10.0) + knapsack (1.13.1) + rake + timecop (>= 0.1.0) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.4.1) @@ -231,14 +231,14 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.1) + minitest (5.10.1) multi_json (1.12.1) multi_xml (0.5.5) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (3.2.0) - newrelic_rpm (3.17.0.325) + newrelic_rpm (3.17.1.326) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) nori (2.6.0) @@ -271,7 +271,7 @@ GEM orm_adapter (0.5.0) paranoia (2.2.0) activerecord (>= 4.0, < 5.1) - parser (2.3.0.6) + parser (2.3.3.1) ast (~> 2.2) pg (0.19.0) pg_search (1.0.6) @@ -282,9 +282,10 @@ GEM capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) + powerpack (0.1.1) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.4) + rack (1.6.5) rack-accept (0.4.5) rack (>= 0.4) rack-attack (5.0.1) @@ -315,8 +316,9 @@ GEM activesupport (= 4.2.7.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.16.0) - rake (11.3.0) + rainbow (2.1.0) + raindrops (0.17.0) + rake (12.0.0) redcarpet (3.3.4) referer-parser (0.3.0) request_store (1.3.1) @@ -325,10 +327,6 @@ GEM rinku (2.0.2) rollbar (2.13.3) multi_json - rspec (3.5.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) @@ -346,7 +344,16 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) + rubocop (0.45.0) + parser (>= 2.3.1.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) + rvm1-capistrano3 (1.4.0) + capistrano (~> 3.0) + sshkit (>= 1.2) safe_yaml (1.0.4) safely_block (0.1.1) errbase @@ -370,6 +377,8 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) + sitemap_generator (5.2.0) + builder (~> 3.0) social-share-button (0.3.1) coffee-rails sass-rails @@ -387,17 +396,19 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.11.3) + sshkit (1.11.4) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - term-ansicolor (1.3.2) + term-ansicolor (1.4.0) tins (~> 1.0) - terminal-table (1.5.2) - thor (0.19.1) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) + thor (0.19.4) thread (0.2.2) thread_safe (0.3.5) tilt (2.0.5) - tins (1.11.0) + timecop (0.8.1) + tins (1.13.0) tolk (2.0.0) rails (>= 4.0) safe_yaml (>= 0.8.6) @@ -410,8 +421,9 @@ GEM tilt (>= 1.4, < 3) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (3.0.3) + uglifier (3.0.4) execjs (>= 0.3.0, < 3) + unicode-display_width (1.1.1) unicorn (5.1.0) kgio (~> 2.6) raindrops (~> 0.7) @@ -442,15 +454,14 @@ DEPENDENCIES acts-as-taggable-on acts_as_votable ahoy_matey (~> 1.4.2) - ancestry (~> 2.2.1) + ancestry (~> 2.2.2) browser bullet byebug cancancan capistrano (= 3.5.0) - capistrano-bundler (= 1.1.4) + capistrano-bundler (~> 1.2) capistrano-rails (= 1.1.8) - capistrano-rvm capistrano3-delayed-job (~> 1.0) capybara ckeditor (~> 4.2.0) @@ -476,9 +487,10 @@ DEPENDENCIES jquery-rails (~> 4.2.1) jquery-ui-rails kaminari + knapsack launchy letter_opener_web (~> 1.3.0) - newrelic_rpm (~> 3.17.0.325) + newrelic_rpm (~> 3.17.1.326) omniauth omniauth-facebook (~> 3.0.0) omniauth-google-oauth2 (~> 0.4.0) @@ -494,8 +506,11 @@ DEPENDENCIES rinku (~> 2.0.2) rollbar (~> 2.13.3) rspec-rails (~> 3.5) + rubocop (~> 0.45.0) + rvm1-capistrano3 sass-rails (~> 5.0, >= 5.0.4) savon + sitemap_generator social-share-button spring spring-commands-rspec @@ -503,10 +518,10 @@ DEPENDENCIES tolk (~> 2.0.0) turbolinks turnout (~> 2.4.0) - uglifier (>= 3.0.3) + uglifier (>= 3.0.4) unicorn (~> 5.1.0) web-console (= 3.3.0) whenever BUNDLED WITH - 1.13.1 + 1.13.6 diff --git a/README.md b/README.md index b6c10b878..c62fcfeec 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Citizen Participation and Open Government Application +[![Join the chat at https://gitter.im/consul/consul](https://badges.gitter.im/consul/consul.svg)](https://gitter.im/consul/consul?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/consul/consul.svg?branch=master)](https://travis-ci.org/consul/consul) [![Code Climate](https://codeclimate.com/github/consul/consul/badges/gpa.svg)](https://codeclimate.com/github/consul/consul) [![Dependency Status](https://gemnasium.com/consul/consul.svg)](https://gemnasium.com/consul/consul) @@ -26,7 +27,7 @@ Frontend tools used include [SCSS](http://sass-lang.com/) over [Foundation](http **NOTE**: For more detailed instructions check the [docs](https://github.com/consul/consul/tree/master/doc/en/dev_test_setup.md) -Prerequisites: install git, Ruby 2.2.3, bundler gem, ghostscript and PostgreSQL (>=9.4). +Prerequisites: install git, Ruby 2.3.2, bundler gem, ghostscript and PostgreSQL (>=9.4). ``` git clone https://github.com/consul/consul.git diff --git a/README_ES.md b/README_ES.md index 6f0f413ec..1b197e983 100644 --- a/README_ES.md +++ b/README_ES.md @@ -5,6 +5,7 @@ Aplicación de Participación Ciudadana y Gobierno Abierto +[![Join the chat at https://gitter.im/consul/consul](https://badges.gitter.im/consul/consul.svg)](https://gitter.im/consul/consul?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/consul/consul.svg?branch=master)](https://travis-ci.org/consul/consul) [![Code Climate](https://codeclimate.com/github/consul/consul/badges/gpa.svg)](https://codeclimate.com/github/consul/consul) [![Dependency Status](https://gemnasium.com/consul/consul.svg)](https://gemnasium.com/consul/consul) @@ -25,7 +26,7 @@ Las herramientas utilizadas para el frontend no están cerradas aún. Los estilo **NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://github.com/consul/consul/tree/master/doc/es/dev_test_setup.md) -Prerequisitos: tener instalado git, Ruby 2.2.3, la gema `bundler`, ghostscript y PostgreSQL (9.4 o superior). +Prerequisitos: tener instalado git, Ruby 2.3.2, la gema `bundler`, ghostscript y PostgreSQL (9.4 o superior). ``` diff --git a/Rakefile b/Rakefile index ba6b733dd..ef2c381ff 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,4 @@ require File.expand_path('../config/application', __FILE__) Rails.application.load_tasks +Knapsack.load_tasks if defined?(Knapsack) \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7fb92b5e3..10339e995 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -45,6 +45,7 @@ //= require valuation_spending_proposal_form //= require embed_video //= require banners +//= require social_share //= require custom var initialize_modules = function() { @@ -66,6 +67,7 @@ var initialize_modules = function() { App.ValuationSpendingProposalForm.initialize(); App.EmbedVideo.initialize(); App.Banners.initialize(); + App.SocialShare.initialize(); }; $(function(){ diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index 876a89b20..fefe85544 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -52,5 +52,6 @@ App.Comments = children_container_id = "#{$(this).data().id}_children" $("##{children_container_id}").toggle('slow') App.Comments.toggle_arrow(children_container_id) + $(this).children('.js-child-toggle').toggle() false ) diff --git a/app/assets/javascripts/social_share.js.coffee b/app/assets/javascripts/social_share.js.coffee new file mode 100644 index 000000000..a61f2d8f4 --- /dev/null +++ b/app/assets/javascripts/social_share.js.coffee @@ -0,0 +1,7 @@ +App.SocialShare = + + initialize: -> + $(".social-share-button a").each -> + element = $(this) + site = element.data('site') + element.append("#{site}") \ No newline at end of file diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss index 1fa432704..9fe4f85a2 100644 --- a/app/assets/stylesheets/_settings.scss +++ b/app/assets/stylesheets/_settings.scss @@ -51,22 +51,22 @@ $base-font-size: rem-calc(17); $base-line: rem-calc(26); $small-font-size: rem-calc(14); $line-height: rem-calc(24); +$tiny-font-size: rem-calc(12); $brand: #004A83; $dark: darken($brand, 10%); $text: #222222; -$text-medium: #999999; -$text-light: #CCCCCC; +$text-medium: #515151; +$text-light: #BFBFBF; $border: #DEE0E3; -$link: #2895F1; +$link: $brand; $link-hover: darken($link, 20%); -$debates: #008CCF; +$debates: $brand; -$votes: #26AEEE; $like: #7BD2A8; $unlike: #EF8585; @@ -74,13 +74,14 @@ $delete: #F04124; $check: #46DB91; $proposals: #FFA42D; +$proposals-dark: #794500; $budget: #454372; $budget-hover: #7571BF; $highlight: #E7F2FC; $light: #F5F7FA; -$featured: #FED900; +$featured: #FFDC5C; $footer-border: #BFC1C3; diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss index 403d5566d..cd33ac92d 100644 --- a/app/assets/stylesheets/foundation_and_overrides.scss +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -34,3 +34,4 @@ @include foundation-thumbnail; @include foundation-title-bar; @include foundation-top-bar; +@include foundation-menu-icon; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 106c0e3e6..ce46bb0c8 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -56,6 +56,7 @@ a { } &:focus { + color: $link-hover; outline: 3px solid #ffbf47; } } @@ -273,7 +274,7 @@ a { } } - h2 { + h2, h3 { font-size: $base-font-size; } } @@ -286,6 +287,10 @@ a { margin: 0 $line-height/2; } +.pagination .current { + background: $brand; +} + // 02. Header // ---------- @@ -394,6 +399,10 @@ header { text-decoration: underline; } } + + ul { + margin-bottom: 0; + } } .subnavigation { @@ -503,8 +512,16 @@ header { &.active { border-bottom: 2px solid $brand; color: $brand; + + &:hover { + text-decoration: none; + } } } + + h2 { + font-size: $base-font-size; + } } .search-form-header input[type=text] { @@ -529,7 +546,7 @@ footer { p { font-size: $small-font-size; - .info a { + &.info a { text-decoration: underline; } } @@ -566,6 +583,7 @@ footer { .subfooter { border-top: 1px solid $text-light; + font-size: $small-font-size; padding-top: $line-height/2; } @@ -598,7 +616,7 @@ footer { } } -h3.sidebar-title { +h2.sidebar-title { border-top: 2px solid $brand; display: inline-block; font-size: rem-calc(16); @@ -912,16 +930,12 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { } .author-deleted, .user-deleted { - background-color: rgba(255,255,255,.5); color: rgba(0,0,0,.4); - font-size: rem-calc(40); - left: 11px; - position: absolute; - top: 72px; -} - -.user-deleted { - top: -4px; + display: inline-block; + font-size: rem-calc(32); + line-height: rem-calc(32); + height: rem-calc(32); + vertical-align: top; } .user-permissions { @@ -1176,7 +1190,7 @@ table { top: 0; } - &:hover { + &:hover, &:focus { background: white; color: #40A2D1; } @@ -1216,7 +1230,7 @@ table { top: 0; } - &:hover { + &:hover, &:focus { background: white; color: #354F88; } @@ -1256,7 +1270,7 @@ table { top: 0; } - &:hover { + &:hover, &:focus { background: white; color: #CE3E26; } @@ -1276,13 +1290,14 @@ table { } .share-supported { + text-align: center; .social-share-button { display: inline-block; } .ssb-twitter { - background: none; + background: #45B0E3; color: white; height: $line-height; position: relative; @@ -1299,13 +1314,14 @@ table { top: 0; } - &:hover { + &:hover, &:focus { + background: white; color: #40A2D1; } } .ssb-facebook { - background: none; + background: #3B5998; color: white; height: rem-calc(24); position: relative; @@ -1322,13 +1338,14 @@ table { top: 0; } - &:hover { + &:hover, &:focus { + background: white; color: #354F88; } } .ssb-google_plus { - background: none; + background: #DE4C34; color: white; height: rem-calc(24); position: relative; @@ -1345,7 +1362,8 @@ table { top: 0; } - &:hover { + &:hover, &:focus { + background: white; color: #CE3E26; } } @@ -1579,7 +1597,7 @@ table { .comment-votes { color: $text-medium; - font-size: rem-calc(14); + font-size: $small-font-size; line-height: $line-height; a { @@ -1589,17 +1607,29 @@ table { &:hover { color: $text-medium; + text-decoration: none; + + .icon-like { + color: $like; + } + + .icon-unlike { + color: $unlike; + } } } [class^="icon-"] { - font-size: rem-calc(20); - vertical-align: middle; + font-size: $base-font-size; + vertical-align: sub; } } .comment-body { - margin-left: rem-calc(42); + + img { + margin-right: $line-height/2; + } .reply { background: white; @@ -1607,20 +1637,28 @@ table { border-left: 0; border-right: 0; font-size: $small-font-size; - margin: rem-calc(6) 0; - padding: rem-calc(6); + margin: $line-height/4 0; + padding: $line-height/4; position: relative; + a.relative, [class^="icon-arrow"] { + padding-left: $line-height/2; + } + [class^="icon-arrow"] { - font-size: rem-calc(18); + font-size: $base-font-size; left: -20px; position: absolute; - top: 0; + top: -1px; } .divider { color: $text-light; } + + form { + margin-top: $line-height/2; + } } .comment-user { @@ -1650,13 +1688,13 @@ table { .is-deleted { background: #E7E7E7; - margin-left: rem-calc(42); - padding: $line-height/4 $line-height/2; + margin-left: $line-height; + padding: $line-height/2; } .comment-children { border-left: 1px dashed $border; - margin-left: rem-calc(42); + margin-left: $line-height; padding-left: $line-height/4; @media only screen and (max-width: 40em) { @@ -1666,9 +1704,9 @@ table { .comment-info { color: $text-medium; + display: inline-block; font-size: $small-font-size; - margin-top: $line-height/4; - vertical-align: middle; + line-height: rem-calc(32); // Same as avatar height span.user-name { color: $text; @@ -1714,7 +1752,8 @@ table { } .flag-disable, .flag-active { - vertical-align: middle; + line-height: 0; + vertical-align: sub; } .flag-disable { diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 3858bbcef..a375df091 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -13,14 +13,21 @@ // ---------------------- @mixin votes { - background: $votes; - margin: 0 rem-calc(-12); - padding: rem-calc(14) rem-calc(12); + border-top: 1px solid $border; + margin-top: $line-height; + padding: $line-height 0; position: relative; + @include breakpoint(medium) { + border-left: 1px solid $border; + border-top: 0; + margin-top: 0; + padding-top: $line-height*2; + } + .icon-like, .icon-unlike { background: white; - border: 2px solid $votes; + border: 2px solid $text-light; border-radius: rem-calc(3); color: $text-light; display: inline-block; @@ -30,7 +37,6 @@ position: relative; &:hover, &:active { - border-color: white; color: white; cursor: pointer; opacity: 1 !important; @@ -41,6 +47,7 @@ &:hover, &:active { background: $like; + border: 2px solid $like; } } @@ -48,50 +55,64 @@ &:hover, &:active { background: $unlike; + border: 2px solid $unlike; } } .like, .unlike { line-height: rem-calc(48); vertical-align: super; + text-decoration: none; span.percentage { - color: white; + color: $text; display: inline-block; - font-size: rem-calc(16); + font-size: $small-font-size; line-height: $line-height*2; - padding-left: rem-calc(8); + padding-right: $line-height/2; vertical-align: top; + + @include breakpoint(medium) { + display: block; + line-height: $line-height; + padding-right: 0; + } } } .voted { .icon-like, .icon-unlike { - border-color: white; color: white; } .icon-like { background: $like; + border: 2px solid $like; } .icon-unlike { background: $unlike; + border: 2px solid $unlike; } } .no-voted { .icon-like, .icon-unlike { - opacity: .5; + opacity: .3; } } .total-votes { - color: white; + font-weight: bold; float: right; line-height: $line-height*2; + + @include breakpoint(medium) { + display: block; + float: none; + } } .divider { @@ -100,64 +121,65 @@ } @mixin supports { - background: $proposals; - margin: 0 rem-calc(-12); - padding: rem-calc(14) rem-calc(12); + padding: $line-height 0; position: relative; .progress { - background-color: rgba(255,255,255,.8); - height: $line-height/2; + background: lighten($proposals, 35%); + border: 1px solid lighten($proposals, 35%); + height: rem-calc(14); + position: relative; .meter { - background: $like; + background: $proposals; + border-radius: 0; + border-bottom-right-radius: rem-calc(3); + border-top-right-radius: rem-calc(3); display: block; height: $line-height/2; } } .percentage { - font-size: rem-calc(10); - color: $brand; - vertical-align: top; + color: $text; + font-size: $tiny-font-size; position: absolute; - top: 13px; - right: 20px; + right: 6px; + top: -2px; + vertical-align: top; } abbr { - color: white; + color: $text-medium; &[title] { - border-bottom: 1px dotted white; + border-bottom: 1px dotted $text-medium; } } .button-support { - background: white; + background: $proposals; color: $text; display: inline-block; font-size: $small-font-size; margin-top: rem-calc(12); - &:hover { - background: darken($proposals, 35%); - color: white; + &:hover, &:active { + background: lighten($proposals, 25%); cursor: pointer; } - - &:active { - opacity: .75; - } } .total-supports { - color: white; + color: $text; + display: block; + font-weight: bold; text-align: center; - font-size: $small-font-size; span { display: block; + font-size: $small-font-size; + font-weight: normal; } } @@ -166,23 +188,17 @@ } .supported { - color: white; + color: $text; margin-top: rem-calc(12); } } -.message { - @include supports; - background: none; - border-top: 0; +.supports-container { + border-top: 1px solid $border; @include breakpoint(medium) { border-left: 1px solid $border; - margin: $line-height rem-calc(-25) 0 rem-calc(12); - } - - p { - font-size: $small-font-size; + border-top: 0; } } @@ -277,7 +293,9 @@ // 03. Show participation // ---------------------- -.debate-show, .proposal-show, .investment-project-show { +.debate-show, +.proposal-show, +.investment-project-show { p { word-wrap: break-word; @@ -308,9 +326,13 @@ clear: both; color: $text-medium; font-size: $small-font-size; - min-height: $line-height*2; + margin-bottom: $line-height/2; position: relative; + span { + line-height: rem-calc(32); // Same as avatar height + } + a { color: $text-medium; } @@ -320,15 +342,6 @@ line-height: $line-height; margin: 0; } - - .author-deleted { - left: 0; - top: 4px; - } - - .author.deleted { - margin-left: rem-calc(48); - } } .debate-description, .proposal-description { @@ -343,12 +356,19 @@ font-size: rem-calc(15); margin-bottom: rem-calc(15); } + + &.tags, &.geozone { + + li { + margin-bottom: 0; + } + } } .author-photo { - line-height: $line-height*2; + line-height: rem-calc(32); margin-right: rem-calc(6); - vertical-align: middle; + vertical-align: top; width: 32px; } @@ -366,7 +386,7 @@ aside { - h3 { + h2 { border-top: 2px solid $brand; display: inline-block; font-size: rem-calc(16); @@ -414,47 +434,8 @@ } } - .votes { - @include votes; - border: 0; - border-radius: 0; - margin: 0; - - .total-votes { - display: block; - float: none; - line-height: $line-height; - } - - @include breakpoint(small + rem-calc(1) and medium down) { - .in-favor, .against { - text-align: left; - width: rem-calc(100); - } - } - - .divider { - display: none; - } - - @include breakpoint(medium) { - .divider { - display: inline-block; - } - } - } - .supports { @include supports; - border: 0; - border-radius: 0; - margin: 0; - - .total-supports { - display: block; - float: none; - line-height: $line-height; - } } .leave-comment { @@ -479,6 +460,17 @@ word-break: break-word; } +.proposal-show, .investment-project-show { + + .supports { + padding: $line-height/2 0 0; + } + + .share-supported { + display: none; + } +} + // 04. List participation // ---------------------- @@ -497,8 +489,7 @@ } .debate, .proposal, .investment-project { - margin-bottom: 0; - margin-top: 0; + margin: $line-height/4 0; .panel { background: white; @@ -533,7 +524,7 @@ } .label-proposal { - color: $proposals; + color: $proposals-dark; } .label-investment-project { @@ -571,7 +562,7 @@ } .icon-proposals { - color: $proposals; + color: $proposals-dark; } .icon-budget { @@ -652,107 +643,30 @@ } } -.debate { +.debate, .debate-show { .votes { @include votes; - border: 1px solid $votes; - margin: 0 rem-calc(-12); - @include breakpoint(medium) { - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - margin: 0 rem-calc(-25) 0 rem-calc(12); - } - - &:after { - content: none; - position: absolute; - display: block; - border-style: solid; - border-color: #166387 transparent transparent transparent; - bottom: -14px; - border-left-width: 0; - border-right-color: transparent; - right: -1px; - border-width: 13px 13px 0 0; - - @include breakpoint(medium) { - content: ""; - } - } - - .total-votes { - display: inline-block; - line-height: $line-height; - margin-left: rem-calc(24); - padding-top: rem-calc(12); - vertical-align: top; - - @include breakpoint(medium) { - display: block; - float: none; - line-height: $line-height*2; - margin-left: 0; - padding-top: 0; - } + .against { + margin-left: $line-height/4; } @include breakpoint(medium) { - .like, .unlike { - - span.percentage { - display: block; - line-height: $line-height/2; - } - } + text-align: center; } } } +.debate-show .votes { + border: 0; + padding: $line-height/2 0; +} + .proposal { .supports { @include supports; - border: 1px solid $proposals; - margin: 0 rem-calc(-12); - - @include breakpoint(medium) { - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - margin: 0 rem-calc(-25) 0 rem-calc(12); - } - - &:after { - content: none; - position: absolute; - display: block; - border-style: solid; - border-color: #664212 transparent transparent transparent; - bottom: -14px; - border-left-width: 0; - border-right-color: transparent; - right: -1px; - border-width: 13px 13px 0 0; - - @include breakpoint(medium) { - content: ""; - } - } - - .total-supports { - display: inline-block; - line-height: $line-height; - padding-top: rem-calc(12); - vertical-align: top; - - @include breakpoint(medium) { - display: block; - float: none; - margin-left: 0; - padding-top: 0; - } - } } } @@ -760,20 +674,6 @@ .supports { @include supports; - background: none; - border: 0; - border-left: 1px solid $border; - margin: 0 rem-calc(-12); - min-height: rem-calc(180); - padding-top: 0; - - @include breakpoint(medium) { - padding-top: $line-height*1.5; - } - - &:after { - content: none; - } .investment-project-amount { color: $budget; @@ -803,33 +703,14 @@ font-weight: bold; } - .supported { - color: $budget; - margin-top: 0; - width: 100%; - } - .remove .icon-check-circle { display: block; font-size: rem-calc(70); line-height: rem-calc(70); } - - .share-supported { - - .ssb-twitter, - .ssb-facebook, - .ssb-google_plus { - color: $budget; - } - } } } -.investment-project-show .supports { - border: 0; -} - .proposals-summary { .panel { @@ -904,7 +785,14 @@ } .button-support { + background: $text; + color: $featured; margin-top: 0; + + &:hover { + background: white; + color: $text; + } } .participation-not-allowed { @@ -925,6 +813,7 @@ .supported { margin-top: 0; + font-size: $small-font-size; } .share-supported { @@ -932,7 +821,10 @@ .ssb-twitter, .ssb-facebook, .ssb-google_plus { - height: rem-calc(33); + background: none; + color: $text; + height: rem-calc(33) !important; + &:before { font-size: rem-calc(18); @@ -946,7 +838,37 @@ // 06. Proposals successful // ------------------------- -.sucessfull-proposals-banner { +.dark-heading { + background: #2D3E50; + color: white; + + @include breakpoint(medium) { + padding-bottom: $line-height; + } + + p { + + &.title { + color: #FFD200; + } + + &.title-date { + font-size: rem-calc(24); + font-weight: bold; + } + } + + .info { + background: #314253; + padding-top: $line-height; + + @include breakpoint(medium) { + border-top: rem-calc(6) solid #FFD200; + } + } +} + +.featured-proposals-ballot-banner, .sucessfull-proposals-banner { background: #2D3E50 image-url("ballot_tiny.gif") no-repeat; background-position: 75% 0; position: relative; diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index c3d814b38..c46b6e42f 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -29,4 +29,4 @@ class AccountController < ApplicationController end end -end +end \ No newline at end of file diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb index dbf683b9a..b919e0861 100644 --- a/app/controllers/admin/banners_controller.rb +++ b/app/controllers/admin/banners_controller.rb @@ -2,7 +2,6 @@ class Admin::BannersController < Admin::BaseController has_filters %w{all with_active with_inactive}, only: :index - before_action :find_banner, only: [:edit, :update, :destroy] before_action :banner_styles, only: [:edit, :new, :create, :update] before_action :banner_imgs, only: [:edit, :new, :create, :update] @@ -24,7 +23,6 @@ class Admin::BannersController < Admin::BaseController end def update - @banner.assign_attributes(banner_params) if @banner.update(banner_params) redirect_to admin_banners_path else @@ -38,14 +36,11 @@ class Admin::BannersController < Admin::BaseController end private + def banner_params params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at) end - def find_banner - @banner = Banner.find(params[:id]) - end - def banner_styles @banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] } end @@ -53,4 +48,5 @@ class Admin::BannersController < Admin::BaseController def banner_imgs @banner_imgs = Setting.all.banner_img.map { |banner_img| [banner_img.value, banner_img.key.split('.')[1]] } end + end \ No newline at end of file diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index a0272f367..1f3d8e837 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -20,8 +20,9 @@ class Admin::CommentsController < Admin::BaseController end private + def load_comment @comment = Comment.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index f7aa5c440..5fb5e3c13 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -3,4 +3,4 @@ class Admin::DashboardController < Admin::BaseController def index end -end +end \ No newline at end of file diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb index 0b0b31b8b..bbe4a06d7 100644 --- a/app/controllers/admin/debates_controller.rb +++ b/app/controllers/admin/debates_controller.rb @@ -29,4 +29,4 @@ class Admin::DebatesController < Admin::BaseController @debate = Debate.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/geozones_controller.rb b/app/controllers/admin/geozones_controller.rb new file mode 100644 index 000000000..b73c13422 --- /dev/null +++ b/app/controllers/admin/geozones_controller.rb @@ -0,0 +1,49 @@ +class Admin::GeozonesController < Admin::BaseController + + respond_to :html + + load_and_authorize_resource + + def index + @geozones = Geozone.all.order("LOWER(name)") + end + + def new + end + + def edit + end + + def create + @geozone = Geozone.new(geozone_params) + + if @geozone.save + redirect_to admin_geozones_path + else + render :new + end + end + + def update + if @geozone.update(geozone_params) + redirect_to admin_geozones_path + else + render :edit + end + end + + def destroy + if @geozone.safe_to_destroy? + @geozone.destroy + redirect_to admin_geozones_path, notice: t('admin.geozones.delete.success') + else + redirect_to admin_geozones_path, flash: { error: t('admin.geozones.delete.error') } + end + end + + private + + def geozone_params + params.require(:geozone).permit(:name, :external_code, :census_code, :html_map_coordinates) + end +end diff --git a/app/controllers/admin/officials_controller.rb b/app/controllers/admin/officials_controller.rb index 2d570c2dc..e0a0a86ca 100644 --- a/app/controllers/admin/officials_controller.rb +++ b/app/controllers/admin/officials_controller.rb @@ -25,8 +25,9 @@ class Admin::OfficialsController < Admin::BaseController end private + def user_params params.require(:user).permit(:official_position, :official_level) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index 77f71ed65..b85460459 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -27,4 +27,4 @@ class Admin::OrganizationsController < Admin::BaseController redirect_to request.query_parameters.merge(action: :index) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index e7c4934fa..2a6dfd718 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -25,4 +25,4 @@ class Admin::ProposalsController < Admin::BaseController @proposal = Proposal.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 17bd364f3..f17afff4c 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -15,7 +15,9 @@ class Admin::SettingsController < Admin::BaseController end private + def settings_params params.require(:setting).permit(:value) end + end \ No newline at end of file diff --git a/app/controllers/admin/signature_sheets_controller.rb b/app/controllers/admin/signature_sheets_controller.rb new file mode 100644 index 000000000..60299c5a6 --- /dev/null +++ b/app/controllers/admin/signature_sheets_controller.rb @@ -0,0 +1,32 @@ +class Admin::SignatureSheetsController < Admin::BaseController + + def index + @signature_sheets = SignatureSheet.all + end + + def new + @signature_sheet = SignatureSheet.new + end + + def create + @signature_sheet = SignatureSheet.new(signature_sheet_params) + @signature_sheet.author = current_user + if @signature_sheet.save + @signature_sheet.delay.verify_signatures + redirect_to [:admin, @signature_sheet], notice: I18n.t('flash.actions.create.signature_sheet') + else + render :new + end + end + + def show + @signature_sheet = SignatureSheet.find(params[:id]) + end + + private + + def signature_sheet_params + params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers) + end + +end \ No newline at end of file diff --git a/app/controllers/admin/spending_proposals_controller.rb b/app/controllers/admin/spending_proposals_controller.rb index e4c13e612..b5923f2f6 100644 --- a/app/controllers/admin/spending_proposals_controller.rb +++ b/app/controllers/admin/spending_proposals_controller.rb @@ -54,4 +54,4 @@ class Admin::SpendingProposalsController < Admin::BaseController @tags = ActsAsTaggableOn::Tag.spending_proposal_tags end -end +end \ No newline at end of file diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index 7e5b902e9..3624174a5 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -32,4 +32,5 @@ class Admin::StatsController < Admin::BaseController @direct_messages = DirectMessage.count @users_who_have_sent_message = DirectMessage.select(:sender_id).distinct.count end -end + +end \ No newline at end of file diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index eed1c4fea..1e17e1c2d 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -30,4 +30,4 @@ class Admin::UsersController < Admin::BaseController @user = User.with_hidden.find(params[:id]) end -end +end \ No newline at end of file diff --git a/app/controllers/admin/valuators_controller.rb b/app/controllers/admin/valuators_controller.rb index 3e403c9fc..4b52a753e 100644 --- a/app/controllers/admin/valuators_controller.rb +++ b/app/controllers/admin/valuators_controller.rb @@ -30,8 +30,10 @@ class Admin::ValuatorsController < Admin::BaseController end private + def create_params params[:valuator][:description] = nil if params[:valuator][:description].blank? params.require(:valuator).permit(:user_id, :description) end -end + +end \ No newline at end of file diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index df928aa02..0a0018c9f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -77,4 +77,4 @@ class CommentsController < ApplicationController Notification.add(notifiable.author_id, notifiable) unless comment.author_id == notifiable.author_id end -end +end \ No newline at end of file diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 3f4398797..ef5e60dcb 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -155,4 +155,4 @@ module CommentableActions nil end -end +end \ No newline at end of file diff --git a/app/controllers/concerns/moderate_actions.rb b/app/controllers/concerns/moderate_actions.rb index 792dacde0..05aa0e97f 100644 --- a/app/controllers/concerns/moderate_actions.rb +++ b/app/controllers/concerns/moderate_actions.rb @@ -4,9 +4,9 @@ module ModerateActions def index @resources = @resources.send(@current_filter) - .send("sort_by_#{@current_order}") - .page(params[:page]) - .per(50) + .send("sort_by_#{@current_order}") + .page(params[:page]) + .per(50) set_resources_instance end diff --git a/app/controllers/concerns/polymorphic.rb b/app/controllers/concerns/polymorphic.rb index 51c5768c9..10d64698d 100644 --- a/app/controllers/concerns/polymorphic.rb +++ b/app/controllers/concerns/polymorphic.rb @@ -1,6 +1,7 @@ module Polymorphic private + def resource @resource ||= instance_variable_get("@#{resource_name}") end diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index f97334d84..8262f014a 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -21,8 +21,8 @@ class DebatesController < ApplicationController respond_to :html, :js def index_customization - @featured_debates = @debates.featured - @proposal_successful_exists = Proposal.successful.exists? + @featured_debates = @debates.featured + @proposal_successfull_exists = Proposal.successfull.exists? end def show @@ -41,7 +41,7 @@ class DebatesController < ApplicationController end def mark_featured - @debate.update_attribute(:featured_at, Time.now) + @debate.update_attribute(:featured_at, Time.current) redirect_to request.query_parameters.merge(action: :index) end diff --git a/app/controllers/management/account_controller.rb b/app/controllers/management/account_controller.rb index 85b9feea4..64e0ddf4d 100644 --- a/app/controllers/management/account_controller.rb +++ b/app/controllers/management/account_controller.rb @@ -6,6 +6,7 @@ class Management::AccountController < Management::BaseController end private + def only_verified_users check_verified_user t("management.account.alert.unverified_user") end diff --git a/app/controllers/management/dashboard_controller.rb b/app/controllers/management/dashboard_controller.rb index abb605341..87b134270 100644 --- a/app/controllers/management/dashboard_controller.rb +++ b/app/controllers/management/dashboard_controller.rb @@ -3,4 +3,4 @@ class Management::DashboardController < Management::BaseController def index end -end +end \ No newline at end of file diff --git a/app/controllers/management/document_verifications_controller.rb b/app/controllers/management/document_verifications_controller.rb index 1b8fabcc2..510e4fa93 100644 --- a/app/controllers/management/document_verifications_controller.rb +++ b/app/controllers/management/document_verifications_controller.rb @@ -33,17 +33,17 @@ class Management::DocumentVerificationsController < Management::BaseController private - def document_verification_params - params.require(:document_verification).permit(:document_type, :document_number) - end + def document_verification_params + params.require(:document_verification).permit(:document_type, :document_number) + end - def set_document - session[:document_type] = params[:document_verification][:document_type] - session[:document_number] = params[:document_verification][:document_number] - end + def set_document + session[:document_type] = params[:document_verification][:document_type] + session[:document_number] = params[:document_verification][:document_number] + end - def clean_document_number - params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? - end + def clean_document_number + params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? + end end \ No newline at end of file diff --git a/app/controllers/management/email_verifications_controller.rb b/app/controllers/management/email_verifications_controller.rb index 3558e6fbf..7d511fe4b 100644 --- a/app/controllers/management/email_verifications_controller.rb +++ b/app/controllers/management/email_verifications_controller.rb @@ -16,8 +16,8 @@ class Management::EmailVerificationsController < Management::BaseController private - def email_verification_params - params.require(:email_verification).permit(:document_type, :document_number, :email) - end + def email_verification_params + params.require(:email_verification).permit(:document_type, :document_number, :email) + end end \ No newline at end of file diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 2ce74d6d5..1a30526f5 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -53,4 +53,4 @@ class Management::ProposalsController < Management::BaseController @comment_flags = managed_user ? managed_user.comment_flags(comments) : {} end -end +end \ No newline at end of file diff --git a/app/controllers/management/sessions_controller.rb b/app/controllers/management/sessions_controller.rb index bca17bf4c..5d0587ae5 100644 --- a/app/controllers/management/sessions_controller.rb +++ b/app/controllers/management/sessions_controller.rb @@ -42,4 +42,4 @@ class Management::SessionsController < ActionController::Base end end -end +end \ No newline at end of file diff --git a/app/controllers/management/user_invites_controller.rb b/app/controllers/management/user_invites_controller.rb index cbe3d1914..4d9b4909f 100644 --- a/app/controllers/management/user_invites_controller.rb +++ b/app/controllers/management/user_invites_controller.rb @@ -10,4 +10,4 @@ class Management::UserInvitesController < Management::BaseController end end -end +end \ No newline at end of file diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index 8ee04cfdf..53004a838 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -8,8 +8,8 @@ class Management::UsersController < Management::BaseController @user = User.new(user_params) @user.skip_password_validation = true @user.terms_of_service = '1' - @user.residence_verified_at = Time.now - @user.verified_at = Time.now + @user.residence_verified_at = Time.current + @user.verified_at = Time.current if @user.save then render :show diff --git a/app/controllers/moderation/users_controller.rb b/app/controllers/moderation/users_controller.rb index 3255bb6cc..cd1fff9a5 100644 --- a/app/controllers/moderation/users_controller.rb +++ b/app/controllers/moderation/users_controller.rb @@ -21,13 +21,13 @@ class Moderation::UsersController < Moderation::BaseController private - def load_users - @users = User.with_hidden.search(params[:name_or_email]).page(params[:page]).for_render - end + def load_users + @users = User.with_hidden.search(params[:name_or_email]).page(params[:page]).for_render + end - def block_user - @user.block - Activity.log(current_user, :block, @user) - end + def block_user + @user.block + Activity.log(current_user, :block, @user) + end end \ No newline at end of file diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index 503c26bc0..a77534d8c 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -24,6 +24,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController end protected + def after_inactive_sign_up_path_for(resource) organizations_sign_up_success_path end diff --git a/app/controllers/proposal_notifications_controller.rb b/app/controllers/proposal_notifications_controller.rb index fc9cdf3d8..36e265e38 100644 --- a/app/controllers/proposal_notifications_controller.rb +++ b/app/controllers/proposal_notifications_controller.rb @@ -26,8 +26,8 @@ class ProposalNotificationsController < ApplicationController private - def proposal_notification_params - params.require(:proposal_notification).permit(:title, :body, :proposal_id) - end + def proposal_notification_params + params.require(:proposal_notification).permit(:title, :body, :proposal_id) + end end \ No newline at end of file diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 3bf559c17..daec4a051 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -38,7 +38,7 @@ class ProposalsController < ApplicationController end def retire - if valid_retired_params? && @proposal.update(retired_params.merge(retired_at: Time.now)) + if valid_retired_params? && @proposal.update(retired_params.merge(retired_at: Time.current)) redirect_to proposal_path(@proposal), notice: t('proposals.notice.retired') else render action: :retire_form diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index d600e2e9c..ab6bedd6e 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -23,6 +23,6 @@ class StatsController < ApplicationController private def daily_cache(key, &block) - Rails.cache.fetch("public_stats/#{Time.now.strftime("%Y-%m-%d")}/#{key}", &block) + Rails.cache.fetch("public_stats/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &block) end end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 81eaa08cb..cbe43390b 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -44,4 +44,4 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController @user.save || @user.save_requiring_finish_signup end -end +end \ No newline at end of file diff --git a/app/controllers/valuation/spending_proposals_controller.rb b/app/controllers/valuation/spending_proposals_controller.rb index d3bc585b1..623c9ac46 100644 --- a/app/controllers/valuation/spending_proposals_controller.rb +++ b/app/controllers/valuation/spending_proposals_controller.rb @@ -58,7 +58,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController end def params_for_current_valuator - params.merge({valuator_id: current_user.valuator.id}) + params.merge({valuator_id: current_user.valuator.id}) end def restrict_access_to_assigned_items @@ -77,4 +77,4 @@ class Valuation::SpendingProposalsController < Valuation::BaseController @spending_proposal.errors.empty? end -end +end \ No newline at end of file diff --git a/app/controllers/verification/email_controller.rb b/app/controllers/verification/email_controller.rb index 9f8fd9f8a..1774197d9 100644 --- a/app/controllers/verification/email_controller.rb +++ b/app/controllers/verification/email_controller.rb @@ -6,7 +6,7 @@ class Verification::EmailController < ApplicationController def show if Verification::Email.find(current_user, params[:email_verification_token]) - current_user.update(verified_at: Time.now) + current_user.update(verified_at: Time.current) redirect_to account_path, notice: t('verification.email.show.flash.success') else redirect_to verified_user_path, alert: t('verification.email.show.alert.failure') diff --git a/app/controllers/verification/letter_controller.rb b/app/controllers/verification/letter_controller.rb index bf5033b32..0e726a683 100644 --- a/app/controllers/verification/letter_controller.rb +++ b/app/controllers/verification/letter_controller.rb @@ -29,7 +29,7 @@ class Verification::LetterController < ApplicationController def update @letter = Verification::Letter.new(letter_params.merge(user: current_user, verify: true)) if @letter.valid? - current_user.update(verified_at: Time.now) + current_user.update(verified_at: Time.current) redirect_to account_path, notice: t('verification.letter.update.flash.success') else Lock.increase_tries(@letter.user) if @letter.user @@ -56,5 +56,4 @@ class Verification::LetterController < ApplicationController end end - end diff --git a/app/controllers/verification/sms_controller.rb b/app/controllers/verification/sms_controller.rb index 1cb5b2d8e..f06af5e6a 100644 --- a/app/controllers/verification/sms_controller.rb +++ b/app/controllers/verification/sms_controller.rb @@ -31,7 +31,7 @@ class Verification::SmsController < ApplicationController ahoy.track(:level_2_user, user_id: current_user.id) rescue nil if VerifiedUser.phone?(current_user) - current_user.update(verified_at: Time.now) + current_user.update(verified_at: Time.current) end redirect_to_next_path @@ -69,4 +69,4 @@ class Verification::SmsController < ApplicationController end end -end \ No newline at end of file +end diff --git a/app/controllers/verification/verified_user_controller.rb b/app/controllers/verification/verified_user_controller.rb index 23045e451..e637bb232 100644 --- a/app/controllers/verification/verified_user_controller.rb +++ b/app/controllers/verification/verified_user_controller.rb @@ -9,6 +9,7 @@ class Verification::VerifiedUserController < ApplicationController end private + def user_data_present? return false if @verified_users.blank? diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index fc43f5357..d0c650fa3 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,5 +16,4 @@ class WelcomeController < ApplicationController redirect_to verification_path if signed_in? end - end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index d0b0765dd..969a8bcad 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -29,7 +29,7 @@ module AdminHelper end def official_level_options - options = [["",0]] + options = [["", 0]] (1..5).each do |i| options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i] end diff --git a/app/helpers/banners_helper.rb b/app/helpers/banners_helper.rb index 548513c7d..a1505a39e 100644 --- a/app/helpers/banners_helper.rb +++ b/app/helpers/banners_helper.rb @@ -1,5 +1,7 @@ module BannersHelper + def has_banners @banners.count > 0 end + end \ No newline at end of file diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 9d9d08075..13884237b 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -39,4 +39,5 @@ module CommentsHelper "" # Default not author class end end -end + +end \ No newline at end of file diff --git a/app/helpers/debates_helper.rb b/app/helpers/debates_helper.rb index 3c1aa02a7..8db989f61 100644 --- a/app/helpers/debates_helper.rb +++ b/app/helpers/debates_helper.rb @@ -1,6 +1,7 @@ module DebatesHelper - def has_featured? + def has_featured? Debate.all.featured.count > 0 end + end \ No newline at end of file diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index b48799bf5..8633549f4 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -9,15 +9,15 @@ module EmbedVideosHelper end if server == "Vimeo" - regExp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ + reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ src = "https://player.vimeo.com/video/" elsif server == "YouTube" - regExp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ + reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ src = "https://www.youtube.com/embed/" end - if regExp - match = link.match(regExp) + if reg_exp + match = link.match(reg_exp) end if match and match[2] diff --git a/app/helpers/flags_helper.rb b/app/helpers/flags_helper.rb index b5ba67f41..715937c0f 100644 --- a/app/helpers/flags_helper.rb +++ b/app/helpers/flags_helper.rb @@ -26,4 +26,4 @@ module FlagsHelper end end -end +end \ No newline at end of file diff --git a/app/helpers/layouts_helper.rb b/app/helpers/layouts_helper.rb new file mode 100644 index 000000000..c92f57898 --- /dev/null +++ b/app/helpers/layouts_helper.rb @@ -0,0 +1,12 @@ +module LayoutsHelper + + def layout_menu_link_to(text, path, is_active, options) + if is_active + content_tag(:span, t('shared.you_are_in'), class: 'sr-only') + ' ' + + link_to(text, path, options.merge(class: "active")) + else + link_to(text, path, options) + end + end + +end diff --git a/app/helpers/locales_helper.rb b/app/helpers/locales_helper.rb index 7954cc908..717be9e9b 100644 --- a/app/helpers/locales_helper.rb +++ b/app/helpers/locales_helper.rb @@ -5,4 +5,4 @@ module LocalesHelper I18n.backend.translate(locale, "i18n.language.name", default: default) end -end +end \ No newline at end of file diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 2b907535f..7342393a7 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,4 +1,2 @@ module NotificationsHelper - - end diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 9eaa88549..578cd1d8e 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -2,19 +2,19 @@ module ProposalsHelper def progress_bar_percentage(proposal) case proposal.cached_votes_up - when 0 then 0 - when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor - else 100 + when 0 then 0 + when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor + else 100 end end def supports_percentage(proposal) percentage = (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success) case percentage - when 0 then "0%" - when 0..(0.1) then "0.1%" - when (0.1)..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1) - else "100%" + when 0 then "0%" + when 0..(0.1) then "0.1%" + when (0.1)..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1) + else "100%" end end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index cd90a8a39..ad844e29f 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -8,4 +8,4 @@ module SettingsHelper @all_settings ||= Hash[ Setting.all.map{|s| [s.key, s.value.presence]} ] end -end +end \ No newline at end of file diff --git a/app/helpers/signature_sheets_helper.rb b/app/helpers/signature_sheets_helper.rb new file mode 100644 index 000000000..acd75a5ab --- /dev/null +++ b/app/helpers/signature_sheets_helper.rb @@ -0,0 +1,8 @@ +module SignatureSheetsHelper + + def signable_options + [[t("activerecord.models.proposal", count: 1), Proposal], + [t("activerecord.models.spending_proposal", count: 1), SpendingProposal]] + end + +end \ No newline at end of file diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index 097711b88..e481ef7e1 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -20,4 +20,5 @@ module StatsHelper opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) content_tag :div, "", opt end + end diff --git a/app/helpers/tracks_helper.rb b/app/helpers/tracks_helper.rb index 53c110d49..557d71802 100644 --- a/app/helpers/tracks_helper.rb +++ b/app/helpers/tracks_helper.rb @@ -1,4 +1,5 @@ module TracksHelper + def track_event(data={}) track_data = "" prefix = " data-track-event-" @@ -9,4 +10,5 @@ module TracksHelper track_data end end + end \ No newline at end of file diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1dbc5baa2..ea1d4fa40 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,5 @@ class ApplicationMailer < ActionMailer::Base helper :settings - default from: "Consul " + default from: "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>" layout 'mailer' end diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 46b5c90b7..356c72e3e 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -45,6 +45,8 @@ module Abilities can [:search, :edit, :update, :create, :index, :destroy], Banner + can [:index, :create, :edit, :update, :destroy], Geozone + can [:manage], Poll can [:manage], Poll::Booth can [:search, :create, :index, :destroy], ::Poll::Officer diff --git a/app/models/banner.rb b/app/models/banner.rb index db8f10635..c4f2295e6 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -12,9 +12,9 @@ class Banner < ActiveRecord::Base validates :post_started_at, presence: true validates :post_ended_at, presence: true - scope :with_active, -> {where("post_started_at <= ?", Time.now). - where("post_ended_at >= ?", Time.now) } + scope :with_active, -> {where("post_started_at <= ?", Time.current). + where("post_ended_at >= ?", Time.current) } - scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.now, Time.now) } + scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } -end \ No newline at end of file +end diff --git a/app/models/comment.rb b/app/models/comment.rb index b666b354a..1b518b7a5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -24,8 +24,8 @@ class Comment < ActiveRecord::Base scope :not_as_admin_or_moderator, -> { where("administrator_id IS NULL").where("moderator_id IS NULL")} scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - scope :sort_by_most_voted , -> { order(confidence_score: :desc, created_at: :desc) } - scope :sort_descendants_by_most_voted , -> { order(confidence_score: :desc, created_at: :asc) } + scope :sort_by_most_voted, -> { order(confidence_score: :desc, created_at: :desc) } + scope :sort_descendants_by_most_voted, -> { order(confidence_score: :desc, created_at: :asc) } scope :sort_by_newest, -> { order(created_at: :desc) } scope :sort_descendants_by_newest, -> { order(created_at: :desc) } diff --git a/app/models/concerns/flaggable.rb b/app/models/concerns/flaggable.rb index a111562b3..c3125c440 100644 --- a/app/models/concerns/flaggable.rb +++ b/app/models/concerns/flaggable.rb @@ -13,7 +13,7 @@ module Flaggable end def ignore_flag - update(ignored_flag_at: Time.now) + update(ignored_flag_at: Time.current) end end diff --git a/app/models/debate.rb b/app/models/debate.rb index 840b9c4b5..020259d80 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -28,7 +28,7 @@ class Debate < ActiveRecord::Base before_save :calculate_hot_score, :calculate_confidence_score scope :for_render, -> { includes(:tags) } - scope :sort_by_hot_score , -> { reorder(hot_score: :desc) } + scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) } scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } diff --git a/app/models/geozone.rb b/app/models/geozone.rb index cc4070c9a..824879ec6 100644 --- a/app/models/geozone.rb +++ b/app/models/geozone.rb @@ -1,5 +1,8 @@ class Geozone < ActiveRecord::Base + has_many :proposals has_many :spending_proposals + has_many :debates + has_many :users validates :name, presence: true def self.names @@ -10,4 +13,9 @@ class Geozone < ActiveRecord::Base where(name: 'city').first end + def safe_to_destroy? + Geozone.reflect_on_all_associations(:has_many).all? do |association| + association.klass.where(geozone: self).empty? + end + end end diff --git a/app/models/lock.rb b/app/models/lock.rb index 3c043de79..c0d5fae39 100644 --- a/app/models/lock.rb +++ b/app/models/lock.rb @@ -4,7 +4,7 @@ class Lock < ActiveRecord::Base before_save :set_locked_until def locked? - locked_until > Time.now + locked_until > Time.current end def set_locked_until @@ -12,7 +12,7 @@ class Lock < ActiveRecord::Base end def lock_time - Time.now + (2**tries).minutes + Time.current + (2**tries).minutes end def too_many_tries? diff --git a/app/models/notification.rb b/app/models/notification.rb index c6c32eb8d..e993e55f8 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -49,4 +49,5 @@ class Notification < ActiveRecord::Base def linkable_resource notifiable.is_a?(ProposalNotification) ? notifiable.proposal : notifiable end + end \ No newline at end of file diff --git a/app/models/organization.rb b/app/models/organization.rb index 069afc27f..74fd16111 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -14,11 +14,11 @@ class Organization < ActiveRecord::Base scope :rejected, -> { where.not(rejected_at: nil).where("(organizations.verified_at IS NULL or organizations.verified_at < rejected_at)") } def verify - update(verified_at: Time.now) + update(verified_at: Time.current) end def reject - update(rejected_at: Time.now) + update(rejected_at: Time.current) end def verified? diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 75e5cbe20..96ca7c1da 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -50,7 +50,7 @@ class Proposal < ActiveRecord::Base scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } - scope :successful, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)} + scope :successful, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)} def to_param "#{id}-#{title}".parameterize diff --git a/app/models/proposal_notification.rb b/app/models/proposal_notification.rb index f73264318..60912d887 100644 --- a/app/models/proposal_notification.rb +++ b/app/models/proposal_notification.rb @@ -9,9 +9,9 @@ class ProposalNotification < ActiveRecord::Base def minimum_interval return true if proposal.try(:notifications).blank? - if proposal.notifications.last.created_at > (Time.now - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime + if proposal.notifications.last.created_at > (Time.current - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: Setting[:proposal_notification_minimum_interval_in_days])) end end -end \ No newline at end of file +end diff --git a/app/models/signature.rb b/app/models/signature.rb new file mode 100644 index 000000000..47408858a --- /dev/null +++ b/app/models/signature.rb @@ -0,0 +1,85 @@ +class Signature < ActiveRecord::Base + belongs_to :signature_sheet + belongs_to :user + + validates :document_number, presence: true + validates :signature_sheet, presence: true + + scope :verified, -> { where(verified: true) } + scope :unverified, -> { where(verified: false) } + + delegate :signable, to: :signature_sheet + + def verified? + user_exists? || in_census? + end + + def verify + if verified? + assign_vote + mark_as_verified + end + end + + def assign_vote + if user_exists? + assign_vote_to_user + else + create_user + assign_vote_to_user + end + end + + def assign_vote_to_user + set_user + signable.register_vote(user, "yes") + assign_signature_to_vote + end + + def assign_signature_to_vote + vote = Vote.where(votable: signable, voter: user).first + vote.update(signature: self) + end + + def user_exists? + User.where(document_number: document_number).any? + end + + def create_user + user_params = { + document_number: document_number, + created_from_signature: true, + verified_at: Time.now, + erased_at: Time.now, + password: random_password, + terms_of_service: '1', + email: nil + } + User.create!(user_params) + end + + def random_password + (0...20).map { ('a'..'z').to_a[rand(26)] }.join + end + + def in_census? + response = document_types.detect do |document_type| + CensusApi.new.call(document_type, document_number).valid? + end + response.present? + end + + def set_user + user = User.where(document_number: document_number).first + update(user: user) + end + + def mark_as_verified + update(verified: true) + end + + def document_types + %w(1 2 3 4) + end + +end \ No newline at end of file diff --git a/app/models/signature_sheet.rb b/app/models/signature_sheet.rb new file mode 100644 index 000000000..6852820bb --- /dev/null +++ b/app/models/signature_sheet.rb @@ -0,0 +1,38 @@ +class SignatureSheet < ActiveRecord::Base + belongs_to :signable, polymorphic: true + belongs_to :author, class_name: 'User', foreign_key: 'author_id' + + VALID_SIGNABLES = %w( Proposal SpendingProposal ) + + has_many :signatures + + validates :author, presence: true + validates :signable_type, inclusion: {in: VALID_SIGNABLES} + validates :document_numbers, presence: true + validates :signable, presence: true + validate :signable_found + + def name + "#{signable_name} #{signable_id}" + end + + def signable_name + I18n.t("activerecord.models.#{signable_type.underscore}", count: 1) + end + + def verify_signatures + parsed_document_numbers.each do |document_number| + signature = signatures.create(document_number: document_number) + signature.verify + end + update(processed: true) + end + + def parsed_document_numbers + document_numbers.split(/\W+/) + end + + def signable_found + errors.add(:signable_id, :not_found) if errors.messages[:signable].present? + end +end \ No newline at end of file diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index a2c143336..223e9adfe 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -114,7 +114,7 @@ class SpendingProposal < ActiveRecord::Base def send_unfeasible_email Mailer.unfeasible_spending_proposal(self).deliver_later - update(unfeasible_email_sent_at: Time.now) + update(unfeasible_email_sent_at: Time.current) end def reason_for_not_being_votable_by(user) diff --git a/app/models/user.rb b/app/models/user.rb index 79c5d1af3..688fde1b1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -70,7 +70,7 @@ class User < ActiveRecord::Base oauth_email: oauth_email, password: Devise.friendly_token[0,20], terms_of_service: '1', - confirmed_at: oauth_email_confirmed ? DateTime.now : nil + confirmed_at: oauth_email_confirmed ? DateTime.current : nil ) end @@ -159,12 +159,11 @@ class User < ActiveRecord::Base def erase(erase_reason = nil) self.update( - erased_at: Time.now, + erased_at: Time.current, erase_reason: erase_reason, username: nil, email: nil, unconfirmed_email: nil, - document_number: nil, phone_number: nil, encrypted_password: "", confirmation_token: nil, @@ -247,6 +246,7 @@ class User < ActiveRecord::Base delegate :can?, :cannot?, to: :ability private + def clean_document_number self.document_number = self.document_number.gsub(/[^a-z0-9]+/i, "").upcase unless self.document_number.blank? end diff --git a/app/models/verification/letter.rb b/app/models/verification/letter.rb index 0beb7c8d8..c746e73e4 100644 --- a/app/models/verification/letter.rb +++ b/app/models/verification/letter.rb @@ -17,7 +17,7 @@ class Verification::Letter end def letter_requested! - user.update(letter_requested_at: Time.now, letter_verification_code: generate_verification_code) + user.update(letter_requested_at: Time.current, letter_verification_code: generate_verification_code) end def validate_existing_user diff --git a/app/models/verification/management/document.rb b/app/models/verification/management/document.rb index fcbc19ca4..17ea065bd 100644 --- a/app/models/verification/management/document.rb +++ b/app/models/verification/management/document.rb @@ -10,7 +10,7 @@ class Verification::Management::Document delegate :username, :email, to: :user, allow_nil: true def user - @user = User.by_document(document_type, document_number).first + @user = User.active.by_document(document_type, document_number).first end def user? @@ -40,7 +40,7 @@ class Verification::Management::Document end def verify - user.update(verified_at: Time.now) if user? + user.update(verified_at: Time.current) if user? end end diff --git a/app/models/verification/management/email.rb b/app/models/verification/management/email.rb index 33282b569..de13d1ab4 100644 --- a/app/models/verification/management/email.rb +++ b/app/models/verification/management/email.rb @@ -27,8 +27,8 @@ class Verification::Management::Email user.update(document_type: document_type, document_number: document_number, - residence_verified_at: Time.now, - level_two_verified_at: Time.now, + residence_verified_at: Time.current, + level_two_verified_at: Time.current, email_verification_token: plain_token) Mailer.email_verification(user, email, encrypted_token, document_type, document_number).deliver_later diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index cc24bb7c8..96a36e5cd 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -31,7 +31,7 @@ class Verification::Residence geozone: self.geozone, date_of_birth: date_of_birth.to_datetime, gender: gender, - residence_verified_at: Time.now) + residence_verified_at: Time.current) end def allowed_age diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 078dad9b1..52c66e0c3 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -118,5 +118,13 @@ + + <% if feature?(:signature_sheets) %> +
  • > + <%= link_to admin_signature_sheets_path do %> + <%= t("admin.menu.signature_sheets") %> + <% end %> +
  • + <% end %> diff --git a/app/views/admin/geozones/_errors.html.erb b/app/views/admin/geozones/_errors.html.erb new file mode 100644 index 000000000..d0f3b849f --- /dev/null +++ b/app/views/admin/geozones/_errors.html.erb @@ -0,0 +1,15 @@ + +<% if @geozone.errors.any? %> + +
    + + + + <%= @geozone.errors.count %> + <%= t("admin.geozones.errors.form.error", count: @geozone.errors.count) %> + +
    + +<% end %> diff --git a/app/views/admin/geozones/_form.html.erb b/app/views/admin/geozones/_form.html.erb new file mode 100644 index 000000000..e92b98c0b --- /dev/null +++ b/app/views/admin/geozones/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for [:admin, @geozone] do |f| %> + + <%= render 'errors' %> + +
    +
    + <%= f.label :name, t("admin.geozones.geozone.name") %> + <%= f.text_field :name, label: false %> +
    +
    + <%= f.label :html_map_coordinates, t("admin.geozones.geozone.coordinates") %> + <%= f.text_field :html_map_coordinates, label: false %> +
    +
    + <%= f.label :external_code, t("admin.geozones.geozone.external_code") %> + <%= f.text_field :external_code, label: false %> +
    +
    + <%= f.label :census_code, t("admin.geozones.geozone.census_code") %> + <%= f.text_field :census_code, label: false %> +
    +
    + +
    +
    + <%= f.submit(class: "button expanded", value: t("admin.geozones.edit.form.submit_button")) %> +
    +
    +<% end %> diff --git a/app/views/admin/geozones/edit.html.erb b/app/views/admin/geozones/edit.html.erb new file mode 100644 index 000000000..b6b8c3fd9 --- /dev/null +++ b/app/views/admin/geozones/edit.html.erb @@ -0,0 +1,13 @@ +
    + +
    + <%= link_to admin_geozones_path, class: "back" do %> + + <%= t("admin.geozones.edit.back") %> + <% end %> + +

    <%= t("admin.geozones.edit.editing") %>

    + + <%= render "form" %> +
    +
    diff --git a/app/views/admin/geozones/index.html.erb b/app/views/admin/geozones/index.html.erb new file mode 100644 index 000000000..5a524e46e --- /dev/null +++ b/app/views/admin/geozones/index.html.erb @@ -0,0 +1,33 @@ +<%= link_to t("admin.geozones.index.create"), + new_admin_geozone_path, class: "button success float-right" %> + +

    <%= t("admin.geozones.index.title") %>

    + + + + + + + + + + + + + + <% @geozones.each do |geozone| %> + + + + + + + + + <% end %> + +
    <%= t("admin.geozones.geozone.name") %><%= t("admin.geozones.geozone.external_code") %><%= t("admin.geozones.geozone.census_code") %><%= t("admin.geozones.geozone.coordinates") %>
    <%= geozone.name %><%= geozone.external_code %><%= geozone.census_code %><%= geozone.html_map_coordinates %> + <%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %> + + <%= link_to t("admin.geozones.index.delete"), admin_geozone_path(geozone), method: :delete, class: 'button hollow alert' %> +
    diff --git a/app/views/admin/geozones/new.html.erb b/app/views/admin/geozones/new.html.erb new file mode 100644 index 000000000..0d5080337 --- /dev/null +++ b/app/views/admin/geozones/new.html.erb @@ -0,0 +1,13 @@ +
    + +
    + <%= link_to admin_geozones_path, class: "back" do %> + + <%= t("admin.geozones.new.back") %> + <% end %> + +

    <%= t("admin.geozones.new.creating") %>

    + + <%= render "form" %> +
    +
    diff --git a/app/views/admin/signature_sheets/index.html.erb b/app/views/admin/signature_sheets/index.html.erb new file mode 100644 index 000000000..74241b5b0 --- /dev/null +++ b/app/views/admin/signature_sheets/index.html.erb @@ -0,0 +1,31 @@ +

    <%= t("admin.signature_sheets.index.title") %>

    + +<%= link_to t("admin.signature_sheets.index.new"), new_admin_signature_sheet_path, + class: "button success float-right" %> + +<% if @signature_sheets.any? %> + + + + + + + <% @signature_sheets.each do |signature_sheet| %> + + + + + + <% end %> +
    <%= t("admin.signature_sheets.name") %><%= t("admin.signature_sheets.author") %><%= t("admin.signature_sheets.created_at") %>
    + <%= link_to signature_sheet.name, [:admin, signature_sheet] %> + + <%= signature_sheet.author.name %> + + <%= l(signature_sheet.created_at, format: :short) %> +
    +<% else %> +
    + <%= t("admin.signature_sheets.no_signature_sheets") %> +
    +<% end %> diff --git a/app/views/admin/signature_sheets/new.html.erb b/app/views/admin/signature_sheets/new.html.erb new file mode 100644 index 000000000..f471e1ea5 --- /dev/null +++ b/app/views/admin/signature_sheets/new.html.erb @@ -0,0 +1,22 @@ +<%= render 'shared/back_link' %> + +

    <%= t("admin.signature_sheets.new.title") %>

    + +<%= form_for [:admin, @signature_sheet] do |f| %> + <%= render 'shared/errors', + resource: @signature_sheet %> + +
    + <%= f.select :signable_type, signable_options %> +
    + +
    + <%= f.text_field :signable_id %> +
    + + <%= f.label :document_numbers %> +

    <%= t("admin.signature_sheets.new.document_numbers_note") %>

    + <%= f.text_area :document_numbers, rows: "6", label: false %> + + <%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/signature_sheets/show.html.erb b/app/views/admin/signature_sheets/show.html.erb new file mode 100644 index 000000000..a3787b67d --- /dev/null +++ b/app/views/admin/signature_sheets/show.html.erb @@ -0,0 +1,39 @@ +

    <%= @signature_sheet.name %>

    + +
    + <%= t("admin.signature_sheets.show.created_at") %> + <%= l(@signature_sheet.created_at, format: :short) %> +  •  + <%= t("admin.signature_sheets.show.author") %> + <%= @signature_sheet.author.name %> +
    + +
    +

    <%= t("admin.signature_sheets.show.documents") %>

    + <%= simple_format @signature_sheet.document_numbers %> +
    + + +
    + + <%= t("admin.signature_sheets.show.verified", + count: @signature_sheet.signatures.verified.count ) %> + +
    + +
    +

    + + <%= t("admin.signature_sheets.show.unverified", + count: @signature_sheet.signatures.unverified.count ) %> + <%= t("admin.signature_sheets.show.unverified_error") %> + +

    + <%= @signature_sheet.signatures.unverified.map(&:document_number).join(", ") %> +
    + +<% unless @signature_sheet.processed? %> +
    + <%= t("admin.signature_sheets.show.loading") %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index bf8bfb50d..cb5ede7f8 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,29 +1,28 @@ <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (@comment_flags[comment.id] if @comment_flags)] do %>
    -
    - - <% if comment.hidden? || comment.user.hidden? %> - <% if comment.children.size > 0 %> -
    -

    <%= t("comments.comment.deleted") %>

    -
    - <% end %> - <% else %> - <% if comment.as_administrator? %> - <%= image_tag("avatar_admin.png", size: 32, class: "admin-avatar float-left") %> - <% elsif comment.as_moderator? %> - <%= image_tag("avatar_moderator.png", size: 32, class: "moderator-avatar float-left") %> - <% else %> - <% if comment.user.hidden? || comment.user.erased? %> - - <% elsif comment.user.organization? %> - <%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %> - <% else %> - <%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %> +
      +
    • + <% if comment.hidden? || comment.user.hidden? %> + <% if comment.children.size > 0 %> +
      +

      <%= t("comments.comment.deleted") %>

      +
      + <% end %> + <% else %> + <% if comment.as_administrator? %> + <%= image_tag("avatar_admin.png", size: 32, class: "admin-avatar float-left") %> + <% elsif comment.as_moderator? %> + <%= image_tag("avatar_moderator.png", size: 32, class: "moderator-avatar float-left") %> + <% else %> + <% if comment.user.hidden? || comment.user.erased? %> + + <% elsif comment.user.organization? %> + <%= image_tag("avatar_collective.png", size: 32, class: "avatar float-left") %> + <% else %> + <%= avatar_image(comment.user, seed: comment.user_id, size: 32, class: "float-left") %> + <% end %> <% end %> - <% end %> -
      <% if comment.as_administrator? %> @@ -58,7 +57,7 @@ <% end %> -  •  +  • <%= l comment.created_at.to_datetime, format: :datetime %>
      _reply" class="reply"> - +
      <%= render 'comments/votes', comment: comment %> - +
      <% if comment.children.size > 0 %> - <%= link_to "", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> - <%= t("shared.show") %> + <%= link_to "#{dom_id(comment)}", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> + + <%= t("shared.hide") %> <%= t("comments.comment.responses", count: comment.children.size) %> <% end %> <% else %> @@ -91,14 +91,15 @@ <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> <% end %>
      -
      - <% end %> - -
      - <% child_comments_of(comment).each do |child| %> - <%= render 'comments/comment', comment: child %> <% end %> -
      -
    + +
  • +
      + <% child_comments_of(comment).each do |child| %> + <%= render 'comments/comment', comment: child %> + <% end %> +
    +
  • +
    <% end %> diff --git a/app/views/comments/_votes.html.erb b/app/views/comments/_votes.html.erb index 0de92a675..93af5b2dd 100644 --- a/app/views/comments/_votes.html.erb +++ b/app/views/comments/_votes.html.erb @@ -6,13 +6,17 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'yes'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.agree') do %> + <%= t('votes.agree') %> <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.agree') %> + + <% end %> <% end %> <%= comment.total_likes %> @@ -20,13 +24,15 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'no'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.disagree') do %> + <%= t('votes.disagree') %> <% end %> <% else %> - + + <%= t('votes.disagree') %> + <% end %> <%= comment.total_dislikes %> @@ -40,26 +46,40 @@ <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'yes'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.agree') do %> + + <%= t('votes.agree') %> + <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.agree') %> + + <% end %> <% end %> <%= comment.total_likes %> + <% if can?(:vote, comment) %> <%= link_to vote_comment_path(comment, value: 'no'), - method: "post", remote: true do %> - + method: "post", remote: true, title: t('votes.disagree') do %> + + <%= t('votes.disagree') %> + <% end %> <% else %> - + <%= link_to new_user_session_path do %> + + <%= t('votes.disagree') %> + + <% end %> <% end %> <%= comment.total_dislikes %> - + + <% end %> diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index 09d7d79c0..d084a0241 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -41,14 +41,14 @@

    - <%= link_to debate.description, debate %> + <%= debate.description %>
    <%= render "shared/tags", taggable: debate, limit: 5 %> -
    +
    <%= render 'debates/votes', debate: debate %>
    diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 30152b366..c88045f26 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -1,6 +1,5 @@ <%= form_for(@debate) do |f| %> - <%= render 'shared/errors', resource: @debate %>
    diff --git a/app/views/debates/_votes.html.erb b/app/views/debates/_votes.html.erb index cc59a3f3a..9bc3ca555 100644 --- a/app/views/debates/_votes.html.erb +++ b/app/views/debates/_votes.html.erb @@ -1,23 +1,41 @@ <% voted_classes = css_classes_for_vote(@debate_votes, debate) %>
    - <%= link_to vote_debate_path(debate, value: 'yes'), - class: "like #{voted_classes[:in_favor]}", title: t('votes.agree'), method: "post", remote: true do %> - - <%= t('votes.agree') %> - - <%= votes_percentage('likes', debate) %> + <% if user_signed_in? %> + <%= link_to vote_debate_path(debate, value: 'yes'), + class: "like #{voted_classes[:in_favor]}", title: t('votes.agree'), method: "post", remote: true do %> + + <%= t('votes.agree') %> + + <%= votes_percentage('likes', debate) %> + <% end %> + <% else %> + <% end %>
    - <%= link_to vote_debate_path(debate, value: 'no'), class: "unlike #{voted_classes[:against]}", title: t('votes.disagree'), method: "post", remote: true do %> - - <%= t('votes.disagree') %> - - <%= votes_percentage('dislikes', debate) %> + <% if user_signed_in? %> + <%= link_to vote_debate_path(debate, value: 'no'), class: "unlike #{voted_classes[:against]}", title: t('votes.disagree'), method: "post", remote: true do %> + + <%= t('votes.disagree') %> + + <%= votes_percentage('dislikes', debate) %> + <% end %> + <% else %> +
    + + <%= t('votes.disagree') %> + + <%= votes_percentage('dislikes', debate) %> +
    <% end %>
    @@ -39,10 +57,12 @@

    <% elsif !user_signed_in? %> - diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 4cee62dd3..e38c52233 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -6,6 +6,8 @@ <% end %>
    +

    <%= t("shared.outline.debates") %>

    +
    diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 9625ab42d..363a3bab3 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -1,6 +1,6 @@ <% provide :title do %><%= @debate.title %><% end %> <% cache [locale_and_user_status(@debate), @debate, @debate.author, Flag.flagged?(current_user, @debate), @debate_votes] do %> -
    +
    <%= render "shared/back_link" %> @@ -44,14 +44,12 @@
    -
    +
    <% end %> <%= render "comments" %> diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index f129b1b9d..de9e89c93 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -1,21 +1,19 @@ <%= paginator.render do -%>
    - + <%= next_page_tag unless current_page.last? %> + <%= last_page_tag unless current_page.last? %> +
    <% end -%> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index da6074706..4f8545fb5 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -41,13 +41,13 @@
    -

    - <%= t("layouts.footer.copyright", year: Time.now.year) %> |  - <%= link_to t("layouts.footer.more_info"), page_path('more_information') %> |  - <%= link_to t("layouts.footer.privacy"), page_path('privacy') %> |  - <%= link_to t("layouts.footer.conditions"), page_path('conditions') %> |  - <%= link_to t("layouts.footer.accessibility"), page_path('accessibility') %> -

    + <%= t("layouts.footer.copyright", year: Time.current.year) %> | +
      +
    • <%= link_to t("layouts.footer.more_info"), page_path('more_information') %> |
    • +
    • <%= link_to t("layouts.footer.privacy"), page_path('privacy') %> |
    • +
    • <%= link_to t("layouts.footer.conditions"), page_path('conditions') %> |
    • +
    • <%= link_to t("layouts.footer.accessibility"), page_path('accessibility') %>
    • +
    @@ -48,9 +40,9 @@
    <%= render "shared/subnavigation" %> -
    - <%= yield :header_addon %> -
    +
    +
    + <%= yield :header_addon %>
    diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 41351f12a..27d9a7f35 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,7 +14,7 @@ <%= csrf_meta_tags %> <%= favicon_link_tag "favicon.ico" %> <%= favicon_link_tag "apple-touch-icon-200.png", - rel: "apple-touch-icon", + rel: "icon apple-touch-icon", sizes: "200x200", type: "image/png" %> <%= content_for :social_media_meta_tags %> @@ -22,6 +22,8 @@ <%= setting['per_page_code'].try(:html_safe) %> +

    <%= setting['org_name'] %>

    +
    <%= render 'layouts/header' %> diff --git a/app/views/pages/accessibility.html.erb b/app/views/pages/accessibility.html.erb index 8d8d6a34d..a2c2eff30 100644 --- a/app/views/pages/accessibility.html.erb +++ b/app/views/pages/accessibility.html.erb @@ -40,7 +40,7 @@ S - Presupuestos ciudadanos + Presupuestos participativos I diff --git a/app/views/pages/spending_proposals_info.html.erb b/app/views/pages/spending_proposals_info.html.erb index 60e947343..41332bb96 100644 --- a/app/views/pages/spending_proposals_info.html.erb +++ b/app/views/pages/spending_proposals_info.html.erb @@ -8,8 +8,8 @@
    -

    ¿Cómo funcionan los presupuestos ciudadanos?

    +

    ¿Cómo funcionan los Presupuestos participativos?

    Explicación detallada del proceso

    -

    Próximamente se podrá encontrar aquí una descripción del proceso de participación ciudadana en los presupuestos.

    +

    Descripción del proceso de participación ciudadana en los presupuestos.

    diff --git a/app/views/proposals/_categories.html.erb b/app/views/proposals/_categories.html.erb index 4d429b055..ec87fd734 100644 --- a/app/views/proposals/_categories.html.erb +++ b/app/views/proposals/_categories.html.erb @@ -1,9 +1,9 @@ - +
    -
    +
      <% @categories.each do |category| %> - <%= link_to category.name, proposals_path(search: category.name) %> +
    • <%= link_to category.name, proposals_path(search: category.name) %>
    • <% end %> -
    \ No newline at end of file + diff --git a/app/views/proposals/_comments.html.erb b/app/views/proposals/_comments.html.erb index ed52b1b66..c304bc4dd 100644 --- a/app/views/proposals/_comments.html.erb +++ b/app/views/proposals/_comments.html.erb @@ -1,26 +1,24 @@ <% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count, @comment_flags] do %> -
    -
    -
    - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> +
    +
    + <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> - <% if user_signed_in? %> - <%= render 'comments/form', {commentable: @proposal, parent_id: nil, toggeable: false} %> - <% else %> -
    + <% if user_signed_in? %> + <%= render 'comments/form', {commentable: @proposal, parent_id: nil, toggeable: false} %> + <% else %> +
    -
    - <%= t("proposals.show.login_to_comment", - signin: link_to(t("votes.signin"), new_user_session_path), - signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> -
    - <% end %> +
    + <%= t("proposals.show.login_to_comment", + signin: link_to(t("votes.signin"), new_user_session_path), + signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> +
    + <% end %> - <% @comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', comment: comment %> - <% end %> - <%= paginate @comment_tree.root_comments %> -
    + <% @comment_tree.root_comments.each do |comment| %> + <%= render 'comments/comment', comment: comment %> + <% end %> + <%= paginate @comment_tree.root_comments %>
    -
    +
    <% end %> diff --git a/app/views/proposals/_featured_votes.html.erb b/app/views/proposals/_featured_votes.html.erb index 5f2f79c2d..3177812a4 100644 --- a/app/views/proposals/_featured_votes.html.erb +++ b/app/views/proposals/_featured_votes.html.erb @@ -1,4 +1,4 @@ -
    +
    <% if voted_for?(@featured_proposals_votes, proposal) %>
    diff --git a/app/views/proposals/_filter_subnav.html.erb b/app/views/proposals/_filter_subnav.html.erb index b7bc85dd6..fe875c9a9 100644 --- a/app/views/proposals/_filter_subnav.html.erb +++ b/app/views/proposals/_filter_subnav.html.erb @@ -3,18 +3,18 @@
    • <%= link_to "#tab-comments" do %> -

      +

      <%= t("proposals.show.comments_tab") %> (<%= @proposal.comments_count %>) -

      + <% end %>
    • <%= link_to "#tab-notifications" do %> -

      +

      <%= t("proposals.show.notifications_tab") %> (<%= @notifications.count %>) -

      + <% end %>
    diff --git a/app/views/proposals/_geozones.html.erb b/app/views/proposals/_geozones.html.erb index ceec721ce..7e4dbcaa4 100644 --- a/app/views/proposals/_geozones.html.erb +++ b/app/views/proposals/_geozones.html.erb @@ -1,5 +1,5 @@ - +
    <%= link_to map_proposals_path, id: 'map', title: t("shared.tags_cloud.districts_list") do %> <%= image_tag("map.jpg", alt: t("shared.tags_cloud.districts_list")) %> diff --git a/app/views/proposals/_popular.html.erb b/app/views/proposals/_popular.html.erb index 15ef8dccf..7f46ea802 100644 --- a/app/views/proposals/_popular.html.erb +++ b/app/views/proposals/_popular.html.erb @@ -1,5 +1,5 @@ - +

    <%= link_to t("proposals.index.top_link_proposals"), summary_proposals_path, class: "small" %>
    diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index d0a56cd20..735e8bcec 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -44,7 +44,7 @@ <% end %>

    -

    <%= link_to proposal.summary, namespaced_proposal_path(proposal) %>

    +

    <%= proposal.summary %>

    <% end %> @@ -52,9 +52,10 @@
    -
    +
    <% if proposal.successful? %> -
    +
    +

    <%= t("proposals.proposal.successful", voting: link_to(t("proposals.proposal.voting"), polls_path)).html_safe %> @@ -68,15 +69,13 @@

    <% end %> <% elsif proposal.archived? %> -
    +
    <%= t("proposals.proposal.supports", count: proposal.total_votes) %>

    <%= t("proposals.proposal.archived") %>

    <% else %> -
    - <%= render 'votes', - { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> -
    + <%= render 'votes', + { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> <% end %>
    diff --git a/app/views/proposals/_retired.html.erb b/app/views/proposals/_retired.html.erb index 280265d87..2167b14af 100644 --- a/app/views/proposals/_retired.html.erb +++ b/app/views/proposals/_retired.html.erb @@ -1,5 +1,5 @@ - + <% if params[:retired].blank? %>

    <%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 'all'), class: "small" %>

    diff --git a/app/views/proposals/_votes.html.erb b/app/views/proposals/_votes.html.erb index 198bf5d07..fb41357af 100644 --- a/app/views/proposals/_votes.html.erb +++ b/app/views/proposals/_votes.html.erb @@ -1,5 +1,4 @@ -
    - +
    @@ -18,15 +17,19 @@
    <% if voted_for?(@proposal_votes, proposal) %> -
    +
    <%= t("proposals.proposal.already_supported") %>
    - <% else %> + <% elsif user_signed_in? && proposal.votable_by?(current_user) %> <%= link_to vote_url, class: "button button-support small expanded", title: t('proposals.proposal.support_title'), method: "post", remote: true do %> <%= t("proposals.proposal.support") %> <% end %> + <% else %> +
    + <%= t("proposals.proposal.support") %> +
    <% end %>
    @@ -36,18 +39,22 @@ <%= t("votes.organizations") %>

    - <% elsif user_signed_in? && !proposal.votable_by?(current_user)%> -