diff --git a/app/assets/stylesheets/print.css b/app/assets/stylesheets/print.css index ef76f607e..5297826c8 100644 --- a/app/assets/stylesheets/print.css +++ b/app/assets/stylesheets/print.css @@ -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; } diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 5655b0f8a..25258d2ab 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -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, featured: :desc).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,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 diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index df232069b..1df510eec 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -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 @@ -32,18 +34,24 @@ module CommentableActions @resource.author = current_user if @resource.save_with_captcha - track_event + 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 end def edit - load_featured_tags + load_featured_tags + load_category_tags + load_district_tags end def update @@ -51,7 +59,9 @@ module CommentableActions if resource.save_with_captcha redirect_to resource, notice: t('flash.actions.update.notice', resource_name: "#{resource_name.capitalize}") else - load_featured_tags + 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? diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb index da64cba15..bb3c71e0a 100644 --- a/app/views/admin/dashboard/index.html.erb +++ b/app/views/admin/dashboard/index.html.erb @@ -3,7 +3,7 @@
Desde aquí puedes administrar el sistema, a través de las siguientes acciones:
-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 marcarlos para ser propuestos al crear debates (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)
<%= t("debates.form.tags_instructions") %>
<%= f.text_field :tag_list, value: @debate.tag_list.to_s, label: false, placeholder: t("debates.form.tags_placeholder"), class: 'js-tag-list' %> diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 4c14730fe..65722fbba 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -43,7 +43,13 @@ <%= f.label :tag_list, t("proposals.form.tags_label") %><%= t("proposals.form.tags_instructions") %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 276e3ca96..22bd6d97b 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -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" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index b124d60e3..a1b9395a1 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -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" diff --git a/config/locales/en.yml b/config/locales/en.yml index f8edcd12a..60c22b775 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" diff --git a/config/locales/es.yml b/config/locales/es.yml index 8d2a2c2f7..246221c04 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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" diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index d7a362d9a..8bd6f9876 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -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") diff --git a/db/migrate/20160108101736_add_kind_to_tags.rb b/db/migrate/20160108101736_add_kind_to_tags.rb new file mode 100644 index 000000000..661099fd2 --- /dev/null +++ b/db/migrate/20160108101736_add_kind_to_tags.rb @@ -0,0 +1,5 @@ +class AddKindToTags < ActiveRecord::Migration + def change + add_column :tags, :kind, :string, limit: 40 + end +end diff --git a/db/schema.rb b/db/schema.rb index ca180b297..8136d925b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/factories.rb b/spec/factories.rb index 2c20000ca..fc71e241c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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