Commit e42003f520c18c8fa0e46a834ceb106ffb942e0c
Committed by
Tallys Martins
1 parent
17c8b3be
Exists in
master
and in
29 other branches
Updated cms upload method on work_assignmet plugin.
Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
2 changed files
with
20 additions
and
14 deletions
Show diff stats
plugins/work_assignment/controllers/myprofile/work_assignment_plugin_cms_controller.rb
| 1 | 1 | class WorkAssignmentPluginCmsController < CmsController |
| 2 | 2 | |
| 3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
| 4 | - | |
| 4 | + | |
| 5 | 5 | def upload_files |
| 6 | 6 | @uploaded_files = [] |
| 7 | 7 | @article = @parent = check_parent(params[:parent_id]) |
| 8 | 8 | @email_notification = params[:article_email_notification] |
| 9 | - | |
| 9 | + | |
| 10 | 10 | @target = @parent ? ('/%s/%s' % [profile.identifier, @parent.full_name]) : '/%s' % profile.identifier |
| 11 | 11 | if @article |
| 12 | 12 | record_coming |
| 13 | 13 | end |
| 14 | 14 | if request.post? && params[:uploaded_files] |
| 15 | 15 | params[:uploaded_files].each do |file| |
| 16 | - if file != '' | |
| 17 | - u = UploadedFile.new(:uploaded_data => file, :profile => profile, :parent => @parent) | |
| 18 | - u.last_changed_by = user | |
| 19 | - u.save! | |
| 20 | - @uploaded_files << u | |
| 21 | - end | |
| 22 | - end | |
| 16 | + unless file == '' | |
| 17 | + @uploaded_files << UploadedFile.create( | |
| 18 | + { | |
| 19 | + :uploaded_data => file, | |
| 20 | + :profile => profile, | |
| 21 | + :parent => @parent, | |
| 22 | + :last_changed_by => user, | |
| 23 | + :author => user, | |
| 24 | + }, | |
| 25 | + :without_protection => true | |
| 26 | + ) | |
| 27 | + end | |
| 28 | + end | |
| 23 | 29 | @errors = @uploaded_files.select { |f| f.errors.any? } |
| 24 | 30 | if @errors.any? |
| 25 | 31 | render :action => 'upload_files', :id => @parent_id |
| ... | ... | @@ -48,7 +54,7 @@ class WorkAssignmentPluginCmsController < CmsController |
| 48 | 54 | @files_paths = [] |
| 49 | 55 | @files_string = params[:self_files_id] |
| 50 | 56 | @files_id_list = @files_string.split(' ') |
| 51 | - | |
| 57 | + | |
| 52 | 58 | @files_id_list.each do |file_id| |
| 53 | 59 | @file = environment.articles.find_by_id(file_id) |
| 54 | 60 | @real_file_url = "http://#{@file.url[:host]}:#{@file.url[:port]}/#{@file.url[:profile]}/#{@file.path}" |
| ... | ... | @@ -100,7 +106,7 @@ class WorkAssignmentPluginCmsController < CmsController |
| 100 | 106 | @files_paths = [] |
| 101 | 107 | @files_string = params[:self_files_id] |
| 102 | 108 | @files_id_list = @files_string.split(' ') |
| 103 | - | |
| 109 | + | |
| 104 | 110 | @files_id_list.each do |file_id| |
| 105 | 111 | @file = environment.articles.find_by_id(file_id) |
| 106 | 112 | @real_file_url = "http://#{@file.url[:host]}:#{@file.url[:port]}/#{@file.url[:profile]}/#{@file.path}" | ... | ... |
plugins/work_assignment/lib/work_assignment_plugin.rb
| ... | ... | @@ -37,7 +37,7 @@ class WorkAssignmentPlugin < Noosfero::Plugin |
| 37 | 37 | |
| 38 | 38 | def content_viewer_controller_filters |
| 39 | 39 | block = proc do |
| 40 | - path = params[:page].join('/') | |
| 40 | + path = params[:page] | |
| 41 | 41 | content = profile.articles.find_by_path(path) |
| 42 | 42 | |
| 43 | 43 | if WorkAssignmentPlugin.is_submission?(content) && !WorkAssignmentPlugin.can_download_submission?(user, content) |
| ... | ... | @@ -51,7 +51,7 @@ class WorkAssignmentPlugin < Noosfero::Plugin |
| 51 | 51 | :block => block } |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | - | |
| 54 | + | |
| 55 | 55 | def upload_files_extra_contents |
| 56 | 56 | proc do |
| 57 | 57 | if params[:parent_id] |
| ... | ... | @@ -60,7 +60,7 @@ class WorkAssignmentPlugin < Noosfero::Plugin |
| 60 | 60 | content = profile.articles.find_by_path(path) |
| 61 | 61 | |
| 62 | 62 | if content.type == "WorkAssignmentPlugin::WorkAssignment" |
| 63 | - render :partial => 'work_assignment_form', :locals => { :size => '45'} | |
| 63 | + render :partial => 'work_assignment_form', :locals => { :size => '45'} | |
| 64 | 64 | end |
| 65 | 65 | else |
| 66 | 66 | render :partial => 'upload_file_form', :locals => { :size => '45'} | ... | ... |