Commit c7b2cb8c279b411ee3c78e04566521cefcf6f3e4
Exists in
staging
and in
1 other branch
Merge branch 'staging' of softwarepublico.gov.br:noosferogov/noosfero into staging
Showing
5 changed files
with
17 additions
and
24 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -103,8 +103,6 @@ class CmsController < MyProfileController |
| 103 | 103 | end |
| 104 | 104 | end |
| 105 | 105 | end |
| 106 | - | |
| 107 | - escape_fields @article | |
| 108 | 106 | end |
| 109 | 107 | |
| 110 | 108 | def new |
| ... | ... | @@ -174,9 +172,6 @@ class CmsController < MyProfileController |
| 174 | 172 | return |
| 175 | 173 | end |
| 176 | 174 | end |
| 177 | - | |
| 178 | - escape_fields @article | |
| 179 | - | |
| 180 | 175 | render :action => 'edit' |
| 181 | 176 | end |
| 182 | 177 | |
| ... | ... | @@ -519,10 +514,4 @@ class CmsController < MyProfileController |
| 519 | 514 | end |
| 520 | 515 | end |
| 521 | 516 | |
| 522 | - def escape_fields article | |
| 523 | - unless article.kind_of?(RssFeed) | |
| 524 | - @escaped_body = CGI::escapeHTML(article.body || '') | |
| 525 | - @escaped_abstract = CGI::escapeHTML(article.abstract || '') | |
| 526 | - end | |
| 527 | - end | |
| 528 | 517 | end | ... | ... |
app/helpers/action_tracker_helper.rb
| ... | ... | @@ -15,7 +15,7 @@ module ActionTrackerHelper |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | def join_community_description ta |
| 18 | - n_('has joined 1 community:<br />%{name}'.html_safe, 'has joined %{num} communities:<br />%{name}'.html_safe, ta.get_resource_name.size) % { | |
| 18 | + n_('has joined 1 community:<br />%{name}', 'has joined %{num} communities:<br />%{name}', ta.get_resource_name.size).html_safe % { | |
| 19 | 19 | num: ta.get_resource_name.size, |
| 20 | 20 | name: ta.collect_group_with_index(:resource_name) do |n,i| |
| 21 | 21 | link = link_to image_tag(ta.get_resource_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/community-icon.png")), | ... | ... |
app/views/shared/_lead_and_body.html.erb
| ... | ... | @@ -23,11 +23,7 @@ |
| 23 | 23 | <% if f %> |
| 24 | 24 | <%= labelled_form_field(_(abstract_label), f.text_area(abstract_method, abstract_options)) %> |
| 25 | 25 | <% else %> |
| 26 | - <% if @article.kind_of?(Article) %> | |
| 27 | - <%= labelled_form_field(_(abstract_label), text_area_tag("article[abstract]", @escaped_abstract, abstract_options)) %> | |
| 28 | - <% else %> | |
| 29 | - <%= labelled_form_field(_(abstract_label), text_area(object, abstract_method, abstract_options)) %> | |
| 30 | - <% end %> | |
| 26 | + <%= labelled_form_field(_(abstract_label), text_area(object, abstract_method, abstract_options)) %> | |
| 31 | 27 | <% end %> |
| 32 | 28 | </div> |
| 33 | 29 | <div style="margin-top: 10px;"> |
| ... | ... | @@ -35,11 +31,7 @@ |
| 35 | 31 | <% if f %> |
| 36 | 32 | <%= labelled_form_field(_(body_label), f.text_area(body_method, body_options)) %> |
| 37 | 33 | <% else %> |
| 38 | - <% if @article.kind_of?(Article) %> | |
| 39 | - <%= labelled_form_field(_(body_label), text_area_tag("article[body]", @escaped_body, body_options)) %> | |
| 40 | - <% else %> | |
| 41 | - <%= labelled_form_field(_(body_label), text_area(object, body_method, body_options)) %> | |
| 42 | - <% end %> | |
| 34 | + <%= labelled_form_field(_(body_label), text_area(object, body_method, body_options)) %> | |
| 43 | 35 | <% end %> |
| 44 | 36 | </div> |
| 45 | 37 | ... | ... |
lib/noosfero/api/v1/search.rb
| ... | ... | @@ -19,10 +19,14 @@ module Noosfero |
| 19 | 19 | scope = scope.where(make_conditions_with_parameter(params)) |
| 20 | 20 | scope = scope.joins(:categories).where(:categories => {:id => params[:category_ids]}) if params[:category_ids].present? |
| 21 | 21 | scope = scope.where('articles.children_count > 0') if params[:has_children].present? |
| 22 | + | |
| 23 | + order = make_order_with_parameters(profile || environment, :articles, params) | |
| 24 | + scope = scope.reorder(order) | |
| 25 | + | |
| 22 | 26 | query = params[:query] || "" |
| 23 | - order = "more_recent" | |
| 27 | + search_order = "more_recent" | |
| 24 | 28 | |
| 25 | - options = {:filter => order, :template_id => params[:template_id]} | |
| 29 | + options = {:filter => search_order, :template_id => params[:template_id]} | |
| 26 | 30 | |
| 27 | 31 | search_result = find_by_contents(asset, context, scope, query, {:page => 1}, options) |
| 28 | 32 | ... | ... |
test/api/search_test.rb
| ... | ... | @@ -155,4 +155,12 @@ class SearchTest < ActiveSupport::TestCase |
| 155 | 155 | assert_equal [article2.id], json['articles'].map {|a| a['id']} |
| 156 | 156 | end |
| 157 | 157 | |
| 158 | + should 'list articles with order' do | |
| 159 | + article1 = fast_create(Article, :profile_id => person.id, created_at: Time.now - 1.day) | |
| 160 | + article2 = fast_create(Article, :profile_id => person.id, created_at: Time.now) | |
| 161 | + params = {order: 'created_at DESC'} | |
| 162 | + get "/api/v1/search/article?#{params.to_query}" | |
| 163 | + json = JSON.parse(last_response.body) | |
| 164 | + assert_equal [article2.id, article1.id], json['articles'].map {|a| a['id']} | |
| 165 | + end | |
| 158 | 166 | end | ... | ... |