diff --git a/controllers/colab_integration_plugin_controller.rb b/controllers/colab_integration_plugin_controller.rb index 976bfb4..4da18f1 100644 --- a/controllers/colab_integration_plugin_controller.rb +++ b/controllers/colab_integration_plugin_controller.rb @@ -6,9 +6,11 @@ class ColabIntegrationPluginController < ApplicationController } environment.profiles.each do |profile| - data["profiles"] << profile.attr_to_json + data["profiles"] << profile.attr_to_hash end render json: data.to_json + + data.to_json end end diff --git a/lib/ext/article.rb b/lib/ext/article.rb index a2c2665..ffa2068 100644 --- a/lib/ext/article.rb +++ b/lib/ext/article.rb @@ -1,7 +1,7 @@ require_dependency "article" class Article - def attr_to_json + def attr_to_hash { "type" => self.type, "data" => { diff --git a/lib/ext/community.rb b/lib/ext/community.rb index 3d1ce7c..b6e3392 100644 --- a/lib/ext/community.rb +++ b/lib/ext/community.rb @@ -2,9 +2,22 @@ require_dependency "community" class Community - def attr_to_json + def attr_to_hash attrs = super + attrs["members-count"] = self.members.count + attrs["members"] = [] + + self.members.each do |member| + attrs_members = { + "is_admin" => self.admins.include?(member), + "id" => member.id, + "identifier" => member.identifier, + "name" => member.name + } + attrs['members'] << attrs_members + end + if self.respond_to?("software?") && self.software? attrs['software_data'] = { "public_software" => self.software_info.public_software, diff --git a/lib/ext/profile.rb b/lib/ext/profile.rb index 6120644..77a1264 100644 --- a/lib/ext/profile.rb +++ b/lib/ext/profile.rb @@ -1,20 +1,20 @@ require_dependency 'profile' class Profile - def attr_to_json + def attr_to_hash attrs = { - "type" => "#{self.type}", + "type" => self.type, "data" => { - "id" => "#{self.id}", - "identifier" => "#{self.identifier}", - "name" => "#{self.name}", - "description" => "#{self.description}" + "id" => self.id, + "identifier" => self.identifier, + "name" => self.name, + "description" => self.description } } attrs['articles'] = [] self.articles.each do |article| - attrs['articles'] << article.attr_to_json + attrs['articles'] << article.attr_to_hash end attrs -- libgit2 0.21.2