Commit 7aab108a3f977b17a595fb8eb91316a4efa353c6
1 parent
dfed6005
Exists in
master
and in
21 other branches
Refactoring work assignment plugin
Changed privacy edition box to open on a new page.
Fixed cancel buttom to redirect to back page.
Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Signed-off-by: Álvaro Fernando <alvarofernandoms@gmail.com>
Signed-off-by: Eduardo Vital <vitaldu@gmail.com>
Showing
4 changed files
with
23 additions
and
21 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -34,8 +34,7 @@ class CmsController < MyProfileController |
| 34 | 34 | false |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | - action_list = [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files, :new] | |
| 38 | - protect_if :except => action_list do |c, user, profile| | |
| 37 | + protect_if :except => [:suggest_an_article, :set_home_page, :edit, :destroy, :publish, :upload_files, :new] do |c, user, profile| | |
| 39 | 38 | add_as_exception?(c.action_name) || user && (user.has_permission?('post_content', profile) || user.has_permission?('publish_content', profile)) |
| 40 | 39 | end |
| 41 | 40 | ... | ... |
plugins/work_assignment/lib/ext/cms_controller.rb
| ... | ... | @@ -8,19 +8,21 @@ protect_if :only => :edit_visibility do |c,user,profile| |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | def edit_visibility |
| 11 | - @folder = profile.articles.find(params[:article_id]) | |
| 12 | - @back_to = url_for(@folder.parent.url) | |
| 13 | - if request.post? | |
| 14 | - @folder.published = params[:article][:published] | |
| 15 | - unless params[:q].nil? | |
| 16 | - @folder.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
| 17 | - @folder.children.each do |c| | |
| 18 | - c.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
| 19 | - c.save! | |
| 11 | + unless params[:article_id].blank? | |
| 12 | + @folder = profile.articles.find(params[:article_id]) | |
| 13 | + @back_to = url_for(@folder.parent.url) | |
| 14 | + unless params[:article].blank? | |
| 15 | + @folder.published = params[:article][:published] | |
| 16 | + unless params[:q].nil? | |
| 17 | + @folder.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
| 18 | + @folder.children.each do |c| | |
| 19 | + c.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} | |
| 20 | + c.save! | |
| 21 | + end | |
| 20 | 22 | end |
| 23 | + @folder.save! | |
| 24 | + redirect_to @back_to | |
| 21 | 25 | end |
| 22 | - @folder.save! | |
| 23 | - redirect_to @back_to | |
| 24 | 26 | end |
| 25 | 27 | end |
| 26 | 28 | ... | ... |
plugins/work_assignment/lib/work_assignment_plugin/helper.rb
| ... | ... | @@ -68,7 +68,7 @@ module WorkAssignmentPlugin::Helper |
| 68 | 68 | |
| 69 | 69 | def display_delete_button(article) |
| 70 | 70 | expirable_button article, :delete, _('Delete'), |
| 71 | - {:controller =>'cms', :action => 'destroy', :id => article.id }, | |
| 71 | + {:controller =>'cms', :action => 'destroy', :id => article.id }, | |
| 72 | 72 | :method => :post, :confirm => delete_article_message(article) |
| 73 | 73 | end |
| 74 | 74 | |
| ... | ... | @@ -76,15 +76,17 @@ module WorkAssignmentPlugin::Helper |
| 76 | 76 | if author_folder |
| 77 | 77 | @folder = environment.articles.find_by_id(author_folder.id) |
| 78 | 78 | work_assignment = @folder.parent |
| 79 | + @back_to = url_for(@folder.parent.url) | |
| 80 | + if(user && work_assignment.allow_privacy_edition && | |
| 81 | + (author_folder.author_id == user.id || user.has_permission?('view_private_content', work_assignment.profile))) | |
| 79 | 82 | |
| 80 | - if(user && work_assignment.allow_privacy_edition && (author_folder.author_id == user.id || user.has_permission?('view_private_content', work_assignment.profile))) | |
| 81 | 83 | @tokenized_children = prepare_to_token_input( |
| 82 | 84 | profile.members.includes(:articles_with_access).find_all{ |m| |
| 83 | 85 | m.articles_with_access.include?(@folder) |
| 84 | - } | |
| 85 | - ) | |
| 86 | - colorbox_button :edit, _('Edit'), { :controller => 'cms', | |
| 87 | - :action => 'edit_visibility', :article_id => @folder.id, :tokenized_children => @tokenized_children} | |
| 86 | + }) | |
| 87 | + button :edit, _('Edit'), { :controller => 'cms', | |
| 88 | + :action => 'edit_visibility', :article_id => @folder.id, | |
| 89 | + :tokenized_children => @tokenized_children, :back_to => @back_to}, :method => :post | |
| 88 | 90 | end |
| 89 | 91 | end |
| 90 | 92 | end | ... | ... |
plugins/work_assignment/views/cms/edit_visibility.html.erb
| 1 | -<!-- <div class='<%= (environment.enabled?('media_panel') ? 'with_media_panel' : 'no_media_panel') %>'> --> | |
| 2 | 1 | <div class="select-privacy-options"> |
| 3 | 2 | <%= labelled_form_for 'article', :html => { :multipart => true, :class => @type } do |f| %> |
| 4 | 3 | |
| ... | ... | @@ -14,7 +13,7 @@ |
| 14 | 13 | |
| 15 | 14 | <% button_bar do %> |
| 16 | 15 | <%= submit_button :save, _('Save') %> |
| 17 | - <%= colorbox_close_button(_('Cancel')) %> | |
| 16 | + <%= button :cancel, _('Cancel'), @back_to %> | |
| 18 | 17 | <% end %> |
| 19 | 18 | <% end %> |
| 20 | 19 | </div> | ... | ... |