Commit 50fdcfa3328e324717a0cee5af01fe7625cd5796

Authored by Gabriela Navarro
1 parent 38750cc9
Exists in master

Add software info on the JSON.

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing 1 changed file with 38 additions and 0 deletions   Show diff stats
lib/ext/community.rb 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +require_dependency "community"
  2 +
  3 +class Community
  4 +
  5 + def attr_to_json
  6 + attrs = super
  7 +
  8 + if self.respond_to?("software?") && self.software?
  9 + attrs['software_data'] = {
  10 + "public_software" => self.software_info.public_software,
  11 + "acronym" => self.software_info.acronym,
  12 + "finality" => self.software_info.finality,
  13 + "repository_link" => self.software_info.repository_link,
  14 + "license_info" => {
  15 + "id" => self.software_info.license_info.id,
  16 + "version" => self.software_info.license_info.version,
  17 + "link" => self.software_info.license_info.link,
  18 + },
  19 + "categories" => []
  20 + }
  21 +
  22 + self.categories.each do |category|
  23 + if Category.last.parent.name == "Software"
  24 + category_info = {
  25 + "id" => category.id,
  26 + "name" => category.name,
  27 + "slug" => category.slug,
  28 + "path" => category.path
  29 + }
  30 +
  31 + attrs['software_data']["categories"] << category_info
  32 + end
  33 + end
  34 + end
  35 +
  36 + attrs
  37 + end
  38 +end
... ...