Add Thematic structure and Districts - Iss685
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,14 +4,24 @@ 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, featured: :desc).page(params[:page])
|
||||
@tag = ActsAsTaggableOn::Tag.new
|
||||
end
|
||||
|
||||
def create
|
||||
@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
|
||||
@tag.update(tag_params)
|
||||
@@ -26,11 +36,14 @@ 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]}'")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,8 @@ module CommentableActions
|
||||
@resource = resource_model.new
|
||||
set_resource_instance
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_tags
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -33,10 +35,14 @@ module CommentableActions
|
||||
|
||||
if @resource.save_with_captcha
|
||||
track_event
|
||||
load_category_tags
|
||||
load_district_tags
|
||||
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
|
||||
redirect_to redirect_path, notice: t('flash.actions.create.notice', resource_name: "#{resource_name.capitalize}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_tags
|
||||
set_resource_instance
|
||||
render :new
|
||||
end
|
||||
@@ -44,6 +50,8 @@ module CommentableActions
|
||||
|
||||
def edit
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_tags
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -52,6 +60,8 @@ module CommentableActions
|
||||
redirect_to resource, notice: t('flash.actions.update.notice', resource_name: "#{resource_name.capitalize}")
|
||||
else
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_tags
|
||||
set_resource_instance
|
||||
render :edit
|
||||
end
|
||||
@@ -70,7 +80,16 @@ 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_tags
|
||||
@district_tags = ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'district' and tags.featured = true").
|
||||
order(kind: :asc, id: :asc)
|
||||
end
|
||||
def parse_tag_filter
|
||||
if params[:tag].present?
|
||||
@tag_filter = params[:tag] if ActsAsTaggableOn::Tag.named(params[:tag]).exists?
|
||||
|
||||
@@ -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>
|
||||
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= f.submit(t("admin.tags.create"), class: "button radius success") %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<% 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>
|
||||
<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,16 @@
|
||||
<%= 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 %>
|
||||
<hr widht="30%" align="left">
|
||||
<%= f.label :tag_list, t("debates.form.tag_district_label") %>
|
||||
<% @district_tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.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,7 +43,13 @@
|
||||
<%= 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 %>
|
||||
<hr widht="30%" align="left">
|
||||
<%= f.label :district_tag_list, t("proposals.form.tag_district_label") %>
|
||||
<% @district_tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
@@ -11,7 +11,7 @@ en:
|
||||
title: "Administration"
|
||||
menu:
|
||||
settings: "General settings"
|
||||
debate_topics: "Debate topics"
|
||||
debate_topics: "Debate or Proposal topics"
|
||||
hidden_proposals: "Hidden proposals"
|
||||
hidden_debates: "Hidden debates"
|
||||
hidden_comments: "Hidden comments"
|
||||
@@ -57,11 +57,15 @@ en:
|
||||
confirm_hide: "Confirm"
|
||||
tags:
|
||||
index:
|
||||
title: "Debate topics"
|
||||
add_tag: "Add a new debate topic"
|
||||
mark_as_featured: "Propose topic upon creating debate"
|
||||
title: "Debate or Proposals topics"
|
||||
add_tag: "Add a new debate or new proposal topic"
|
||||
mark_as_featured: "Propose topic upon creating debate or proposal"
|
||||
message: "The name of the topic is mandatory filling"
|
||||
message_find: "name of the topic already exists"
|
||||
name:
|
||||
placeholder: "Type the name of the topic"
|
||||
kind:
|
||||
placeholder: "Type the group of the topic"
|
||||
create: "Create Topic"
|
||||
update: "Update Topic"
|
||||
destroy: "Destroy Topic"
|
||||
|
||||
@@ -11,7 +11,7 @@ es:
|
||||
title: "Administración"
|
||||
menu:
|
||||
settings: "Configuración global"
|
||||
debate_topics: "Temas de debate"
|
||||
debate_topics: "Temas de debate o propuesta"
|
||||
hidden_proposals: "Propuestas ocultas"
|
||||
hidden_debates: "Debates ocultos"
|
||||
hidden_comments: "Comentarios ocultos"
|
||||
@@ -57,11 +57,15 @@ es:
|
||||
confirm_hide: "Confirmar"
|
||||
tags:
|
||||
index:
|
||||
title: "Temas de debate"
|
||||
add_tag: "Añade un nuevo tema de debate"
|
||||
title: "Temas de debate o propuesta"
|
||||
add_tag: "Añade un nuevo tema de debate o propuesta"
|
||||
mark_as_featured: "Proponer tema al crear debate"
|
||||
message: "Nombre del Tema es de relleno obligatorio"
|
||||
message_find: "Nombre de Tema ya existe"
|
||||
name:
|
||||
placeholder: "Escribe el nombre del tema"
|
||||
kind:
|
||||
placeholder: "Escribe el grupo del tema"
|
||||
create: "Crear Tema"
|
||||
update: "Actualizar Tema"
|
||||
destroy: "Eliminar Tema"
|
||||
|
||||
@@ -112,8 +112,10 @@ en:
|
||||
debate_title: "Debate title"
|
||||
debate_text: "Initial debate text"
|
||||
tags_label: "Topics"
|
||||
tags_instructions: "Tag this debate. You can choose from our suggestions or enter your own."
|
||||
tags_instructions: "Tag this debate. You can choose from Categories and Districs suggestions or enter your own"
|
||||
tags_placeholder: "Enter the tags you would like to use, separated by commas (',')"
|
||||
tag_category_label: "Categories"
|
||||
tag_district_label: "Districts"
|
||||
show:
|
||||
back_link: "Go back"
|
||||
author_deleted: "User deleted"
|
||||
@@ -203,8 +205,10 @@ en:
|
||||
proposal_responsible_name: "Full name of the person submitting the proposal"
|
||||
proposal_responsible_name_note: "(individually or as representative of a collective; will not be displayed publically)"
|
||||
tags_label: "Tags"
|
||||
tags_instructions: "Tag this proposal. You can choose from our tags or add your own."
|
||||
tags_instructions: "Tag this proposal. You can choose from Categories and Districs tags or add your own"
|
||||
tags_placeholder: "Enter the tags you would like to use, separated by commas (',')"
|
||||
tag_category_label: "Category"
|
||||
tag_district_label: "District"
|
||||
show:
|
||||
back_link: "Go back"
|
||||
author_deleted: "User deleted"
|
||||
|
||||
@@ -112,8 +112,10 @@ es:
|
||||
debate_title: "Título del debate"
|
||||
debate_text: "Texto inicial del debate"
|
||||
tags_label: "Temas"
|
||||
tags_instructions: "Etiqueta este debate. Puedes elegir entre nuestras propuestas o introducir las que desees."
|
||||
tags_instructions: "Etiqueta este debate. Puedes elegir entre Categorias y Distritos propuestos o introducir las que desees."
|
||||
tags_placeholder: "Escribe las etiquetas que desees separadas por coma (',')"
|
||||
tag_category_label: "Categorías"
|
||||
tag_district_label: "Distritos"
|
||||
show:
|
||||
back_link: "Volver"
|
||||
author_deleted: "Usuario eliminado"
|
||||
@@ -203,8 +205,10 @@ es:
|
||||
proposal_responsible_name: "Nombre y apellidos de la persona que hace esta propuesta"
|
||||
proposal_responsible_name_note: "(individualmente o como representante de un colectivo; no se mostrará públicamente)"
|
||||
tags_label: "Temas"
|
||||
tags_instructions: "Etiqueta esta propuesta. Puedes elegir entre nuestras propuestas o introducir las que desees."
|
||||
tags_instructions: "Etiqueta esta propuesta. Puedes elegir entre Categorias y Distritos propuestos o introducir las que desees."
|
||||
tags_placeholder: "Escribe las etiquetas que desees separadas por una coma (',')"
|
||||
tag_category_label: "Categorías"
|
||||
tag_district_label: "Distritos"
|
||||
show:
|
||||
back_link: "Volver"
|
||||
author_deleted: "Usuario eliminado"
|
||||
|
||||
@@ -204,3 +204,45 @@ 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")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Cultura", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Deportes", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Derechos Sociales", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Economía", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Empleo", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Equidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Sostenibilidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Participación", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Movilidad", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medios", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salud", featured: true , kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Transparencia", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Seguridad y Emergencias", featured: true, kind: "category")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Medio Ambiente", featured: true, kind: "category")
|
||||
|
||||
puts "Creating Tags Districts"
|
||||
|
||||
ActsAsTaggableOn::Tag.create!(name: "Centro", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Arganzuela", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Retiro" , featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Salamanca" , featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Chamartín" , featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Tetuán" , featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Chamberí" , featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Moncloa-Aravaca", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Latina", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Carabanchel", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Usera", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Puente de Vallecas", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Moratalaz", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Ciudad Lineal", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Hortaleza", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Villaverde", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Villa de Vallecas", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Vicalvaro", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "San Blas-Canillejas", featured: true, kind: "district")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Barajas", featured: true, kind: "district")
|
||||
|
||||
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
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151215165824) do
|
||||
ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -283,6 +283,7 @@ ActiveRecord::Schema.define(version: 20151215165824) do
|
||||
t.boolean "featured", default: false
|
||||
t.integer "debates_count", default: 0
|
||||
t.integer "proposals_count", default: 0
|
||||
t.string "kind", limit: 40
|
||||
end
|
||||
|
||||
add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree
|
||||
|
||||
@@ -259,6 +259,7 @@ FactoryGirl.define do
|
||||
|
||||
factory :tag, class: 'ActsAsTaggableOn::Tag' do
|
||||
sequence(:name) { |n| "Tag #{n} name" }
|
||||
kind 'category'
|
||||
|
||||
trait :featured do
|
||||
featured true
|
||||
|
||||
Reference in New Issue
Block a user