Commit a18ff65ca5322200d40bd54fe9b95b99cd8a116b
1 parent
fa516d36
Exists in
master
and in
28 other branches
ActionItem806: add button to config blog in control panel
Showing
10 changed files
with
58 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| @@ -61,6 +61,9 @@ class CmsController < MyProfileController | @@ -61,6 +61,9 @@ class CmsController < MyProfileController | ||
| 61 | @article = profile.articles.find(params[:id]) | 61 | @article = profile.articles.find(params[:id]) |
| 62 | @parent_id = params[:parent_id] | 62 | @parent_id = params[:parent_id] |
| 63 | @type = params[:type] | 63 | @type = params[:type] |
| 64 | + if !@article.nil? && @article.blog? || !@type.nil? && @type == 'Blog' | ||
| 65 | + @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier) | ||
| 66 | + end | ||
| 64 | record_coming_from_public_view | 67 | record_coming_from_public_view |
| 65 | if request.post? | 68 | if request.post? |
| 66 | @article.last_changed_by = user | 69 | @article.last_changed_by = user |
| @@ -89,6 +92,10 @@ class CmsController < MyProfileController | @@ -89,6 +92,10 @@ class CmsController < MyProfileController | ||
| 89 | @parent_id = params[:parent_id] | 92 | @parent_id = params[:parent_id] |
| 90 | render :action => 'select_article_type', :layout => false | 93 | render :action => 'select_article_type', :layout => false |
| 91 | return | 94 | return |
| 95 | + else | ||
| 96 | + if @type == 'Blog' | ||
| 97 | + @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier) | ||
| 98 | + end | ||
| 92 | end | 99 | end |
| 93 | 100 | ||
| 94 | raise "Invalid article type #{@type}" unless valid_article_type?(@type) | 101 | raise "Invalid article type #{@type}" unless valid_article_type?(@type) |
| @@ -175,7 +182,9 @@ class CmsController < MyProfileController | @@ -175,7 +182,9 @@ class CmsController < MyProfileController | ||
| 175 | protected | 182 | protected |
| 176 | 183 | ||
| 177 | def redirect_back | 184 | def redirect_back |
| 178 | - if params[:back_to] == 'public_view' | 185 | + if params[:back_to] == 'control_panel' |
| 186 | + redirect_to :controller => 'profile_editor', :profile => @profile.identifier | ||
| 187 | + elsif params[:back_to] == 'public_view' | ||
| 179 | redirect_to @article.url | 188 | redirect_to @article.url |
| 180 | elsif @article.parent | 189 | elsif @article.parent |
| 181 | redirect_to :action => 'view', :id => @article.parent | 190 | redirect_to :action => 'view', :id => @article.parent |
app/views/cms/_blog.rhtml
| @@ -15,3 +15,5 @@ | @@ -15,3 +15,5 @@ | ||
| 15 | <%= labelled_form_field(_('Use as description in RSS Feed:'), feed.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> | 15 | <%= labelled_form_field(_('Use as description in RSS Feed:'), feed.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> |
| 16 | 16 | ||
| 17 | <% end %> | 17 | <% end %> |
| 18 | + | ||
| 19 | +<%= javascript_tag "$('back_to').value = 'control_panel'" %> |
app/views/content_viewer/view_page.rhtml
| @@ -30,11 +30,13 @@ | @@ -30,11 +30,13 @@ | ||
| 30 | if ( act ) act.className = ( show ? "show" : "hidden" ); | 30 | if ( act ) act.className = ( show ? "show" : "hidden" ); |
| 31 | } | 31 | } |
| 32 | </script> | 32 | </script> |
| 33 | - <% if logged_in? && current_user.person.has_permission?('post_content', profile) %> | 33 | + <% if logged_in? && current_user.person.has_permission?('post_content', profile) %> |
| 34 | <div id="article-actions" class="hidden"> | 34 | <div id="article-actions" class="hidden"> |
| 35 | + <% unless @page.blog? %> | ||
| 35 | <%= link_to content_tag( 'span', label_for_edit_article(@page) ), | 36 | <%= link_to content_tag( 'span', label_for_edit_article(@page) ), |
| 36 | { :controller => 'cms', :action => 'edit', :id => @page }, | 37 | { :controller => 'cms', :action => 'edit', :id => @page }, |
| 37 | :class => 'button with-text icon-edit' %> | 38 | :class => 'button with-text icon-edit' %> |
| 39 | + <% end %> | ||
| 38 | <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %> | 40 | <% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %> |
| 39 | <% if @page != profile.home_page %> | 41 | <% if @page != profile.home_page %> |
| 40 | <%= link_to content_tag( 'span', _('Delete') ), | 42 | <%= link_to content_tag( 'span', _('Delete') ), |
app/views/profile_editor/index.rhtml
| @@ -25,6 +25,12 @@ | @@ -25,6 +25,12 @@ | ||
| 25 | 25 | ||
| 26 | <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') unless environment.enabled?('disable_cms') || profile.community? %> | 26 | <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') unless environment.enabled?('disable_cms') || profile.community? %> |
| 27 | 27 | ||
| 28 | + <% if profile.has_blog? %> | ||
| 29 | + <%= file_manager_button(_('Config my blog'), 'icons-app/blog.png', :controller => 'cms', :action => 'edit', :id => profile.blog) %> | ||
| 30 | + <% else %> | ||
| 31 | + <%= file_manager_button(_('Create my blog'), 'icons-app/blog-disabled.png', :controller => 'cms', :action => 'new', :type => 'Blog') %> | ||
| 32 | + <% end %> | ||
| 33 | + | ||
| 28 | <%= file_manager_button(_('Change Password'), 'icons-app/change-password.png', :controller => 'account', :action => 'change_password') if profile.person? %> | 34 | <%= file_manager_button(_('Change Password'), 'icons-app/change-password.png', :controller => 'account', :action => 'change_password') if profile.person? %> |
| 29 | 35 | ||
| 30 | <%= file_manager_button(__('Manage friends'), 'icons-app/friends.png', :controller => 'friends', :action => 'index') if profile.person? %> | 36 | <%= file_manager_button(__('Manage friends'), 'icons-app/friends.png', :controller => 'friends', :action => 'index') if profile.person? %> |
public/images/icons-app/README
| @@ -45,6 +45,7 @@ gtk-cancel.png dlg-neu | @@ -45,6 +45,7 @@ gtk-cancel.png dlg-neu | ||
| 45 | emblem-important.png dlg-neu | 45 | emblem-important.png dlg-neu |
| 46 | gnome-globe.png gnome | 46 | gnome-globe.png gnome |
| 47 | header-and-footer.svg Noosfero team | 47 | header-and-footer.svg Noosfero team |
| 48 | +livejournal.png dlg-neu | ||
| 48 | ### END OF ICONS LISTING ### | 49 | ### END OF ICONS LISTING ### |
| 49 | 50 | ||
| 50 | Icons rasterization | 51 | Icons rasterization |
1.85 KB
3.09 KB
test/functional/cms_controller_test.rb
| @@ -758,4 +758,28 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -758,4 +758,28 @@ class CmsControllerTest < Test::Unit::TestCase | ||
| 758 | assert :tag => 'input', :attributes => {:name => 'article[notify_comments]', :value => 1} | 758 | assert :tag => 'input', :attributes => {:name => 'article[notify_comments]', :value => 1} |
| 759 | end | 759 | end |
| 760 | 760 | ||
| 761 | + should 'back to control panel after create blog' do | ||
| 762 | + assert_difference Blog, :count do | ||
| 763 | + post :new, :type => Blog.name, :profile => profile.identifier, :article => { :name => 'my-blog' }, :back_to => 'control_panel' | ||
| 764 | + assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier | ||
| 765 | + end | ||
| 766 | + end | ||
| 767 | + | ||
| 768 | + should 'back to control panel after config blog' do | ||
| 769 | + profile.articles << Blog.new(:name => 'my-blog', :profile => profile) | ||
| 770 | + post :edit, :profile => profile.identifier, :id => profile.blog.id, :back_to => 'control_panel' | ||
| 771 | + assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier | ||
| 772 | + end | ||
| 773 | + | ||
| 774 | + should 'back to control panel if cancel create blog' do | ||
| 775 | + get :new, :profile => profile.identifier, :type => Blog.name | ||
| 776 | + assert_tag :tag => 'a', :content => 'Cancel', :attributes => { :href => /\/myprofile\/#{profile.identifier}/ } | ||
| 777 | + end | ||
| 778 | + | ||
| 779 | + should 'back to control panel if cancel config blog' do | ||
| 780 | + profile.articles << Blog.new(:name => 'my-blog', :profile => profile) | ||
| 781 | + get :edit, :profile => profile.identifier, :id => profile.blog.id | ||
| 782 | + assert_tag :tag => 'a', :content => 'Cancel', :attributes => { :href => /\/myprofile\/#{profile.identifier}/ } | ||
| 783 | + end | ||
| 784 | + | ||
| 761 | end | 785 | end |
test/functional/profile_editor_controller_test.rb
| @@ -622,4 +622,15 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -622,4 +622,15 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
| 622 | assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/default_user/cms' } | 622 | assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/default_user/cms' } |
| 623 | end | 623 | end |
| 624 | 624 | ||
| 625 | + should 'offer to create blog in control panel' do | ||
| 626 | + get :index, :profile => 'default_user' | ||
| 627 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/cms/new?type=Blog" } | ||
| 628 | + end | ||
| 629 | + | ||
| 630 | + should 'offer to config blog in control panel' do | ||
| 631 | + profile.articles << Blog.new(:name => 'My blog', :profile => profile) | ||
| 632 | + get :index, :profile => 'default_user' | ||
| 633 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/cms/edit/#{profile.blog.id}" } | ||
| 634 | + end | ||
| 635 | + | ||
| 625 | end | 636 | end |