Commit 3015766829921c3b8a9704969a40a6a3c8eeb68b
1 parent
132e019c
Exists in
master
and in
22 other branches
Update software_info
- Add timestamps - Visibility filter on API Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
3 changed files
with
16 additions
and
0 deletions
Show diff stats
src/noosfero-spb/software_communities/db/migrate/20160114190943_add_timestamps_to_software_info.rb
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +class AddTimestampsToSoftwareInfo < ActiveRecord::Migration | ||
2 | + def up | ||
3 | + change_table :software_infos do |t| | ||
4 | + t.datetime :created_at, :null => false, :default => Time.zone.now | ||
5 | + t.datetime :updated_at, :null => false, :default => Time.zone.now | ||
6 | + end | ||
7 | + end | ||
8 | + | ||
9 | + def down | ||
10 | + remove_column :software_infos, :created_at | ||
11 | + remove_column :software_infos, :updated_at | ||
12 | + end | ||
13 | +end |
src/noosfero-spb/software_communities/lib/software_communities_plugin/api.rb
@@ -9,6 +9,7 @@ class SoftwareCommunitiesPlugin::API < Grape::API | @@ -9,6 +9,7 @@ class SoftwareCommunitiesPlugin::API < Grape::API | ||
9 | get do | 9 | get do |
10 | authenticate! | 10 | authenticate! |
11 | softwares = select_filtered_collection_of(environment,'communities',params).joins(:software_info) | 11 | softwares = select_filtered_collection_of(environment,'communities',params).joins(:software_info) |
12 | + softwares = softwares.visible_for_person(current_person) | ||
12 | present softwares.map{|o|o.software_info}, :with => Entities::SoftwareInfo | 13 | present softwares.map{|o|o.software_info}, :with => Entities::SoftwareInfo |
13 | end | 14 | end |
14 | 15 |
src/noosfero-spb/software_communities/lib/software_communities_plugin/api_entities.rb
@@ -18,6 +18,8 @@ module Entities | @@ -18,6 +18,8 @@ module Entities | ||
18 | expose :software_languages | 18 | expose :software_languages |
19 | expose :software_databases | 19 | expose :software_databases |
20 | expose :operating_system_names | 20 | expose :operating_system_names |
21 | + expose :created_at, :format_with => :timestamp | ||
22 | + expose :updated_at, :format_with => :timestamp | ||
21 | expose :community_id do |software_info,options| | 23 | expose :community_id do |software_info,options| |
22 | software_info.community.id | 24 | software_info.community.id |
23 | end | 25 | end |