merges master and fixes conflicts
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -822,6 +822,10 @@ img.initialjs-avatar {
|
||||
background: $association;
|
||||
}
|
||||
|
||||
.is-deleted {
|
||||
background: $deleted;
|
||||
}
|
||||
|
||||
.level-1 {
|
||||
background: $level-1;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
@@ -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
|
||||
end
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<div class="row">
|
||||
<div id="<%= dom_id(comment) %>" class="comment small-12 column">
|
||||
|
||||
<% if comment.not_visible? %>
|
||||
<%= t("debates.comment.deleted") %>
|
||||
<% if comment.hidden? || comment.user.hidden? %>
|
||||
<% if comment.children_count > 0 %>
|
||||
<div class="is-deleted">
|
||||
<p><%= t("debates.comment.deleted") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
|
||||
<% if comment.as_administrator? %>
|
||||
<%= image_tag("admin_avatar.png", size: 32, class: "admin-avatar left") %>
|
||||
<% elsif comment.as_moderator? %>
|
||||
<%= image_tag("moderator_avatar.png", size: 32, class: "moderator-avatar left") %>
|
||||
<% else %>
|
||||
|
||||
<% if comment.user.organization? %>
|
||||
<%= image_tag("collective_avatar.png", size: 32, class: "avatar left") %>
|
||||
<% else %>
|
||||
@@ -19,7 +21,6 @@
|
||||
<% if comment.user.hidden? %>
|
||||
<i class="icon-deleted user-deleted"></i>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="comment-body">
|
||||
@@ -91,11 +92,10 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="comment-children">
|
||||
<%= render comment.children.for_render.reorder('id DESC, lft') %>
|
||||
</div>
|
||||
<div class="comment-children">
|
||||
<%= render comment.children.for_render.reorder('id DESC, lft') %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<div id="js-comment-form-<%= dom_id(parent) %>" <%= "style='display:none'".html_safe if toggeable %>>
|
||||
<%= form_for [@debate, Comment.new], remote: true do |f| %>
|
||||
<%= f.text_area :body, label: t("comments.form.leave_comment") %>
|
||||
<%= label_tag "comment-body-#{dom_id(parent)}", t("comments.form.leave_comment") %>
|
||||
<%= f.text_area :body, id: "comment-body-#{dom_id(parent)}", label: false %>
|
||||
<%= f.hidden_field :commentable_type, value: parent.class %>
|
||||
<%= f.hidden_field :commentable_id, value: parent.id %>
|
||||
|
||||
@@ -8,14 +9,14 @@
|
||||
|
||||
<% if can? :comment_as_moderator, @debate %>
|
||||
<div class="right">
|
||||
<%= f.check_box :as_moderator, label: false %>
|
||||
<%= f.label :as_moderator, t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
||||
<%= f.check_box :as_moderator, id: "comment-as-moderator-#{dom_id(parent)}", label: false %>
|
||||
<%= label_tag "comment-as-moderator-#{dom_id(parent)}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if can? :comment_as_administrator, @debate %>
|
||||
<div class="right">
|
||||
<%= f.check_box :as_administrator, label: false %>
|
||||
<%= f.label :as_administrator, t("comments.form.comment_as_admin"), class: "checkbox" %>
|
||||
<%= f.check_box :as_administrator, id: "comment-as-administrator-#{dom_id(parent)}",label: false %>
|
||||
<%= label_tag "comment-as-administrator-#{dom_id(parent)}", t("comments.form.comment_as_admin"), class: "checkbox" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var field_with_errors = "#js-comment-form-<%= dom_id(@parent) %> #comment_body";
|
||||
var field_with_errors = "#js-comment-form-<%= dom_id(@parent) %> #comment-body-<%= dom_id(@parent) %>";
|
||||
App.Comments.display_error(field_with_errors, "<%= j render('comments/errors') %>");
|
||||
|
||||
@@ -1,34 +1,45 @@
|
||||
<section role="main">
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="filters row">
|
||||
<div class="small-12 column">
|
||||
<h2><%= t("debates.index.showing") %></h2>
|
||||
<form class="inline-block">
|
||||
<select class="js-location-changer" name="order-selector">
|
||||
<% @valid_orders.each do |order| %>
|
||||
<option <%= 'selected' if order == @order %>
|
||||
value='<%= url_for(request.query_parameters.merge(order: order))%>'>
|
||||
<%= t("debates.index.orders.#{order}") %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /. Filters -->
|
||||
<div class="small-9 column">
|
||||
|
||||
<!-- Filter topic results -->
|
||||
<div class="filters row">
|
||||
<div class="small-12 column">
|
||||
<h2>
|
||||
<%= t("debates.index.filter_topic",
|
||||
number: "N",
|
||||
topic: "topic").html_safe %>
|
||||
</h2>
|
||||
<div class="inline-block" >
|
||||
<% if @tag_filter %>
|
||||
<h2>
|
||||
<%= t("debates.index.filter_topic",
|
||||
number: @debates.size,
|
||||
topic: @tag_filter) %>
|
||||
</h2>
|
||||
<% else %>
|
||||
<h2><%= t("debates.index.select_topic") %></h2>
|
||||
<form class="inline-block">
|
||||
<select class="js-location-changer" name="tag-filter">
|
||||
<option value="/" selected="selected"><%= t("debates.index.all") %></option>
|
||||
<% @tags.each do |tag| %>
|
||||
<option value='<%= url_for(request.query_parameters.merge(tag: tag.name))%>'>
|
||||
<%= tag.name %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</form>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="inline-block right">
|
||||
<h6 class="inline-block"><%= t("debates.index.select_order") %></h6>
|
||||
<form class="inline-block">
|
||||
<select class="js-location-changer" name="order-selector">
|
||||
<% @valid_orders.each do |order| %>
|
||||
<option <%= 'selected' if order == @order %>
|
||||
value='<%= url_for(request.query_parameters.merge(order: order))%>'>
|
||||
<%= t("debates.index.orders.#{order}") %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /. Filter topic results -->
|
||||
|
||||
<div class="row">
|
||||
<div id="debates" class="debates-list small-12 medium-9 column">
|
||||
|
||||
@@ -56,12 +56,14 @@ en:
|
||||
debates:
|
||||
index:
|
||||
create_debate: Create a debate
|
||||
showing: You are seeing debates
|
||||
select_order: Order by
|
||||
orders:
|
||||
created_at: newest
|
||||
total_votes: most voted
|
||||
likes: best rated
|
||||
select_topic: "Filter by topic:"
|
||||
filter_topic: "You are seeing %{number} debates with the topic '%{topic}'"
|
||||
all: All
|
||||
debate:
|
||||
debate: Debate
|
||||
comments:
|
||||
|
||||
@@ -56,12 +56,14 @@ es:
|
||||
debates:
|
||||
index:
|
||||
create_debate: Crea un debate
|
||||
showing: "Estás viendo los debates"
|
||||
select_order: Ordenar por
|
||||
orders:
|
||||
created_at: "más nuevos"
|
||||
total_votes: "más votados"
|
||||
likes: mejor valorados
|
||||
select_topic: "Filtrar por tema:"
|
||||
filter_topic: "Estás viendo %{number} debates con el tema '%{topic}'"
|
||||
all: Todos
|
||||
debate:
|
||||
debate: Debate
|
||||
comments:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class UserApi
|
||||
class CensusApi
|
||||
attr_accessor :client, :citizen, :response
|
||||
|
||||
def initialize(citizen)
|
||||
@@ -42,6 +42,8 @@ class UserApi
|
||||
end
|
||||
|
||||
def valid?
|
||||
return false unless data[:datos_habitante][:item].present?
|
||||
|
||||
citizen.date_of_birth == date_of_birth &&
|
||||
citizen.postal_code == postal_code
|
||||
end
|
||||
@@ -59,7 +59,7 @@ feature 'Comments' do
|
||||
login_as(user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in 'comment_body', with: 'Have you thought about...?'
|
||||
fill_in "comment-body-debate_#{debate.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
|
||||
within "#comments" do
|
||||
@@ -91,7 +91,7 @@ feature 'Comments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in 'comment_body', with: 'It will be done next week.'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
end
|
||||
|
||||
@@ -178,8 +178,8 @@ feature 'Comments' do
|
||||
login_as(moderator.user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in "comment_body", with: "I am moderating!"
|
||||
check "comment_as_moderator"
|
||||
fill_in "comment-body-debate_#{debate.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-debate_#{debate.id}"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
@@ -203,8 +203,8 @@ feature 'Comments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment_body", with: "I am moderating!"
|
||||
check "comment_as_moderator"
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
end
|
||||
|
||||
@@ -237,8 +237,8 @@ feature 'Comments' do
|
||||
login_as(admin.user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in "comment_body", with: "I am your Admin!"
|
||||
check "comment_as_administrator"
|
||||
fill_in "comment-body-debate_#{debate.id}", with: "I am your Admin!"
|
||||
check "comment-as-administrator-debate_#{debate.id}"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
@@ -262,8 +262,8 @@ feature 'Comments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment_body", with: "Top of the world!"
|
||||
check "comment_as_administrator"
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
end
|
||||
|
||||
|
||||
@@ -407,4 +407,34 @@ feature 'Debates' do
|
||||
expect(@most_liked_debate.title).to appear_before(@most_voted_debate.title)
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Debates can be filtered by tags', :js do
|
||||
let!(:debate1) { create(:debate, tag_list: ["Deporte", "Corrupción"]) }
|
||||
let!(:debate2) { create(:debate, tag_list: ["Deporte", "Fiestas populares"]) }
|
||||
let!(:debate3) { create(:debate, tag_list: ["Corrupción", "Fiestas populares"]) }
|
||||
|
||||
scenario 'By default no tag filter is applied' do
|
||||
visit debates_path
|
||||
|
||||
expect(page).to have_content('Filter by topic')
|
||||
expect(page).not_to have_content('with the topic')
|
||||
expect(page).to have_selector('#debates .debate', count: 3)
|
||||
end
|
||||
|
||||
scenario 'Debates are filtered by single tag' do
|
||||
visit debates_path
|
||||
|
||||
select('Deporte', from: 'tag-filter')
|
||||
|
||||
expect(page).not_to have_content('Filter by topic')
|
||||
expect(page).not_to have_select('tag-filter')
|
||||
expect(page).to have_content('with the topic')
|
||||
expect(current_url).to include('tag=Deporte')
|
||||
|
||||
expect(page).to have_selector('#debates .debate', count: 2)
|
||||
expect(page).to_not have_content(debate3.title)
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ feature 'Moderate Comments' do
|
||||
|
||||
feature 'Hiding Comments' do
|
||||
|
||||
scenario 'Hide', :js do
|
||||
scenario 'Hide without children hides the comment completely', :js do
|
||||
citizen = create(:user)
|
||||
moderator = create(:moderator)
|
||||
|
||||
@@ -23,7 +23,7 @@ feature 'Moderate Comments' do
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_content('This comment has been deleted')
|
||||
expect(page).to_not have_content('This comment has been deleted')
|
||||
expect(page).to_not have_content('SPAM')
|
||||
end
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ feature 'Verify Letter' do
|
||||
expect(page).to have_content "You will receive a letter to your home address"
|
||||
end
|
||||
|
||||
scenario "Error accessing address from UserApi" do
|
||||
scenario "Error accessing address from CensusApi" do
|
||||
user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111")
|
||||
|
||||
login_as(user)
|
||||
visit new_letter_path
|
||||
|
||||
allow_any_instance_of(UserApi).to receive(:address).and_return(nil)
|
||||
allow_any_instance_of(CensusApi).to receive(:address).and_return(nil)
|
||||
|
||||
click_button "Send me a letter"
|
||||
|
||||
@@ -57,4 +57,4 @@ feature 'Verify Letter' do
|
||||
expect(URI.parse(current_url).path).to eq(new_sms_path)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module CommonActions
|
||||
login_as(user2)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in 'comment_body', with: 'Have you thought about...?'
|
||||
fill_in "comment-body-debate_#{debate.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
end
|
||||
@@ -45,7 +45,7 @@ module CommonActions
|
||||
|
||||
click_link "Reply"
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in 'comment_body', with: 'It will be done next week.'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
end
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
|
||||
Reference in New Issue
Block a user