cleans up

This commit is contained in:
rgarcia
2016-01-25 20:52:18 +01:00
parent 328f5b4472
commit dbc19090ed
17 changed files with 21 additions and 342 deletions

View File

@@ -1,5 +0,0 @@
function call_function()
{
location.href = "/new_debate_map/" + $('#district-selector-participation').val() ;
}

View File

@@ -1,5 +0,0 @@
function call_function()
{
location.href = "/new_proposal_map/" + $('#district-selector-participation').val() ;
}

View File

@@ -4,24 +4,14 @@ class Admin::TagsController < Admin::BaseController
respond_to :html, :js
def index
@tags = ActsAsTaggableOn::Tag.order(kind: :asc, id: :asc).page(params[:page])
@tags = ActsAsTaggableOn::Tag.order(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)
@@ -36,16 +26,11 @@ class Admin::TagsController < Admin::BaseController
private
def tag_params
params.require(:tag).permit(:featured, :name, :kind)
params.require(:tag).permit(:featured, :name)
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

View File

@@ -5,6 +5,8 @@ class Management::ProposalsController < Management::BaseController
before_action :check_verified_user, except: :print
before_action :set_proposal, only: [:vote, :show]
before_action :parse_search_terms, only: :index
before_action :load_categories, only: [:new, :edit]
before_action :load_geozones, only: [:edit]
has_orders %w{confidence_score hot_score created_at most_commented random}, only: [:index, :print]
has_orders %w{most_voted newest}, only: :show
@@ -43,7 +45,7 @@ class Management::ProposalsController < Management::BaseController
managed_user
end
### Duplicated in application_controller. Move to a concenrn.
### Duplicated in application_controller. Move to a concern.
def set_proposal_votes(proposals)
@proposal_votes = current_user ? current_user.proposal_votes(proposals) : {}
end

View File

@@ -3,7 +3,7 @@
<p>Desde aquí puedes administrar el sistema, a través de las siguientes acciones:</p>
<h3>Temas de debate o propuesta</h3>
<h3>Temas de debate</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>

View File

@@ -7,34 +7,25 @@
<%= 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">
</div>
<%= 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),

View File

@@ -48,11 +48,5 @@
</aside>
</div>
<div class="small-12 medium-3 column">
<aside class="sidebar" role="complementary">
<%= link_to t("shared.tags_cloud.map"), mad_path %>
</aside>
</div>
</div>
</section>

View File

@@ -1,74 +0,0 @@
<%= javascript_include_tag "new_debate_map" %>
<div id="proposals" class="proposals-list small-12 medium-9 column">
<h3><%= t("proposals.index.map_district") %></h3>
</br>
<%= image_tag("Distritos_Madrid.jpg", :usemap => "#MadridMap") %>
<map name="MadridMap">
<area shape="poly" coords="3,86,27,60,134,54,220,88,295,3,348,85,312,108,230,94,270,198,248,239,200,259,57,235,34,164" href="/debates?tag=Fuencarral-El+Pardo" title="Fuencarral - El Pardo" alt="Fuencarral - El Pardo">
<area shape="poly" coords="54,234,200,261,185,329,115,355,125,290,105,288,90,261,50,246" href="/debates?tag=Moncloa-Aravaca" title="Moncloa - Aravaca" alt="Moncloa - Aravaca">
<area shape="poly" coords="199,258,228,253,224,292,199,290,196,292" href="/debates?tag=Tetu%C3%A1n" title="Tetuán" alt="Tetuán">
<area shape="poly" coords="190,292,222,294,224,324,193,317" href="/debates?tag=Chamber%C3%AD" title="Chamberí" alt="Chamberí">
<area shape="poly" coords="190,317,184,342,214,352,218,325" href="/debates?tag=Centro" title="Centro" alt="Centro">
<area shape="poly" coords="179,335,113,357,48,355,68,406,114,416,147,381,181,350" href="/debates?tag=Latina" title="Latina" alt="Latina">
<area shape="poly" coords="178,353,198,370,176,412,116,416,176,354" href="/debates?tag=Carabanchel" title="Carabanchel" alt="Carabanchel">
<area shape="poly" coords="184,342,218,351,238,373,214,390,183,348" href="/debates?tag=Arganzuela" title="Arganzuela" alt="Arganzuela">
<area shape="poly" coords="178,412,201,371,222,420" href="/debates?tag=Usera" title="Usera" alt="Usera">
<area shape="poly" coords="177,415,225,424,245,470,183,478,168,451" href="/debates?tag=Villaverde" title="Villaverde" alt="Villaverde">
<area shape="poly" coords="231,247,224,303,237,309,257,300,246,241" href="/debates?tag=Chamart%C3%ADn" title="Chamartin" alt="Chamartin">
<area shape="poly" coords="223,306,235,310,256,301,258,335,219,332" href="/debates?tag=Salamanca" title="Salamanca" alt="Salamanca">
<area shape="poly" coords="218,334,259,338,240,369,216,350" href="/debates?tag=Retiro" title="Retiro" alt="Retiro">
<area shape="poly" coords="214,390,250,356,265,362,271,372,295,384,291,397,256,406,243,420,223,422" href="/debates?tag=Puente+de+Vallecas" title="Puente de Vallecas" alt="Puente de Vallecas">
<area shape="poly" coords="227,423,258,407,292,397,295,387,322,398,323,413,374,440,334,494,317,502,261,468,246,471" href="/debates?tag=Villa+de+Vallecas" title="Villa de Vallecas" alt="Villa de Vallecas">
<area shape="poly" coords="271,197,297,205,320,203,338,229,305,255,301,272,326,295,277,296,258,265,262,245,249,238" href="/debates?tag=Hortaleza" title="Hortaleza" alt="Hortaleza">
<area shape="poly" coords="334,217,391,207,387,222,420,274,410,305,327,295,312,283,304,258,339,232" href="/debates?tag=Barajas" title="Barajas" alt="Barajas">
<area shape="poly" coords="246,240,258,243,258,267,285,307,301,347,258,338,255,271" href="/debates?tag=Ciudad+Lineal" title="Ciudad Lineal" alt="Ciudad Lineal">
<area shape="poly" coords="259,338,302,346,290,380,251,355" href="/debates?tag=Moratalaz" title="Moratalaz" alt="Moratalaz">
<area shape="poly" coords="282,295,404,306,372,320,351,340,335,359,303,346" href="/debates?tag=San+Blas-Canillejas" title="San Blas - Canillejas" alt="San Blas - Canillejas">
<area shape="poly" coords="291,381,304,347,335,362,351,342,358,355,392,358,404,342,423,360,417,392,393,387,375,438,325,413,323,393" href="/debates?tag=Vic%C3%A1lvaro" title="Vicálvaro" alt="Vicálvaro">
</map>
<br>
<div id="districtslist">
<% tag_cloud @district_cloud, %w[s m l] do |tag, css_class| %>
<%= link_to tag.name, debates_path(tag: tag.name) %>
<br>
<% end %>
</div>
<h3><%= t("debates.new.start_new_district") %></h3>
</br>
<label for="district-selector-participation" ><%= t("proposals.index.select_district") %></label>
<select name="district-selector"
id="district-selector-participation">
<% @district_cloud.each do |distri| %>
<option value='<%= distri.name %>'>
<%= distri.name%>
</option>
<% end %>
</select>
</br>
<div id="startdebatewithtag">
<%= link_to t("debates.index.start_debate"), "javascript:", :onclick => "call_function();" , class: 'button radius' %>
</div>
</div>
<div class="small-12 medium-3 column">
<aside class="sidebar" role="complementary">
<%= link_to t("debates.index.start_debate"), new_debate_path, class: 'button radius expand' %>
<%= render "shared/tag_cloud", taggable: 'debate' %>
</aside>
</div>

View File

@@ -1,81 +0,0 @@
<%= javascript_include_tag "new_proposal_map" %>
<div id="proposals" class="proposals-list small-12 medium-9 column">
<h3><%= t("proposals.index.map_district") %></h3>
</br>
<%= image_tag("Distritos_Madrid.jpg", :usemap => "#MadridMap") %>
<map name="MadridMap">
<area shape="poly" coords="3,86,27,60,134,54,220,88,295,3,348,85,312,108,230,94,270,198,248,239,200,259,57,235,34,164" href="/proposals?tag=Fuencarral-El+Pardo" title="Fuencarral - El Pardo" alt="Fuencarral - El Pardo">
<area shape="poly" coords="54,234,200,261,185,329,115,355,125,290,105,288,90,261,50,246" href="/proposals?tag=Moncloa-Aravaca" title="Moncloa - Aravaca" alt="Moncloa - Aravaca">
<area shape="poly" coords="199,258,228,253,224,292,199,290,196,292" href="/proposals?tag=Tetu%C3%A1n" title="Tetuán" alt="Tetuán">
<area shape="poly" coords="190,292,222,294,224,324,193,317" href="/proposals?tag=Chamber%C3%AD" title="Chamberí" alt="Chamberí">
<area shape="poly" coords="190,317,184,342,214,352,218,325" href="/proposals?tag=Centro" title="Centro" alt="Centro">
<area shape="poly" coords="179,335,113,357,48,355,68,406,114,416,147,381,181,350" href="/proposals?tag=Latina" title="Latina" alt="Latina">
<area shape="poly" coords="178,353,198,370,176,412,116,416,176,354" href="/proposals?tag=Carabanchel" title="Carabanchel" alt="Carabanchel">
<area shape="poly" coords="184,342,218,351,238,373,214,390,183,348" href="/proposals?tag=Arganzuela" title="Arganzuela" alt="Arganzuela">
<area shape="poly" coords="178,412,201,371,222,420" href="/proposals?tag=Usera" title="Usera" alt="Usera">
<area shape="poly" coords="177,415,225,424,245,470,183,478,168,451" href="/proposals?tag=Villaverde" title="Villaverde" alt="Villaverde">
<area shape="poly" coords="231,247,224,303,237,309,257,300,246,241" href="/proposals?tag=Chamart%C3%ADn" title="Chamartin" alt="Chamartin">
<area shape="poly" coords="223,306,235,310,256,301,258,335,219,332" href="/proposals?tag=Salamanca" title="Salamanca" alt="Salamanca">
<area shape="poly" coords="218,334,259,338,240,369,216,350" href="/proposals?tag=Retiro" title="Retiro" alt="Retiro">
<area shape="poly" coords="214,390,250,356,265,362,271,372,295,384,291,397,256,406,243,420,223,422" href="/proposals?tag=Puente+de+Vallecas" title="Puente de Vallecas" alt="Puente de Vallecas">
<area shape="poly" coords="227,423,258,407,292,397,295,387,322,398,323,413,374,440,334,494,317,502,261,468,246,471" href="/proposals?tag=Villa+de+Vallecas" title="Villa de Vallecas" alt="Villa de Vallecas">
<area shape="poly" coords="271,197,297,205,320,203,338,229,305,255,301,272,326,295,277,296,258,265,262,245,249,238" href="/proposals?tag=Hortaleza" title="Hortaleza" alt="Hortaleza">
<area shape="poly" coords="334,217,391,207,387,222,420,274,410,305,327,295,312,283,304,258,339,232" href="/proposals?tag=Barajas" title="Barajas" alt="Barajas">
<area shape="poly" coords="246,240,258,243,258,267,285,307,301,347,258,338,255,271" href="/proposals?tag=Ciudad+Lineal" title="Ciudad Lineal" alt="Ciudad Lineal">
<area shape="poly" coords="259,338,302,346,290,380,251,355" href="/proposals?tag=Moratalaz" title="Moratalaz" alt="Moratalaz">
<area shape="poly" coords="282,295,404,306,372,320,351,340,335,359,303,346" href="/proposals?tag=San+Blas-Canillejas" title="San Blas - Canillejas" alt="San Blas - Canillejas">
<area shape="poly" coords="291,381,304,347,335,362,351,342,358,355,392,358,404,342,423,360,417,392,393,387,375,438,325,413,323,393" href="/proposals?tag=Vic%C3%A1lvaro" title="Vicálvaro" alt="Vicálvaro">
</map>
<br>
<div id="districtslist">
<% tag_cloud @district_cloud, %w[s m l] do |tag, css_class| %>
<%= link_to tag.name, proposals_path(tag: tag.name) %>
<br>
<% end %>
</div>
<h3><%= t("proposals.new.start_new_district") %></h3>
</br>
<label for="district-selector-participation" ><%= t("proposals.index.select_district") %></label>
<select name="district-selector"
id="district-selector-participation">
<% @district_cloud.each do |distri| %>
<option value='<%= distri.name %>'>
<%= distri.name%>
</option>
<% end %>
</select>
</br>
<div id="startproposalwithtag">
<%= link_to t("proposals.index.start_proposal"), "javascript:", :onclick => "call_function();" , class: 'button radius' %>
</div>
</div>
<div class="small-12 medium-3 column">
<aside class="sidebar" role="complementary">
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button radius expand' %>
<%= render "shared/tag_cloud", taggable: 'proposal' %>
</aside>
</div>

View File

@@ -2,28 +2,12 @@
<div class="sidebar-divider"></div>
<h3><%= t("shared.tags_cloud.tags") %></h3>
<br>
<% tag_cloud @tag_cloud, %w[s m l] do |tag, css_class| %>
<%= link_to taggable_path(taggable, tag.name), class: css_class do %>
<%= tag.name %>
(<%= tag.send(taggable_counter_field(taggable)) %>)
<% end %>
<% end %>
<div class="sidebar-divider"></div>
<h3><%= t("shared.tags_cloud.categorys") %></h3>
<br>
<% tag_cloud @category_cloud, %w[s m l] do |tag, css_class| %>
<%= link_to taggable_path(taggable, tag.name), class: css_class do %>
<%= tag.name %>
<span class='label round info'><%= tag.send(taggable_counter_field(taggable)) %></span>
<% end %>
<% end %>
<div class="sidebar-divider"></div>
<h3><%= t("shared.tags_cloud.districts") %></h3>
<br>
<%= image_tag("Distritos_Madrid.jpg") %>
</div>

View File

@@ -1,7 +1,7 @@
<%- limit ||= nil %>
<% if taggable.tags.any? %>
<span class='tags'>
<span id="tags" class='tags'>
<% taggable.tag_list_with_limit(limit).each do |tag| %>
<%= link_to sanitize(tag.name), send("#{taggable.class.to_s.downcase.pluralize}_path", tag: tag.name) %>
<% end %>

View File

@@ -13,5 +13,3 @@ Rails.application.config.assets.precompile += %w( ckeditor/* )
Rails.application.config.assets.precompile += %w( ie_lt9.js )
Rails.application.config.assets.precompile += %w( stat_graphs.js )
Rails.application.config.assets.precompile += %w( print.css )
Rails.application.config.assets.precompile += %w( new_proposal_map.js )
Rails.application.config.assets.precompile += %w( new_debate_map.js )

View File

@@ -27,10 +27,6 @@ Rails.application.routes.draw do
patch :do_finish_signup, to: 'users/registrations#do_finish_signup'
end
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
get '/welcome', to: 'welcome#welcome'
get '/highlights', to: 'welcome#highlights', as: :highlights
@@ -237,55 +233,6 @@ Rails.application.routes.draw do
resources :spending_proposals, only: [:new, :create, :show]
end
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
@@ -293,12 +240,6 @@ Rails.application.routes.draw do
mount Tolk::Engine => '/translate', :as => 'tolk'
# static pages
get '/map', to: 'proposals#map_district'
get '/new_proposal_map/:district', to: 'proposals#new', as: 'new_proposal_map'
get '/mad', to: 'debates#map_district'
get '/new_debate_map/:district', to: 'debates#new', as: 'new_debate_map'
get '/blog' => redirect("http://diario.madrid.es/participa/")
resources :pages, path: '/', only: [:show]
end

View File

@@ -1,5 +0,0 @@
class AddKindToTags < ActiveRecord::Migration
def change
add_column :tags, :kind, :string, limit: 40
end
end

View File

@@ -267,7 +267,6 @@ FactoryGirl.define do
factory :tag, class: 'ActsAsTaggableOn::Tag' do
sequence(:name) { |n| "Tag #{n} name" }
kind 'category'
trait :featured do
featured true

View File

@@ -17,6 +17,7 @@ feature 'Admin tags' do
scenario 'Create' do
visit admin_tags_path
expect(page).to_not have_content 'important issues'
within("form.new_tag") do
@@ -25,6 +26,7 @@ feature 'Admin tags' do
end
visit admin_tags_path
expect(page).to have_content 'important issues'
end
@@ -79,48 +81,4 @@ 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

View File

@@ -66,7 +66,4 @@ describe 'ActsAsTaggableOn' do
end
end
end