parent
149d7ef1f4
commit
59051972e1
|
@ -238,6 +238,8 @@ class ApplicationController < ActionController::Base
|
||||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
||||||
elsif @course
|
elsif @course
|
||||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
|
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
|
end
|
||||||
|
|
||||||
if allowed
|
if allowed
|
||||||
|
|
|
@ -124,10 +124,19 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @project.nil?
|
# modify by nwb
|
||||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum,@attachment.container) }
|
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
|
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
|
end
|
||||||
|
|
||||||
format.js
|
format.js
|
||||||
|
@ -190,9 +199,14 @@ private
|
||||||
def find_project
|
def find_project
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
# Show 404 if the filename in the url is wrong
|
# Show 404 if the filename in the url is wrong
|
||||||
|
# modify by nwb
|
||||||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
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'
|
if @attachment.container_type == 'Course'
|
||||||
@project = @attachment.project
|
@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
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
|
|
|
@ -193,6 +193,10 @@ class Attachment < ActiveRecord::Base
|
||||||
container.try(:project)
|
container.try(:project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def course
|
||||||
|
container
|
||||||
|
end
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
if container_id
|
if container_id
|
||||||
container && container.attachments_visible?(user)
|
container && container.attachments_visible?(user)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<h3><%=l(:label_attachment_new)%></h3>
|
<h3><%=l(:label_attachment_new)%></h3>
|
||||||
<% attachmenttypes = course.attachmenttypes %>
|
<% attachmenttypes = course.attachmenttypes %>
|
||||||
<%= error_messages_for 'attachment' %>
|
<%= 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">
|
<div class="box">
|
||||||
<p>
|
<p>
|
||||||
<% if attachmenttypes.any? %>
|
<% if attachmenttypes.any? %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<% versions = project.versions.sort %>
|
<% versions = project.versions.sort %>
|
||||||
<% attachmenttypes = project.attachmenttypes %>
|
<% attachmenttypes = project.attachmenttypes %>
|
||||||
<%= error_messages_for 'attachment' %>
|
<%= 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">
|
<div class="box">
|
||||||
<p>
|
<p>
|
||||||
<table>
|
<table>
|
||||||
|
|
|
@ -25,6 +25,10 @@ $('#put-tag-form #name').val("");
|
||||||
$("#attachments_fields").children().remove();
|
$("#attachments_fields").children().remove();
|
||||||
$("#upload_file_count").text("未上传文件");
|
$("#upload_file_count").text("未上传文件");
|
||||||
$('#upload_file_div').slideToggle('slow');
|
$('#upload_file_div').slideToggle('slow');
|
||||||
|
<%if @project%>
|
||||||
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
|
$("#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 %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,8 @@ module Redmine
|
||||||
scope = scope.visible(user1, options)
|
scope = scope.visible(user1, options)
|
||||||
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
|
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
|
||||||
scope = scope
|
scope = scope
|
||||||
|
elsif event_type.to_s == 'course_files'
|
||||||
|
scope = scope
|
||||||
else
|
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."
|
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
|
# scope = scope
|
||||||
|
@ -125,7 +127,7 @@ module Redmine
|
||||||
end
|
end
|
||||||
scope.all(provider_options[:find_options].dup)
|
scope.all(provider_options[:find_options].dup)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue