diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 03b626f7d..46fc68184 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -238,6 +238,8 @@ class ApplicationController < ActionController::Base allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) elsif @course allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global) + else + allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) end if allowed diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 99160b0c0..0b05f91d1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -124,10 +124,19 @@ class AttachmentsController < ApplicationController end respond_to do |format| - if @project.nil? - format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum,@attachment.container) } + # modify by nwb + if @attachment.container_type == 'Course' + if @course.nil? + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } + else + format.html { redirect_to_referer_or course_path(@course) } + end else - format.html { redirect_to_referer_or project_path(@project)} + if @project.nil? + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } + else + format.html { redirect_to_referer_or project_path(@project) } + end end format.js @@ -190,9 +199,14 @@ private def find_project @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong + # modify by nwb raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' - @project = @attachment.project + if @attachment.container_type == 'Course' + @course = @attachment.course + else + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' + @project = @attachment.project + end end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 71676467a..d9ad3915e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -193,6 +193,10 @@ class Attachment < ActiveRecord::Base container.try(:project) end + def course + container + end + def visible?(user=User.current) if container_id container && container.attachments_visible?(user) diff --git a/app/views/files/_course_new.html.erb b/app/views/files/_course_new.html.erb index 659543201..960b2d399 100644 --- a/app/views/files/_course_new.html.erb +++ b/app/views/files/_course_new.html.erb @@ -1,7 +1,7 @@

<%=l(:label_attachment_new)%>

<% attachmenttypes = course.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(course_files_path(course), :multipart => true,:remote => false,:method => :post,:name=>"upload_form", :class => "tabular") do %> +<%= form_tag(course_files_path(course), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>

<% if attachmenttypes.any? %> diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index 27bd4911a..af65bbcf4 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -2,7 +2,7 @@ <% versions = project.versions.sort %> <% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true,:remote => false,:method => :post,:name=>"upload_form", :class => "tabular") do %> +<%= form_tag(project_files_path(project), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>

diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 443fdfec8..c8a250fe8 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -25,6 +25,10 @@ $('#put-tag-form #name').val(""); $("#attachments_fields").children().remove(); $("#upload_file_count").text("未上传文件"); $('#upload_file_div').slideToggle('slow'); +<%if @project%> $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); +<%elsif @course%> +$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); +<%end%> <% end %> diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index 239848400..c719629ae 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -118,6 +118,8 @@ module Redmine scope = scope.visible(user1, options) elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos') scope = scope + elsif event_type.to_s == 'course_files' + scope = scope else ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option." # scope = scope @@ -125,7 +127,7 @@ module Redmine end scope.all(provider_options[:find_options].dup) end - + end end end