Commit fda68f5c20f719214241dae9b18da405e2d61720
Committed by
Gabriela Navarro
1 parent
50fdcfa3
Exists in
master
Insert community's members information
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
4 changed files
with
25 additions
and
10 deletions
Show diff stats
controllers/colab_integration_plugin_controller.rb
@@ -6,9 +6,11 @@ class ColabIntegrationPluginController < ApplicationController | @@ -6,9 +6,11 @@ class ColabIntegrationPluginController < ApplicationController | ||
6 | } | 6 | } |
7 | 7 | ||
8 | environment.profiles.each do |profile| | 8 | environment.profiles.each do |profile| |
9 | - data["profiles"] << profile.attr_to_json | 9 | + data["profiles"] << profile.attr_to_hash |
10 | end | 10 | end |
11 | 11 | ||
12 | render json: data.to_json | 12 | render json: data.to_json |
13 | + | ||
14 | + data.to_json | ||
13 | end | 15 | end |
14 | end | 16 | end |
lib/ext/article.rb
lib/ext/community.rb
@@ -2,9 +2,22 @@ require_dependency "community" | @@ -2,9 +2,22 @@ require_dependency "community" | ||
2 | 2 | ||
3 | class Community | 3 | class Community |
4 | 4 | ||
5 | - def attr_to_json | 5 | + def attr_to_hash |
6 | attrs = super | 6 | attrs = super |
7 | 7 | ||
8 | + attrs["members-count"] = self.members.count | ||
9 | + attrs["members"] = [] | ||
10 | + | ||
11 | + self.members.each do |member| | ||
12 | + attrs_members = { | ||
13 | + "is_admin" => self.admins.include?(member), | ||
14 | + "id" => member.id, | ||
15 | + "identifier" => member.identifier, | ||
16 | + "name" => member.name | ||
17 | + } | ||
18 | + attrs['members'] << attrs_members | ||
19 | + end | ||
20 | + | ||
8 | if self.respond_to?("software?") && self.software? | 21 | if self.respond_to?("software?") && self.software? |
9 | attrs['software_data'] = { | 22 | attrs['software_data'] = { |
10 | "public_software" => self.software_info.public_software, | 23 | "public_software" => self.software_info.public_software, |
lib/ext/profile.rb
1 | require_dependency 'profile' | 1 | require_dependency 'profile' |
2 | 2 | ||
3 | class Profile | 3 | class Profile |
4 | - def attr_to_json | 4 | + def attr_to_hash |
5 | attrs = { | 5 | attrs = { |
6 | - "type" => "#{self.type}", | 6 | + "type" => self.type, |
7 | "data" => { | 7 | "data" => { |
8 | - "id" => "#{self.id}", | ||
9 | - "identifier" => "#{self.identifier}", | ||
10 | - "name" => "#{self.name}", | ||
11 | - "description" => "#{self.description}" | 8 | + "id" => self.id, |
9 | + "identifier" => self.identifier, | ||
10 | + "name" => self.name, | ||
11 | + "description" => self.description | ||
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | attrs['articles'] = [] | 15 | attrs['articles'] = [] |
16 | self.articles.each do |article| | 16 | self.articles.each do |article| |
17 | - attrs['articles'] << article.attr_to_json | 17 | + attrs['articles'] << article.attr_to_hash |
18 | end | 18 | end |
19 | 19 | ||
20 | attrs | 20 | attrs |