[noosfero/noosfero][master] stoa: avoid url_for if not available

Rodrigo Souto gitlab at gitlab.com
Thu Apr 2 13:18:53 BRT 2015


Rodrigo Souto pushed to master at Noosfero / noosfero


Commits:
48ce6083 by Rodrigo Souto at 2015-04-02T13:17:11Z
stoa: avoid url_for if not available

- - - - -


1 changed file:

- plugins/stoa/lib/stoa_plugin/person_api.rb


Changes:

=====================================
plugins/stoa/lib/stoa_plugin/person_api.rb
=====================================
--- a/plugins/stoa/lib/stoa_plugin/person_api.rb
+++ b/plugins/stoa/lib/stoa_plugin/person_api.rb
@@ -16,7 +16,7 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator
   end
 
   def homepage
-    context.url_for(url)
+    profile_homepage(context, object)
   end
 
   def birth_date
@@ -35,6 +35,16 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator
   end
 
   def communities
-    object.communities.public.map {|community| {:url => context.url_for(community.url), :name => community.name}}
+    object.communities.public.map {|community| {:url => profile_homepage(context, community), :name => community.name}}
+  end
+
+  private
+
+  def profile_homepage(context, profile)
+    if context.respond_to?(:url_for)
+      context.url_for(profile.url)
+    else
+      profile.environment.top_url + '/' + profile.identifier
+    end
   end
 end


View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/48ce60833263d5c578445f6ccc596e37c6442f64
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150402/c74b2dda/attachment.html>


More information about the Noosfero-dev mailing list