Commit d6e63a774e18f40ca70538ea62f7a20d5f919155
1 parent
305736e5
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
dspace_plugin : return to previous page if unable to contact dspace rest api
Showing
1 changed file
with
31 additions
and
0 deletions
Show diff stats
plugins/dspace/lib/dspace_plugin.rb
@@ -33,4 +33,35 @@ class DspacePlugin < Noosfero::Plugin | @@ -33,4 +33,35 @@ class DspacePlugin < Noosfero::Plugin | ||
33 | false | 33 | false |
34 | end | 34 | end |
35 | 35 | ||
36 | + def cms_controller_filters | ||
37 | + block = proc do | ||
38 | + | ||
39 | + dspace_content_type = params[:type] | ||
40 | + | ||
41 | + case dspace_content_type | ||
42 | + | ||
43 | + when 'DspacePlugin::Communityy' | ||
44 | + parent = DspacePlugin::Library.find_by_id(params[:parent_id]) | ||
45 | + children = Dspace::Community.get_all_communities_from parent.dspace_server_url | ||
46 | + | ||
47 | + when 'DspacePlugin::Collection' | ||
48 | + parent = DspacePlugin::Communityy.find_by_id(params[:parent_id]) | ||
49 | + children = Dspace::Collection.get_all_collections_from parent.parent.dspace_server_url | ||
50 | + | ||
51 | + end | ||
52 | + | ||
53 | + if dspace_content_type == 'DspacePlugin::Communityy' || dspace_content_type == 'DspacePlugin::Collection' | ||
54 | + if children.nil? | ||
55 | + session[:notice] = _('Unable to contact DSpace server') | ||
56 | + redirect_to parent.view_url | ||
57 | + end | ||
58 | + end | ||
59 | + | ||
60 | + end | ||
61 | + | ||
62 | + { :type => 'before_filter', | ||
63 | + :method_name => 'new', | ||
64 | + :block => block } | ||
65 | + end | ||
66 | + | ||
36 | end | 67 | end |