Commit 01cdf3548bd13d592462d1133c1311cb840f925e

Authored by MoisesMachado
1 parent 2a5de396

ActionItem261: changing all filds of articles and products to created_at and references to it


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1681 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/search_controller.rb
... ... @@ -9,7 +9,7 @@ class SearchController < ApplicationController
9 9 protected
10 10  
11 11 def search(finder, query)
12   - finder.find_by_contents(query).sort_by(&:created_at).sort_by do |hit|
  12 + finder.find_by_contents(query).sort_by do |hit|
13 13 -(relevance_for(hit))
14 14 end
15 15 end
... ...
app/helpers/application_helper.rb
... ... @@ -468,4 +468,23 @@ module ApplicationHelper
468 468 content_tag('div', result)
469 469 end
470 470  
  471 + def select_city(name, top_level='Nacional')
  472 + city_field_name = "#{object}[#{method}]"
  473 + state_field_name = "#{object}_#{method}_state"
  474 + region_field_name = "#{object}_#{method}_region"
  475 +
  476 + selected_state = nil
  477 + selected_region = nil
  478 +
  479 + regions = Region.find_by_name(top_level).children
  480 +
  481 + select_tag(region_field_name, options_for_select(regions.map {|r| [r.name, r.id] } + ['---','']) +
  482 + select_tag(state_field_name, options_for_select(['---', ''])) +
  483 + select_tag(city_fied_name, options_for_select(['---',''])) +
  484 +
  485 + observe_field(country_field_name, :update => state_field_name, :url => { :controller => 'geography', :action => 'states' }, :with => 'country' ) +
  486 + observe_field(country_field_name, :update => city_field_name, :url => { :controller => 'geography', :action => 'cities_by_country' }, :with => 'country') +
  487 + observe_field(state_field_name, :update => city_field_name, :url => { :controller => 'geography', :action => 'cities' }, :with => 'state_id')
  488 + end
  489 +
471 490 end
... ...
app/models/article.rb
... ... @@ -33,7 +33,7 @@ class Article < ActiveRecord::Base
33 33 # retrieves the latest +limit+ articles, sorted from the most recent to the
34 34 # oldest.
35 35 def self.recent(limit)
36   - options = { :limit => limit, :order => 'created_on desc, articles.id desc' }
  36 + options = { :limit => limit, :order => 'created_at desc, articles.id desc' }
37 37 self.find(:all, options)
38 38 end
39 39  
... ...
app/models/category.rb
... ... @@ -37,7 +37,7 @@ class Category < ActiveRecord::Base
37 37 end
38 38  
39 39 def recent_comments(limit = 10)
40   - comments.find(:all, :order => 'created_on DESC, comments.id DESC', :limit => limit)
  40 + comments.find(:all, :order => 'created_at DESC, comments.id DESC', :limit => limit)
41 41 end
42 42  
43 43 def most_commented_articles(limit = 10)
... ...
app/models/comment.rb
... ... @@ -36,7 +36,7 @@ class Comment < ActiveRecord::Base
36 36 end
37 37  
38 38 def self.recent(limit = nil)
39   - self.find(:all, :order => 'created_on desc, id desc', :limit => limit)
  39 + self.find(:all, :order => 'created_at desc, id desc', :limit => limit)
40 40 end
41 41  
42 42 end
... ...
app/models/rss_feed.rb
... ... @@ -88,7 +88,7 @@ class RssFeed < Article
88 88 xml.description(article.abstract)
89 89 end
90 90 # rfc822
91   - xml.pubDate(article.created_on.rfc2822)
  91 + xml.pubDate(article.created_at.rfc2822)
92 92 # link to article
93 93 xml.link(url_for(article.url))
94 94 xml.guid(url_for(article.url))
... ...
app/views/content_viewer/_comment.rhtml
... ... @@ -23,7 +23,7 @@
23 23 <div class="comment-info">
24 24 <%= _('By %{author} on %{date}') % {
25 25 :author => comment.author ? link_to(comment.author.name, comment.author.url) : content_tag('u', comment.name),
26   - :date => show_time(comment.created_on) } %>
  26 + :date => show_time(comment.created_at) } %>
27 27 <%= '<br/>' + _('(unauthenticated user)') if ! comment.author %>
28 28 </div>
29 29 <div class="comment-text">
... ...
app/views/search/_article.rhtml
... ... @@ -6,6 +6,6 @@
6 6 <%= _('by %s') % link_to(article.last_changed_by.name, article.last_changed_by.url) %>
7 7 </span>
8 8 <% end %>
9   - <span class="cat_item_update"><%= _('Last update: %s.') % show_date(article.updated_on) %></span>
  9 + <span class="cat_item_update"><%= _('Last update: %s.') % show_date(article.updated_at) %></span>
10 10 </div>
11 11 </li>
... ...
app/views/search/_display_results.rhtml
... ... @@ -27,4 +27,4 @@
27 27 <% end %>
28 28 <% end %>
29 29 <br style="clear:both" />
30   -<div><!-- end id="search-results" -->
  30 +</div><!-- end id="search-results" -->
... ...
db/migrate/031_add_timestamps_in_product.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class AddTimestampsInProduct < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :products, :created_at, :datetime
  4 + add_column :products, :updated_at, :datetime
  5 + end
  6 +
  7 + def self.down
  8 + remove_column :products, :created_at, :datetime
  9 + remove_column :products, :updated_at, :datetime
  10 + end
  11 +end
... ...
lib/noosfero/core_ext/string.rb
... ... @@ -37,7 +37,7 @@ class String
37 37 end
38 38  
39 39 def to_slug
40   - transliterate.downcase.gsub(/^\d+/,'').gsub( /[^a-z0-9~\s:;+=_.-]/, '').gsub(/[\s:;+=_.-]+/, '-').gsub(/-$ | ^-/, '').to_s
  40 + transliterate.downcase.gsub(/^\d+/,'').gsub( /[^a-z0-9~\s:;+=_.-]/, '').gsub(/[\s:;+=_.-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s
41 41 end
42 42  
43 43 end
... ...
test/functional/search_controller_test.rb
... ... @@ -352,7 +352,7 @@ class SearchControllerTest &lt; Test::Unit::TestCase
352 352 :products => 'Products',
353 353 }
354 354 names.each do |thing, description|
355   - assert_tag :tag => 'div', :attributes => { :id => "search-results-#{thing}" }, :descendant => { :tag => 'h3', :content => description }
  355 + assert_tag :tag => 'div', :attributes => { :class => /search-results-#{thing}/ }, :descendant => { :tag => 'h3', :content => description }
356 356 assert_tag :tag => 'a', :content => "display #{thing.to_s.singularize}"
357 357 end
358 358 end
... ...