diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index b641e84..838226b 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -212,6 +212,8 @@ class CmsController < MyProfileController if @errors.any? render :action => 'upload_files', :parent_id => @parent_id else + session[:notice] = _('File(s) successfully uploaded') + @plugins.dispatch(:check_extra_parameters, @upload_files, params).collect { |content| instance_exec(&content) } if @back_to redirect_to @back_to elsif @parent diff --git a/app/views/cms/upload_files.html.erb b/app/views/cms/upload_files.html.erb index 43bf141..18afa20 100644 --- a/app/views/cms/upload_files.html.erb +++ b/app/views/cms/upload_files.html.erb @@ -19,15 +19,11 @@
<%= _('Uploading files to %s') % content_tag('code', @target) %>
-<% if @plugins.dispatch(:upload_files_extra_contents).size == 0 %> - <%= form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> +<%= form_for('uploaded_file', :url => {:action => 'upload_files' }, :html => {:multipart => true}) do |f| %> - <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %> - - <% end %> -<% else %> + <%= @plugins.dispatch(:article_extra_contents, params[:parent_id]).collect { |content| instance_exec(&content) }.join("") %> - <%= @plugins.dispatch(:upload_files_extra_contents).collect { |content| instance_eval(&content) }.join("") %> + <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %> -<% end %> +<% end %> diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 6d44a2d..87b0ce0 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -529,6 +529,12 @@ class Noosfero::Plugin params end + # -> Checks adicional parameters passed through html + # by the work_assignment plugin + def check_extra_parameters(uploaded_files, params = {}) + nil + end + # -> Finds objects by their contents # returns = {:results => [a, b, c, ...], ...} # P.S.: The plugin might add other informations on the return hash for its diff --git a/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb b/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb index 90cf980..58ae738 100644 --- a/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb +++ b/plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb @@ -2,49 +2,6 @@ class WorkAssignmentPluginCmsController < CmsController append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def upload_files - @uploaded_files = [] - @article = @parent = check_parent(params[:parent_id]) - @email_notification = params[:article_email_notification] - - @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier - if @article - record_coming - end - if request.post? && params[:uploaded_files] - params[:uploaded_files].each do |file| - unless file == '' - @uploaded_files << UploadedFile.create( - { - :uploaded_data => file, - :profile => profile, - :parent => @parent, - :last_changed_by => user, - :author => user, - }, - :without_protection => true - ) - end - end - @errors = @uploaded_files.select { |f| f.errors.any? } - if @errors.any? - render :action => 'upload_files', :id => @parent_id - else - if @back_to - if @email_notification == 'true' - redirect_to :controller => 'work_assignment_plugin_cms', :action => 'send_email', :id => @parent.id, :files_id => @uploaded_files, :confirm => true - else - redirect_to @back_to - end - elsif @parent - redirect_to :controller => 'cms', :action => 'view', :id => @parent.id - else - redirect_to :controller => 'cms', :action => 'index' - end - end - end - end - def send_email @parent = check_parent(params[:id]) @files_id_list = params[:files_id] diff --git a/plugins/work_assignment/lib/ext/email_contact.rb b/plugins/work_assignment/lib/ext/email_contact.rb index ea4751f..096ed93 100644 --- a/plugins/work_assignment/lib/ext/email_contact.rb +++ b/plugins/work_assignment/lib/ext/email_contact.rb @@ -29,6 +29,7 @@ class EmailContact end class EmailSender < ActionMailer::Base + def notification(email_contact) @name = email_contact.name @email = email_contact.email @@ -40,16 +41,12 @@ class EmailContact to: email_contact.reciever, reply_to: email_contact.email, subject: email_contact.subject, - message: email_contact.message, + body: email_contact.message, from: "#{email_contact.name} <#{email_contact.email}>" } - if email_contact.sender - options.merge!('X-Noosfero-Sender' => email_contact.sender.identifier) - end - - if email_contact.receive_a_copy - options.merge!(cc: "#{email_contact.name} <#{email_contact.email}>") + if email_contact.receive_a_copy == "1" + options.merge!(cc: "#{email_contact.email}") end mail(options) diff --git a/plugins/work_assignment/lib/work_assignment_plugin.rb b/plugins/work_assignment/lib/work_assignment_plugin.rb index cf4bdef..94c1274 100644 --- a/plugins/work_assignment/lib/work_assignment_plugin.rb +++ b/plugins/work_assignment/lib/work_assignment_plugin.rb @@ -52,20 +52,24 @@ class WorkAssignmentPlugin < Noosfero::Plugin end - def upload_files_extra_contents + def article_extra_contents(article_id) proc do - if params[:parent_id] - parent_id = params[:parent_id] - path = Article.find_by_id(parent_id).path.split("/")[0] - content = profile.articles.find_by_path(path) + @article = Article.find_by_id(article_id) + if params[:parent_id] && !@article.nil? && @article.type == "WorkAssignmentPlugin::WorkAssignment" + render :partial => 'notify_checkbox', :locals => { :size => '45'} + end + end + end - if content.type == "WorkAssignmentPlugin::WorkAssignment" - render :partial => 'work_assignment_form', :locals => { :size => '45'} - end - else - render :partial => 'upload_file_form', :locals => { :size => '45'} + def check_extra_parameters (uploaded_files, params = {}) + @email_notification = params[:article_email_notification] + # uploaded_files = params[:uploaded_files] + id = params[:parent_id] + if @email_notification == 'true' + proc do + @back_to = url_for :controller => 'work_assignment_plugin_cms', :action => 'send_email', :id => id, :files_id => uploaded_files, :confirm => true end end end -end +end \ No newline at end of file diff --git a/plugins/work_assignment/public/show_notification_email.js b/plugins/work_assignment/public/show_notification_email.js deleted file mode 100644 index d3e08e9..0000000 --- a/plugins/work_assignment/public/show_notification_email.js +++ /dev/null @@ -1,12 +0,0 @@ -jQuery(function($) { - function show_hide_token_input() { - if($('input:checkbox[name="article_email_notification"]').attr('checked')){ - $("#email_notifications").css('display', 'inline-block');} - else - $("#email_notifications").css('display', 'none'); - } - - show_hide_token_input(); - //Hide / Show the text area - $("#checkbox-0").click(show_hide_token_input); -}); \ No newline at end of file diff --git a/plugins/work_assignment/public/style.css b/plugins/work_assignment/public/style.css index d374683..4046fbf 100644 --- a/plugins/work_assignment/public/style.css +++ b/plugins/work_assignment/public/style.css @@ -1,26 +1,2 @@ .icon-newwork-assignment { background-image: url(../../designs/icons/tango/Tango/16x16/categories/applications-office.png) } -.icon-work-assignment { background-image: url(../../designs/icons/tango/Tango/16x16/categories/applications-office.png) } - -#email_notifications{ - padding: 10px 20px; - display: inline-block; -} - -#email_notifications label{ - width: 117px; - display: block; - float: left; -} - -#email_notifications input, #email_notifications textarea{ - display: block; - float: left; - resize: vertical; - width: 330px; - line-height: 1.5em; -} - -body.action-cms-upload_files #uploaded_files p:nth-child(3), -body.action-cms-upload_files #uploaded_files p:nth-child(5){ - display: none; - } +.icon-work-assignment { background-image: url(../../designs/icons/tango/Tango/16x16/categories/applications-office.png) } \ No newline at end of file diff --git a/plugins/work_assignment/views/cms/_notify_checkbox.html.erb b/plugins/work_assignment/views/cms/_notify_checkbox.html.erb index 4a43f03..40b5712 100644 --- a/plugins/work_assignment/views/cms/_notify_checkbox.html.erb +++ b/plugins/work_assignment/views/cms/_notify_checkbox.html.erb @@ -1,7 +1 @@ -<%= javascript_include_tag '../plugins/work_assignment/show_notification_email' %> -<%= labelled_check_box(_('Send notification'), 'article_email_notification', true) %> - -
- - -
+<%= labelled_check_box(_('Send notification'), 'article_email_notification', true) %> \ No newline at end of file diff --git a/plugins/work_assignment/views/cms/_work_assignment_form.html.erb b/plugins/work_assignment/views/cms/_work_assignment_form.html.erb deleted file mode 100644 index 74bf228..0000000 --- a/plugins/work_assignment/views/cms/_work_assignment_form.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= form_for('uploaded_file', :url => { :controller => 'work_assignment_plugin_cms', :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> - <%= render :partial => 'notify_checkbox', :locals => { :size => '45'} %> - <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %> -<% end %> \ No newline at end of file diff --git a/plugins/work_assignment/views/cms/work_assignment_plugin/_work_assignment.html.erb b/plugins/work_assignment/views/cms/work_assignment_plugin/_work_assignment.html.erb index 01f2355..77b9549 100644 --- a/plugins/work_assignment/views/cms/work_assignment_plugin/_work_assignment.html.erb +++ b/plugins/work_assignment/views/cms/work_assignment_plugin/_work_assignment.html.erb @@ -1,3 +1,2 @@ <%= render :partial => 'folder', :locals => {:f => f} %> - <%=labelled_check_box(_('Publish submissions'), 'article[publish_submissions]', true, @article.publish_submissions) %> diff --git a/plugins/work_assignment/views/work_assignment_plugin_cms/_work_assignment_form.html.erb b/plugins/work_assignment/views/work_assignment_plugin_cms/_work_assignment_form.html.erb deleted file mode 100644 index 872e317..0000000 --- a/plugins/work_assignment/views/work_assignment_plugin_cms/_work_assignment_form.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% form_for('uploaded_file', :url => { :controller => 'work_assignment_plugin_cms', :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> - <%= render :partial => 'notify_checkbox', :locals => { :size => '45'} %> - <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %> - -<% end %> \ No newline at end of file diff --git a/plugins/work_assignment/views/work_assignment_plugin_cms/send_email.html.erb b/plugins/work_assignment/views/work_assignment_plugin_cms/send_email.html.erb index d4ef2ee..8c64ac5 100644 --- a/plugins/work_assignment/views/work_assignment_plugin_cms/send_email.html.erb +++ b/plugins/work_assignment/views/work_assignment_plugin_cms/send_email.html.erb @@ -14,7 +14,7 @@ <%= render :file => 'shared/tiny_mce' %> <%= required f.text_area(:message, :class => 'mceEditor') %> - <%= labelled_form_field check_box(:email_contact, :receive_a_copy) + _('I want to receive a copy of the message in my e-mail.'), '' %> +<%= labelled_form_field check_box(:email_contact, :receive_a_copy) + _('I want to receive a copy of the message in my e-mail.'), '' %> <%= submit_button(:send, _('Send'), :onclick => "$('confirm').value = 'true'") %> <%= submit_button(:cancel, _('Cancel'), :onclick =>"$('confirm').value = 'false'") %> -- libgit2 0.21.2