filter by districts and categories
This commit is contained in:
BIN
app/assets/images/Distritos_Madrid.jpg
Normal file
BIN
app/assets/images/Distritos_Madrid.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
5
app/assets/javascripts/new_debate_map.js
Normal file
5
app/assets/javascripts/new_debate_map.js
Normal file
@@ -0,0 +1,5 @@
|
||||
function call_function()
|
||||
{
|
||||
|
||||
location.href = "/new_debate_map/" + $('#district-selector-participation').val() ;
|
||||
}
|
||||
5
app/assets/javascripts/new_proposal_map.js
Normal file
5
app/assets/javascripts/new_proposal_map.js
Normal file
@@ -0,0 +1,5 @@
|
||||
function call_function()
|
||||
{
|
||||
|
||||
location.href = "/new_proposal_map/" + $('#district-selector-participation').val() ;
|
||||
}
|
||||
@@ -11,6 +11,8 @@ module CommentableActions
|
||||
index_customization if index_customization.present?
|
||||
|
||||
@tag_cloud = tag_cloud
|
||||
@district_cloud = load_district_tags
|
||||
@category_cloud = load_category_tags
|
||||
set_resource_votes(@resources)
|
||||
set_resources_instance
|
||||
end
|
||||
@@ -26,9 +28,6 @@ module CommentableActions
|
||||
def new
|
||||
@resource = resource_model.new
|
||||
set_resource_instance
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -36,7 +35,7 @@ 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)
|
||||
@@ -51,7 +50,7 @@ module CommentableActions
|
||||
end
|
||||
|
||||
def edit
|
||||
load_featured_tags
|
||||
load_featured_tags
|
||||
load_category_tags
|
||||
load_district_select
|
||||
end
|
||||
@@ -61,7 +60,7 @@ 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
|
||||
@@ -69,6 +68,13 @@ module CommentableActions
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def map_district
|
||||
@tag_cloud = tag_cloud
|
||||
@district_cloud = load_district_tags
|
||||
@category_cloud = load_category_tags
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_event
|
||||
@@ -79,23 +85,53 @@ module CommentableActions
|
||||
resource_model.last_week.tag_counts.order("#{resource_name.pluralize}_count": :desc, name: :asc).limit(5)
|
||||
end
|
||||
|
||||
def load_category_tags
|
||||
|
||||
if resource_model.to_s=="Proposal"
|
||||
ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'category' and proposals_count>0").
|
||||
order(proposals_count: :desc)
|
||||
else
|
||||
ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'category' and debates_count>0").
|
||||
order(debates_count: :desc)
|
||||
end
|
||||
end
|
||||
def load_district_tags
|
||||
|
||||
if resource_model.to_s =="Proposal"
|
||||
|
||||
ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'district' and proposals_count>0").
|
||||
order(name: :asc)
|
||||
else
|
||||
ActsAsTaggableOn::Tag.select("tags.*").
|
||||
where("kind = 'district' and debates_count>0").
|
||||
order(name: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
order(kind: :asc, id: :asc)
|
||||
end
|
||||
def load_district_select
|
||||
@district_select = Geozone.select("geozones.name, geozones.id").
|
||||
order(id: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
def parse_tag_filter
|
||||
if params[:tag].present?
|
||||
@tag_filter = params[:tag] if ActsAsTaggableOn::Tag.named(params[:tag]).exists?
|
||||
end
|
||||
|
||||
if params[:district].present?
|
||||
@tag_filter = params[:district] if ActsAsTaggableOn::Disctrict.named(params[:district]).exists?
|
||||
end
|
||||
end
|
||||
|
||||
def parse_search_terms
|
||||
|
||||
@@ -7,7 +7,7 @@ class DebatesController < ApplicationController
|
||||
before_action :parse_advanced_search_terms, only: :index
|
||||
before_action :parse_tag_filter, only: :index
|
||||
before_action :set_search_order, only: :index
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
before_action :authenticate_user!, except: [:index, :show, :map_district]
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class ProposalsController < ApplicationController
|
||||
before_action :parse_advanced_search_terms, only: :index
|
||||
before_action :parse_tag_filter, only: :index
|
||||
before_action :set_search_order, only: :index
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
before_action :authenticate_user!, except: [:index, :show, :map_district]
|
||||
|
||||
has_orders %w{hot_score confidence_score created_at relevance}, only: :index
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
|
||||
@@ -10,6 +10,8 @@ module Abilities
|
||||
can :read, Legislation
|
||||
can :read, User
|
||||
can [:search, :read], Annotation
|
||||
can :map_district, Proposal
|
||||
can :map_district, Debate
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,5 +47,12 @@
|
||||
<%= render "shared/tag_cloud", taggable: 'debate' %>
|
||||
</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>
|
||||
|
||||
74
app/views/debates/map_district.html.erb
Normal file
74
app/views/debates/map_district.html.erb
Normal file
@@ -0,0 +1,74 @@
|
||||
<%= 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>
|
||||
@@ -56,5 +56,12 @@
|
||||
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<aside class="sidebar" role="complementary">
|
||||
<%= link_to t("shared.tags_cloud.map"), map_path %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
81
app/views/proposals/map_district.html.erb
Normal file
81
app/views/proposals/map_district.html.erb
Normal file
@@ -0,0 +1,81 @@
|
||||
<%= 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>
|
||||
|
||||
|
||||
|
||||
@@ -8,4 +8,22 @@
|
||||
(<%= 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>
|
||||
|
||||
@@ -13,3 +13,5 @@ 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 )
|
||||
|
||||
@@ -105,6 +105,8 @@ en:
|
||||
search_results:
|
||||
one: " containing the term '%{search_term}'"
|
||||
other: " containing the term '%{search_term}'"
|
||||
map_district: "Districts of Madrid"
|
||||
select_district: "Select your district"
|
||||
select_order: Order by
|
||||
start_debate: Start a debate
|
||||
title: Debates
|
||||
@@ -121,6 +123,7 @@ en:
|
||||
recommendation_two: Any debate or comment suggesting illegal action will be deleted, as well as those intending to sabotage the debate spaces. Anything else is allowed.
|
||||
recommendations_title: Recommendations for creating a debate
|
||||
start_new: Start a debate
|
||||
start_new_district: "Start a debate for your district"
|
||||
show:
|
||||
author_deleted: User deleted
|
||||
back_link: Go back
|
||||
@@ -294,6 +297,7 @@ en:
|
||||
recommendation_two: Any proposal or comment suggesting illegal action will be deleted, as well as those intending to sabotage the debate spaces. Anything else is allowed.
|
||||
recommendations_title: Recommendations for creating a proposal
|
||||
start_new: Create new proposal
|
||||
start_new_district: "Start a proposal for your district"
|
||||
proposal:
|
||||
already_supported: You have already supported this proposal. Share it!
|
||||
comments:
|
||||
@@ -360,6 +364,9 @@ en:
|
||||
print_button: Print this info
|
||||
tags_cloud:
|
||||
tags: Trending
|
||||
districts: "Districs"
|
||||
categorys: "Categories"
|
||||
map: "View map of districts"
|
||||
unflag: Unflag
|
||||
simple_captcha:
|
||||
label: Enter the text from the image in the box below
|
||||
|
||||
@@ -105,6 +105,8 @@ es:
|
||||
search_results:
|
||||
one: " que contiene '%{search_term}'"
|
||||
other: " que contienen '%{search_term}'"
|
||||
map_district: "Distritos de Madrid"
|
||||
select_district: "Selecciona tu distrito"
|
||||
select_order: Ordenar por
|
||||
start_debate: Empieza un debate
|
||||
title: Debates
|
||||
@@ -121,6 +123,7 @@ es:
|
||||
recommendation_two: Cualquier debate o comentario que implique una acción ilegal será eliminado, también los que tengan la intención de sabotear los espacios de debate, todo lo demás está permitido.
|
||||
recommendations_title: Recomendaciones para crear un debate
|
||||
start_new: Empezar un debate
|
||||
start_new_district: "Empieza un debate para tu distrito"
|
||||
show:
|
||||
author_deleted: Usuario eliminado
|
||||
back_link: Volver
|
||||
@@ -294,6 +297,7 @@ es:
|
||||
recommendation_two: Cualquier propuesta o comentario que implique una acción ilegal será eliminada, también las que tengan la intención de sabotear los espacios de propuesta, todo lo demás está permitido.
|
||||
recommendations_title: Recomendaciones para crear una propuesta
|
||||
start_new: Crear una propuesta
|
||||
start_new_district: "Crea una propuesta para tu distrito"
|
||||
proposal:
|
||||
already_supported: "¡Ya has apoyado esta propuesta, compártela!"
|
||||
comments:
|
||||
@@ -360,6 +364,9 @@ es:
|
||||
print_button: Imprimir esta información
|
||||
tags_cloud:
|
||||
tags: Tendencias
|
||||
districts: "Distritos"
|
||||
categorys: "Categorias"
|
||||
map: "Ver mapa de distritos"
|
||||
unflag: Deshacer denuncia
|
||||
simple_captcha:
|
||||
label: Introduce el texto de la imagen en la siguiente caja
|
||||
|
||||
@@ -286,6 +286,11 @@ Rails.application.routes.draw do
|
||||
|
||||
# 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
|
||||
|
||||
@@ -71,10 +71,68 @@ end
|
||||
org_user_ids = User.organizations.pluck(:id)
|
||||
not_org_users = User.where(['users.id NOT IN(?)', org_user_ids])
|
||||
|
||||
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")
|
||||
ActsAsTaggableOn::Tag.create!(name: "Fuencarral-El Pardo", featured: true, kind: "district")
|
||||
|
||||
|
||||
|
||||
puts "Creating Debates"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
tags = ['Centro', 'Arganzuela', 'Retiro','Salamanca', 'Chamartín', 'Tetuán', 'Chamberí', 'Fuencarral-El Pardo', 'Moncloa-Aravaca', 'Latina', 'Carabanchel', 'Usera', 'Puente de Vallecas', 'Moratalaz', 'Ciudad Lineal', 'Hortaleza', 'Villaverde', 'Villa de Vallecas', 'Vicálvaro', 'San Blas', 'Barajas']
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
debate = Debate.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(','),
|
||||
terms_of_service: "1")
|
||||
puts " #{debate.title}"
|
||||
end
|
||||
|
||||
|
||||
tags = ['Consumo y comercio', 'Cultura y ocio', 'Deportes', 'Economía', 'Educación', 'Emergencias y seguridad', 'Hacienda', 'Medio ambiente', 'Movilidad y transportes', 'Oposiciones y empleo', 'Salud', 'Servicios sociales', 'Urbanismo y vivienda']
|
||||
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
@@ -88,10 +146,29 @@ tags = Faker::Lorem.words(25)
|
||||
puts " #{debate.title}"
|
||||
end
|
||||
|
||||
|
||||
puts "Creating Proposals"
|
||||
|
||||
tags = Faker::Lorem.words(25)
|
||||
tags = ['Centro', 'Arganzuela', 'Retiro','Salamanca', 'Chamartín', 'Tetuán', 'Chamberí', 'Fuencarral-El Pardo', 'Moncloa-Aravaca', 'Latina', 'Carabanchel', 'Usera', 'Puente de Vallecas', 'Moratalaz', 'Ciudad Lineal', 'Hortaleza', 'Villaverde', 'Villa de Vallecas', 'Vicálvaro', 'San Blas', 'Barajas']
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
question: Faker::Lorem.sentence(3),
|
||||
summary: Faker::Lorem.sentence(3),
|
||||
responsible_name: Faker::Name.name,
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
tag_list: tags.sample(3).join(','),
|
||||
terms_of_service: "1")
|
||||
puts " #{proposal.title}"
|
||||
end
|
||||
|
||||
|
||||
tags = ['Consumo y comercio', 'Cultura y ocio', 'Deportes', 'Economía', 'Educación', 'Emergencias y seguridad', 'Hacienda', 'Medio ambiente', 'Movilidad y transportes', 'Oposiciones y empleo', 'Salud', 'Servicios sociales', 'Urbanismo y vivienda']
|
||||
(1..30).each do |i|
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
|
||||
5
db/migrate/20160119132601_add_kind_to_tags.rb
Normal file
5
db/migrate/20160119132601_add_kind_to_tags.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddKindToTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, :kind, :string
|
||||
end
|
||||
end
|
||||
@@ -317,6 +317,7 @@ ActiveRecord::Schema.define(version: 20160122153329) do
|
||||
t.integer "proposals_count", default: 0
|
||||
t.string "kind", limit: 40
|
||||
t.integer "spending_proposals_count", default: 0
|
||||
t.string "kind"
|
||||
end
|
||||
|
||||
add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree
|
||||
|
||||
@@ -901,4 +901,28 @@ feature 'Debates' do
|
||||
visit debate_path(debate)
|
||||
expect(page).to have_content('User deleted')
|
||||
end
|
||||
|
||||
|
||||
scenario "Filtered by district" do
|
||||
tag1= ActsAsTaggableOn::Tag.create!(name: "Centro", featured: true, kind: "district")
|
||||
tag2= ActsAsTaggableOn::Tag.create!(name: "Puente de Vallecas", featured: true, kind: "district")
|
||||
tag3= ActsAsTaggableOn::Tag.create!(name: "Retiro", featured: true, kind: "district")
|
||||
tag4= ActsAsTaggableOn::Tag.create!(name: "Salamanca", featured: true, kind: "district")
|
||||
|
||||
debate1 = create(:debate, tag_list: tag1)
|
||||
debate2 = create(:debate, tag_list: tag2)
|
||||
debate3 = create(:debate, tag_list: tag3)
|
||||
debate4 = create(:debate, tag_list: tag4)
|
||||
visit debates_path
|
||||
|
||||
click_link "View map of districts"
|
||||
within("#districtslist") do
|
||||
click_link "Puente de Vallecas"
|
||||
end
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_content(debate2.title)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1000,4 +1000,27 @@ feature 'Proposals' do
|
||||
visit proposals_path
|
||||
expect(page).to have_content('User deleted')
|
||||
end
|
||||
|
||||
|
||||
scenario "Filtered by district" do
|
||||
tag1= ActsAsTaggableOn::Tag.create!(name: "Centro", featured: true, kind: "district")
|
||||
tag2= ActsAsTaggableOn::Tag.create!(name: "Puente de Vallecas", featured: true, kind: "district")
|
||||
tag3= ActsAsTaggableOn::Tag.create!(name: "Retiro", featured: true, kind: "district")
|
||||
tag4= ActsAsTaggableOn::Tag.create!(name: "Salamanca", featured: true, kind: "district")
|
||||
|
||||
proposal1 = create(:proposal, tag_list: tag1)
|
||||
proposal2 = create(:proposal, tag_list: tag2)
|
||||
proposal3 = create(:proposal, tag_list: tag3)
|
||||
proposal4 = create(:proposal, tag_list: tag4)
|
||||
visit proposals_path
|
||||
|
||||
click_link "View map of districts"
|
||||
within("#districtslist") do
|
||||
click_link "Puente de Vallecas"
|
||||
end
|
||||
within("#proposals") do
|
||||
expect(page).to have_css('.proposal', count: 1)
|
||||
expect(page).to have_content(proposal2.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user