Commit 94681b0ebcc863e80f9e2f26fe482d5fd823c1db
Committed by
Victor Costa
1 parent
344ed16e
Exists in
staging
and in
4 other branches
stoa: avoid url_for if not available
Showing
1 changed file
with
12 additions
and
2 deletions
Show diff stats
plugins/stoa/lib/stoa_plugin/person_api.rb
| ... | ... | @@ -16,7 +16,7 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | 18 | def homepage |
| 19 | - context.url_for(url) | |
| 19 | + profile_homepage(context, object) | |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | 22 | def birth_date |
| ... | ... | @@ -35,6 +35,16 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def communities |
| 38 | - object.communities.public.map {|community| {:url => context.url_for(community.url), :name => community.name}} | |
| 38 | + object.communities.public.map {|community| {:url => profile_homepage(context, community), :name => community.name}} | |
| 39 | + end | |
| 40 | + | |
| 41 | + private | |
| 42 | + | |
| 43 | + def profile_homepage(context, profile) | |
| 44 | + if context.respond_to?(:url_for) | |
| 45 | + context.url_for(profile.url) | |
| 46 | + else | |
| 47 | + profile.environment.top_url + '/' + profile.identifier | |
| 48 | + end | |
| 39 | 49 | end |
| 40 | 50 | end | ... | ... |