Commit 48ce60833263d5c578445f6ccc596e37c6442f64
1 parent
61a8e873
Exists in
master
and in
29 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 | ... | ... |