1.修改课程资源删除

2.修改课程资源上传后的界面刷新
This commit is contained in:
nwb 2014-06-11 15:52:47 +08:00
parent 149d7ef1f4
commit 59051972e1
7 changed files with 34 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -1,7 +1,7 @@
<h3><%=l(:label_attachment_new)%></h3>
<% 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 %>
<div class="box">
<p>
<% if attachmenttypes.any? %>

View File

@ -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 %>
<div class="box">
<p>
<table>

View File

@ -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 %>

View File

@ -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