Commit fb38345f76621f8fd8664d82be6ef2b469375bb1

Authored by Evandro Junior
2 parents 4c937832 1223902d

Merge branch 'stable' of gitlab.com:participa/noosfero into stable

app/views/cms/edit.html.erb
1 <%= error_messages_for 'article' %> 1 <%= error_messages_for 'article' %>
2 2
3 -<% show_media_panel = environment.enabled?('media_panel') && [TinyMceArticle, TextileArticle, Event, EnterpriseHomepage].any?{|klass| @article.kind_of?(klass)} %> 3 +<% show_media_panel = environment.enabled?('media_panel') && [TinyMceArticle, TextileArticle, Event, EnterpriseHomepage, ProposalsDiscussionPlugin::Topic, ProposalsDiscussionPlugin::Discussion].any?{|klass| @article.kind_of?(klass)} %>
4 4
5 <div class='<%= (show_media_panel ? 'with_media_panel' : 'no_media_panel') %>'> 5 <div class='<%= (show_media_panel ? 'with_media_panel' : 'no_media_panel') %>'>
6 <%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %> 6 <%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %>
lib/noosfero/api/entities.rb
@@ -64,6 +64,8 @@ module Noosfero @@ -64,6 +64,8 @@ module Noosfero
64 expose :profile, :using => Profile 64 expose :profile, :using => Profile
65 expose :categories, :using => Category 65 expose :categories, :using => Category
66 expose :image, :using => Image 66 expose :image, :using => Image
  67 + expose :votes_for
  68 + expose :votes_against
67 end 69 end
68 70
69 class Article < ArticleBase 71 class Article < ArticleBase
lib/noosfero/api/v1/articles.rb
@@ -40,8 +40,15 @@ module Noosfero @@ -40,8 +40,15 @@ module Noosfero
40 40
41 get ':id/children' do 41 get ':id/children' do
42 article = find_article(environment.articles, params[:id]) 42 article = find_article(environment.articles, params[:id])
  43 +
  44 + votes_order = params.delete(:order) if params[:order]=='votes_score'
43 articles = select_filtered_collection_of(article, 'children', params) 45 articles = select_filtered_collection_of(article, 'children', params)
44 articles = articles.display_filter(current_person, nil) 46 articles = articles.display_filter(current_person, nil)
  47 +
  48 + if votes_order
  49 + articles = articles.joins('left join votes on articles.id=votes.voteable_id').group('articles.id').reorder('sum(coalesce(votes.vote, 0)) DESC')
  50 + end
  51 +
45 present articles, :with => Entities::Article, :fields => params[:fields] 52 present articles, :with => Entities::Article, :fields => params[:fields]
46 end 53 end
47 54
lib/noosfero/api/v1/users.rb
@@ -24,11 +24,15 @@ module Noosfero @@ -24,11 +24,15 @@ module Noosfero
24 24
25 present user, :with => Entities::User 25 present user, :with => Entities::User
26 end 26 end
27 - 27 +
  28 + get "/me" do
  29 + present current_user, :with => Entities::User
  30 + end
  31 +
28 get ":id" do 32 get ":id" do
29 present environment.users.find_by_id(params[:id]), :with => Entities::User 33 present environment.users.find_by_id(params[:id]), :with => Entities::User
30 end 34 end
31 - 35 +
32 get ":id/permissions" do 36 get ":id/permissions" do
33 user = environment.users.find(params[:id]) 37 user = environment.users.find(params[:id])
34 output = {} 38 output = {}
plugins/proposals_discussion
1 -Subproject commit 3a32ff13a05df2d443410642172c2a4df1585ca1 1 +Subproject commit f3f2b7f6fd7a2aeb927f5f9cce9a7d3c5e655a3c
public/designs/themes/participa-theme
1 -Subproject commit 4716af097fe208efdf75a72997328ed23c00f4f6 1 +Subproject commit 105c0714d83699cd2eb1822514ba5a01c1d870b0
public/javascripts/application.js
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 *= require slick.js 30 *= require slick.js
31 *= require select-or-die/_src/selectordie.js 31 *= require select-or-die/_src/selectordie.js
32 *= require block-store.js 32 *= require block-store.js
  33 +*= require jquery.typewatch.js
33 */ 34 */
34 35
35 // scope for noosfero stuff 36 // scope for noosfero stuff
public/proposal-app
1 -Subproject commit 318967386e6f99b0debb2e3a9076bae3502e65fc 1 +Subproject commit 1ce4dbee53562a2ef69a1208f6565b46199e551b
test/unit/api/users_test.rb
@@ -40,4 +40,10 @@ class UsersTest &lt; ActiveSupport::TestCase @@ -40,4 +40,10 @@ class UsersTest &lt; ActiveSupport::TestCase
40 assert_includes json["user"]["permissions"], community.identifier 40 assert_includes json["user"]["permissions"], community.identifier
41 end 41 end
42 42
  43 + should 'get logged user' do
  44 + get "/api/v1/users/me?#{params.to_query}"
  45 + json = JSON.parse(last_response.body)
  46 + assert_equal user.id, json['user']['id']
  47 + end
  48 +
43 end 49 end