Commit 192156471ff1122c2de9e47ff9e8e8aead765a3e
1 parent
53362515
Exists in
master
added endpoint to return random topics - one by category
Showing
2 changed files
with
12 additions
and
17 deletions
Show diff stats
lib/dialoga_plugin.rb
lib/dialoga_plugin/api.rb
| 1 | 1 | class DialogaPlugin::API < Grape::API |
| 2 | 2 | |
| 3 | -# resource :states do | |
| 4 | -# | |
| 5 | -# get do | |
| 6 | -# states = State.select([:id, :name]).order(:name) | |
| 7 | -# present states | |
| 8 | -# end | |
| 9 | -# | |
| 10 | -# get ':id/cities' do | |
| 11 | -# state = State.find(params[:id]) | |
| 12 | -# cities = City.where(:parent_id => state.id).select([:id, :name]).order(:name) | |
| 13 | -# present cities | |
| 14 | -# end | |
| 15 | -# | |
| 16 | -# end | |
| 3 | + resource :dialoga_plugin do | |
| 4 | + get 'random_topics/:discussion_id' do | |
| 5 | + discussion = ProposalsDiscussionPlugin::Discussion.find(params[:discussion_id]) | |
| 6 | + | |
| 7 | + # render articles using Entity Article | |
| 8 | + present discussion.random_topics_one_by_category, :with => Noosfero::API::Entities::Article, :fields => params[:fields] | |
| 9 | + end | |
| 10 | + end | |
| 11 | + | |
| 17 | 12 | end | ... | ... |