fixes conflicts
This commit is contained in:
@@ -28,6 +28,8 @@ img.left { display: none !important; }
|
||||
|
||||
li.name { display: none !important; }
|
||||
|
||||
li.kind { display: none !important; }
|
||||
|
||||
p.proposal-info span:nth-child(3) { display: none !important; }
|
||||
|
||||
.top-links { display: none !important; }
|
||||
|
||||
@@ -4,13 +4,23 @@ class Admin::TagsController < Admin::BaseController
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
@tags = ActsAsTaggableOn::Tag.order(featured: :desc).page(params[:page])
|
||||
@tags = ActsAsTaggableOn::Tag.order(kind: :asc, id: :asc).page(params[:page])
|
||||
@tag = ActsAsTaggableOn::Tag.new
|
||||
end
|
||||
|
||||
def create
|
||||
ActsAsTaggableOn::Tag.create(tag_params)
|
||||
redirect_to admin_tags_path
|
||||
@paramTag = params[:tag]
|
||||
if @paramTag[:name] == ""
|
||||
redirect_to admin_tags_path, notice: t("admin.tags.message")
|
||||
else
|
||||
search_tag
|
||||
if @tag.present?
|
||||
redirect_to admin_tags_path, notice: t("admin.tags.message_find")
|
||||
else
|
||||
ActsAsTaggableOn::Tag.create(tag_params)
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -26,11 +36,16 @@ class Admin::TagsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def tag_params
|
||||
params.require(:tag).permit(:featured, :name)
|
||||
params.require(:tag).permit(:featured, :name, :kind)
|
||||
end
|
||||
|
||||
def find_tag
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:id])
|
||||
end
|
||||
|
||||
def search_tag
|
||||
# @tag = ActsAsTaggableOn::Tag.where("name = '#{@paramTag[:name]}' and
|
||||
# kind = '#{@paramTag[:kind]}'")
|
||||
|
||||
@tag = ActsAsTaggableOn::Tag.where("upper(name) = upper('#{@paramTag[:name]}')")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,6 +27,8 @@ module CommentableActions
|
||||
@resource = resource_model.new
|
||||
set_resource_instance
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -34,18 +36,24 @@ module CommentableActions
|
||||
@resource.author = current_user
|
||||
|
||||
if @resource.save_with_captcha
|
||||
track_event
|
||||
track_event
|
||||
load_category_tags
|
||||
load_district_select
|
||||
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
|
||||
redirect_to redirect_path, notice: t("flash.actions.create.#{resource_name.underscore}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
set_resource_instance
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
load_featured_tags
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -53,7 +61,9 @@ module CommentableActions
|
||||
if resource.save_with_captcha
|
||||
redirect_to resource, notice: t("flash.actions.update.#{resource_name.underscore}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
set_resource_instance
|
||||
render :edit
|
||||
end
|
||||
@@ -72,6 +82,15 @@ module CommentableActions
|
||||
def load_featured_tags
|
||||
@featured_tags = ActsAsTaggableOn::Tag.where(featured: true)
|
||||
end
|
||||
def load_category_tags
|
||||
@category_tags = ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'category' and tags.featured = true").
|
||||
order(kind: :asc, id: :asc)
|
||||
end
|
||||
def load_district_select
|
||||
@district_select = Geozone.select("geozones.name, geozones.id").
|
||||
order(id: :asc)
|
||||
end
|
||||
|
||||
def parse_tag_filter
|
||||
if params[:tag].present?
|
||||
|
||||
@@ -35,7 +35,7 @@ class ProposalsController < ApplicationController
|
||||
private
|
||||
|
||||
def proposal_params
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key, :geozone_id)
|
||||
end
|
||||
|
||||
def resource_model
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<p>Desde aquí puedes administrar el sistema, a través de las siguientes acciones:</p>
|
||||
|
||||
<h3>Temas de debate</h3>
|
||||
<h3>Temas de debate o propuesta</h3>
|
||||
<p>Los temas (también llamadas tags, o etiquetas) de debate son palabras que definen los usuarios al crear debates, para catalogarlos (ej: sanidad, movilidad, arganzuela, ...). Aquí se pueden eliminar temas inapropiados, o <strong>marcarlos para ser propuestos al crear debates</strong> (cada usuario puede definir los que quiera, pero se le sugieren algunos que nos parecen útiles como catalogación por defecto; aquí se puede cambiar cuáles se sugieren)</p>
|
||||
|
||||
<h3>Propuestas/Debates/Comentarios ocultos</h3>
|
||||
|
||||
@@ -7,25 +7,34 @@
|
||||
<%= f.label :name, t("admin.tags.name.placeholder") %>
|
||||
<%= f.text_field :name, placeholder: t("admin.tags.name.placeholder"), label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.label :kind, t("admin.tags.kind.placeholder") %>
|
||||
<%= f.text_field :kind, placeholder: t("admin.tags.kind.placeholder"), label: false %>
|
||||
</div>
|
||||
<div class="is-featured small-12 medium-6 column">
|
||||
<%= f.label :featured do %>
|
||||
<%= f.check_box :featured, label: false %>
|
||||
<span class="checkbox"><%= t("admin.tags.mark_as_featured") %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.submit(t("admin.tags.create"), class: "button radius success") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= f.submit(t("admin.tags.create"), class: "button radius success") %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<br>
|
||||
<hr widht="30%" align="left">
|
||||
<h3><%= t("admin.tags.index.title") %>: <%= page_entries_info @tags %></h3>
|
||||
|
||||
<ul class="admin-list">
|
||||
<% @tags.each do |tag| %>
|
||||
<li>
|
||||
<span class="tag"><%= tag.name %></span>
|
||||
<div class="is-featured small-12 medium-6 column">
|
||||
<span class="tag"><%= tag.name %></span>
|
||||
</div>
|
||||
<div class="is-featured small-12 medium-6 column">
|
||||
<span class="tag"><%= tag.kind %></span>
|
||||
</div>
|
||||
|
||||
<%= form_for(tag,
|
||||
url: admin_tag_path(tag),
|
||||
|
||||
@@ -16,9 +16,14 @@
|
||||
<%= f.label :tag_list, t("debates.form.tags_label") %>
|
||||
<p class="note"><%= t("debates.form.tags_instructions") %></p>
|
||||
<span class="tags">
|
||||
<% @featured_tags.each do |tag| %>
|
||||
<%= f.label :tag_list, t("debates.form.tag_category_label") %>
|
||||
<% @category_tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
<%= f.label :tag_list, t("debates.form.tag_district_label") %>
|
||||
<% @district_select.each do |g| %>
|
||||
<a class="js-add-tag-link"><%= g.name%></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s, label: false, placeholder: t("debates.form.tags_placeholder"), class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
@@ -43,13 +43,18 @@
|
||||
<%= f.label :tag_list, t("proposals.form.tags_label") %>
|
||||
<p class="note"><%= t("proposals.form.tags_instructions") %></p>
|
||||
<span class="tags">
|
||||
<% @featured_tags.each do |tag| %>
|
||||
<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %>
|
||||
<% @category_tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
<%= f.label :district_tag_list, t("proposals.form.tag_district_label") %>
|
||||
<% @district_select.each do |g| %>
|
||||
<a class="js-add-tag-link"><%= g.name %></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<br>
|
||||
<%= f.text_field :tag_list, value: @proposal.tag_list.to_s, label: false, placeholder: t("proposals.form.tags_placeholder"), class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<% if current_user.unverified? %>
|
||||
<div class="small-12 column">
|
||||
<%= f.label :responsible_name, t("proposals.form.proposal_responsible_name") %>
|
||||
@@ -79,4 +84,4 @@
|
||||
<%= f.submit(class: "button radius", value: t("proposals.#{action_name}.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -233,3 +233,38 @@ puts "Confirming hiding in debates, comments & proposals"
|
||||
Comment.only_hidden.flagged.reorder("RANDOM()").limit(10).each(&:confirm_hide)
|
||||
Debate.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
|
||||
|
||||
|
||||
puts "Creating Tags Categories"
|
||||
|
||||
ActsAsTaggableOn::Tag.create!(name: "Asociaciones", featured: true, kind: "category")
|
||||
puts " Asociaciones"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Cultura", featured: true, kind: "category")
|
||||
puts " Cultura"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Deportes", featured: true, kind: "category")
|
||||
puts " Deportes"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Derechos SMedio Ambienteociales", featured: true, kind: "category")
|
||||
puts " Derechos Sociales"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Economía", featured: true, kind: "category")
|
||||
puts " Economía"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Empleo", featured: true, kind: "category")
|
||||
puts " Empleo"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Equidad", featured: true, kind: "category")
|
||||
puts " Equidad"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Sostenibilidad", featured: true, kind: "category")
|
||||
puts " Sostenibilidad"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Participación", featured: true, kind: "category")
|
||||
puts " Participación"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Movilidad", featured: true, kind: "category")
|
||||
puts " Movilidad"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medios", featured: true, kind: "category")
|
||||
puts " Medios"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salud", featured: true , kind: "category")
|
||||
puts " Salud"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Transparencia", featured: true, kind: "category")
|
||||
puts " Transparencia"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Seguridad y Emergencias", featured: true, kind: "category")
|
||||
puts " Seguridad y Emergencias"
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medio Ambiente", featured: true, kind: "category")
|
||||
puts " Medio Ambiente"
|
||||
|
||||
|
||||
5
db/migrate/20160108101736_add_kind_to_tags.rb
Normal file
5
db/migrate/20160108101736_add_kind_to_tags.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddKindToTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, :kind, :string, limit: 40
|
||||
end
|
||||
end
|
||||
@@ -199,7 +199,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
create_table "locks", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "tries", default: 0
|
||||
t.datetime "locked_until", default: '2000-01-01 00:01:01', null: false
|
||||
t.datetime "locked_until", default: '2000-01-01 07:01:01', null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
@@ -315,6 +315,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
t.boolean "featured", default: false
|
||||
t.integer "debates_count", default: 0
|
||||
t.integer "proposals_count", default: 0
|
||||
t.string "kind", limit: 40
|
||||
t.integer "spending_proposals_count", default: 0
|
||||
end
|
||||
|
||||
|
||||
@@ -267,6 +267,7 @@ FactoryGirl.define do
|
||||
|
||||
factory :tag, class: 'ActsAsTaggableOn::Tag' do
|
||||
sequence(:name) { |n| "Tag #{n} name" }
|
||||
kind 'category'
|
||||
|
||||
trait :featured do
|
||||
featured true
|
||||
|
||||
@@ -17,7 +17,6 @@ feature 'Admin tags' do
|
||||
|
||||
scenario 'Create' do
|
||||
visit admin_tags_path
|
||||
|
||||
expect(page).to_not have_content 'important issues'
|
||||
|
||||
within("form.new_tag") do
|
||||
@@ -26,7 +25,6 @@ feature 'Admin tags' do
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
expect(page).to have_content 'important issues'
|
||||
end
|
||||
|
||||
@@ -81,4 +79,48 @@ feature 'Admin tags' do
|
||||
expect(page).to_not have_content tag2.name
|
||||
end
|
||||
|
||||
scenario 'validate add new tags' do
|
||||
visit admin_tags_path
|
||||
expect(page).to_not have_content 'important issues'
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: 'important issues'
|
||||
click_button 'Create Topic'
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: 'important issues'
|
||||
click_button 'Create Topic'
|
||||
end
|
||||
expect(page).to have_content 'name of the topic already exists'
|
||||
end
|
||||
|
||||
scenario 'validate uppercase name add new tags' do
|
||||
visit admin_tags_path
|
||||
expect(page).to_not have_content 'important issues'
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: 'important issues'
|
||||
click_button 'Create Topic'
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: 'IMPORTANT ISSUES'
|
||||
click_button 'Create Topic'
|
||||
end
|
||||
expect(page).to have_content 'name of the topic already exists'
|
||||
end
|
||||
|
||||
scenario 'validate name new tags' do
|
||||
visit admin_tags_path
|
||||
|
||||
within("form.new_tag") do
|
||||
click_button 'Create Topic'
|
||||
end
|
||||
expect(page).to have_content 'The name of the topic is mandatory filling'
|
||||
end
|
||||
end
|
||||
@@ -204,9 +204,13 @@ feature 'Debates' do
|
||||
login_as(author)
|
||||
end
|
||||
|
||||
scenario 'using featured tags', :js do
|
||||
scenario 'using featured tags and geozone district', :js do
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
create(:tag, :featured, name: tag_name)
|
||||
create(:tag, :featured, name: tag_name, kind: "category")
|
||||
end
|
||||
|
||||
['Distrito A', 'Distrito B'].each do |geozone_name|
|
||||
create(:geozone, name: geozone_name)
|
||||
end
|
||||
|
||||
visit new_debate_path
|
||||
@@ -220,12 +224,19 @@ feature 'Debates' do
|
||||
find('.js-add-tag-link', text: tag_name).click
|
||||
end
|
||||
|
||||
['Distrito A', 'Distrito B'].each do |geozone_name|
|
||||
find('.js-add-tag-link', text: geozone_name).click
|
||||
end
|
||||
|
||||
click_button 'Start a debate'
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
end
|
||||
['Distrito A', 'Distrito B'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'using dangerous strings' do
|
||||
|
||||
@@ -271,18 +271,22 @@ feature 'Proposals' do
|
||||
expect(page.html).to_not include "<script>alert('hey')</script>"
|
||||
end
|
||||
|
||||
context 'Tagging proposals' do
|
||||
context 'Tagging proposals ' do
|
||||
let(:author) { create(:user) }
|
||||
|
||||
background do
|
||||
login_as(author)
|
||||
end
|
||||
|
||||
scenario 'using featured tags', :js do
|
||||
scenario 'using featured tags and geozone district', :js do
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
create(:tag, :featured, name: tag_name)
|
||||
end
|
||||
|
||||
['Distrito A', 'Distrito B'].each do |geozone_name|
|
||||
create(:geozone, name: geozone_name)
|
||||
end
|
||||
|
||||
visit new_proposal_path
|
||||
|
||||
fill_in 'proposal_title', with: 'A test with enough characters'
|
||||
@@ -298,12 +302,20 @@ feature 'Proposals' do
|
||||
find('.js-add-tag-link', text: tag_name).click
|
||||
end
|
||||
|
||||
['Distrito A', 'Distrito B'].each do |geozone_name|
|
||||
find('.js-add-tag-link', text: geozone_name).click
|
||||
end
|
||||
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
['Medio Ambiente', 'Ciencia'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
end
|
||||
|
||||
['Distrito A', 'Distrito B'].each do |tag_name|
|
||||
expect(page).to have_content tag_name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'using dangerous strings' do
|
||||
|
||||
Reference in New Issue
Block a user