Commit a38702e32dbae17a65a2f5f17d4c169f6593ceee

Authored by Rodrigo Souto
2 parents 7635668e 10ab44f4

Merge branch 'ai2992' of https://gitlab.com/brauliobo/noosfero into brauliobo/noosfero-ai2992

app/controllers/my_profile/themes_controller.rb
@@ -14,7 +14,7 @@ class ThemesController < MyProfileController @@ -14,7 +14,7 @@ class ThemesController < MyProfileController
14 end 14 end
15 15
16 def index 16 def index
17 - @themes = profile.environment.themes + Theme.approved_themes(profile) 17 + @themes = (profile.environment.themes + Theme.approved_themes(profile)).uniq_by{ |t| t.id }.sort_by{ |t| t.name }
18 @current_theme = profile.theme 18 @current_theme = profile.theme
19 19
20 @layout_templates = LayoutTemplate.all 20 @layout_templates = LayoutTemplate.all
lib/noosfero/core_ext.rb
1 require 'noosfero/core_ext/string' 1 require 'noosfero/core_ext/string'
2 require 'noosfero/core_ext/integer' 2 require 'noosfero/core_ext/integer'
  3 +require 'noosfero/core_ext/array'
3 require 'noosfero/core_ext/object' 4 require 'noosfero/core_ext/object'
4 require 'noosfero/core_ext/active_record' 5 require 'noosfero/core_ext/active_record'
lib/noosfero/core_ext/array.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class Array
  2 +
  3 + def uniq_by
  4 + hash, array = {}, []
  5 + each { |i| hash[yield(i)] ||= (array << i) }
  6 + array
  7 + end
  8 +
  9 +end