diff --git a/app/assets/stylesheets/debates.scss b/app/assets/stylesheets/debates.scss index 641e7ccff..5017837bc 100644 --- a/app/assets/stylesheets/debates.scss +++ b/app/assets/stylesheets/debates.scss @@ -574,6 +574,8 @@ padding: rem-calc(6) rem-calc(12); } + + &.is-admin { background: $comment-admin; padding: rem-calc(6) rem-calc(12); @@ -585,6 +587,12 @@ } } + .is-deleted { + background: $deleted; + margin-left: rem-calc(42); + padding: rem-calc(6) rem-calc(12); + } + .comment-children { border-left: 1px dashed $border; margin-left: rem-calc(42); diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index 55f79bfa0..570b7024c 100644 --- a/app/assets/stylesheets/participacion.scss +++ b/app/assets/stylesheets/participacion.scss @@ -822,6 +822,10 @@ img.initialjs-avatar { background: $association; } +.is-deleted { + background: $deleted; +} + .level-1 { background: $level-1; } diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 6240702d2..1954de5bd 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -76,6 +76,7 @@ $level-5: #F08A24; $author: #008CCF; $association: #C0392B; +$deleted: #E7E7E7; $comment-author: rgba(45,144,248,.15); $comment-level-5: rgba(255,241,204,1); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b9e75c56..9df8c4874 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,7 @@ require "application_responder" class ApplicationController < ActionController::Base + before_filter :authenticate check_authorization unless: :devise_controller? include SimpleCaptcha::ControllerHelpers self.responder = ApplicationResponder @@ -15,6 +16,14 @@ class ApplicationController < ActionController::Base before_action :ensure_signup_complete + def authenticate + if Rails.env.staging? || Rails.env.production? + authenticate_or_request_with_http_basic do |username, password| + username == Rails.application.secrets.username && password == Rails.application.secrets.password + end + end + end + rescue_from CanCan::AccessDenied do |exception| redirect_to main_app.root_url, alert: exception.message end diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 60819fcf6..85ca6d496 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -1,5 +1,5 @@ class DebatesController < ApplicationController - before_action :parse_order, only: :index + before_action :parse_order, :parse_tag_filter, only: :index before_action :authenticate_user!, except: [:index, :show] load_and_authorize_resource @@ -7,6 +7,7 @@ class DebatesController < ApplicationController def index @debates = Debate.search(params).page(params[:page]).for_render.send("sort_by_#{@order}") + @tags = ActsAsTaggableOn::Tag.all set_debate_votes(@debates) end @@ -77,4 +78,9 @@ class DebatesController < ApplicationController @order = @valid_orders.include?(params[:order]) ? params[:order] : 'created_at' end + def parse_tag_filter + valid_tags = ActsAsTaggableOn::Tag.all.map(&:name) + @tag_filter = params[:tag] if valid_tags.include?(params[:tag]) + end + end diff --git a/app/models/comment.rb b/app/models/comment.rb index fa5f72164..c23c5c993 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -61,10 +61,6 @@ class Comment < ActiveRecord::Base cached_votes_down end - def not_visible? - hidden? || user.hidden? - end - def ignored_flag? ignored_flag_at.present? end diff --git a/app/models/letter.rb b/app/models/letter.rb index 58e326d58..75b5a5437 100644 --- a/app/models/letter.rb +++ b/app/models/letter.rb @@ -18,7 +18,7 @@ class Letter end def address - @address ||= UserApi.new(user).address + @address ||= CensusApi.new(user).address end def letter_requested! @@ -50,4 +50,4 @@ class Letter district: address[:nombre_distrito] } end -end \ No newline at end of file +end diff --git a/app/models/residence.rb b/app/models/residence.rb index b9610015e..511f1cb0c 100644 --- a/app/models/residence.rb +++ b/app/models/residence.rb @@ -36,10 +36,10 @@ class Residence self.date_of_birth = date_to_string(date_of_birth) - residency = UserApi.new(self) + residency = CensusApi.new(self) errors.add(:residence_in_madrid, false) unless residency.valid? self.date_of_birth = string_to_date(date_of_birth) end -end \ No newline at end of file +end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 5ffff4a85..e21b148bc 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,16 +1,18 @@
<%= t("debates.comment.deleted") %>
+