This commit is contained in:
z9hang 2014-07-17 18:10:42 +08:00
commit 0f4933240b
19 changed files with 59 additions and 20 deletions

View File

@ -27,6 +27,7 @@ group :test do
gem "mocha", "~> 0.13.3"
gem 'capybara', '~> 2.0.0'
gem 'nokogiri', '< 1.6.0'
gem 'factory_girl'
platforms :mri, :mingw do
group :rmagick do
@ -43,7 +44,7 @@ group :development, :test do
gem 'spork-testunit'
gem 'guard-spork'
gem 'guard-test', '~> 1.0.0'
#gem 'ruby-prof'
gem 'ruby-prof' unless RUBY_PLATFORM =~ /w32/
gem 'pry'
gem 'pry-nav'
end

View File

@ -78,6 +78,8 @@ GEM
coffee-script-source (1.7.1)
erubis (2.7.0)
execjs (2.2.1)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
fastercsv (1.5.5)
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
@ -247,6 +249,7 @@ DEPENDENCIES
capybara (~> 2.0.0)
coderay (~> 1.0.6)
coffee-rails (~> 3.2.1)
factory_girl
fastercsv (~> 1.5.0)
guard-rails
guard-spork

View File

@ -55,32 +55,35 @@ class AttachmentsController < ApplicationController
candown = false
if @attachment.container.has_attribute?(:project) && @attachment.container.project
project = @attachment.container.project
candown= User.current.member_of?(project)
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Project)
project = @attachment.container
candown= User.current.member_of?(project)
candown= User.current.member_of?(project) || (project.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
course = @attachment.container.course
candown= User.current.member_of_course?(course)
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Course)
course = @attachment.container
candown= User.current.member_of_course?(course)
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
candown = true
else
candown = @attachment.is_public == 1
end
if candown || User.current.admin?
@attachment.increment_download
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
else
render_403 :message => :notice_not_authorized
end
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
end
rescue => e
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end

View File

@ -38,7 +38,7 @@ class StoresController < ApplicationController
LIMIT = 12 unless const_defined?(:LIMIT)
def index
@projects_attach = project_classification(0).take(LIMIT)
@courses_attach = Attachment.includes(:course).where("courses.is_public = ?", 1).
@courses_attach = Attachment.includes(:course).where("courses.is_public = 1").
where(container_type: 'Course').
limit(LIMIT)
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).

View File

@ -16,6 +16,8 @@ module StoresHelper
news_path(container)
when 'Project'
project_files_path(container)
when 'Course'
course_files_path(container)
when 'Version'
# version_path(container)
project_files_path(container.project)

View File

@ -11,7 +11,9 @@
<div id="file_buttons" class="nhidden">
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %>
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %>
<p></p>
<div class="box" id="files-box">
<label for="files-box" style="font-weight:bold;">&nbsp;&nbsp;<%= l(:label_files_filter) %></label>
<% if attachmenttypes.any? %>
&nbsp; &nbsp; &nbsp;
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
@ -24,7 +26,7 @@
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
<% end %>
</div>
<div id="upload_file_div" class="relation_file_div hidden">
<%= render :partial => 'course_new', locals: {course: @course} %>
</div>

View File

@ -11,7 +11,9 @@
<div id="file_buttons" class="nhidden">
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
<p></p>
<div class="box" id="files-box">
<label for="files-box" style="font-weight:bold;">&nbsp;&nbsp;<%= l(:label_files_filter) %></label>
<% if attachmenttypes.any? %>
&nbsp; &nbsp; &nbsp;
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
@ -24,6 +26,7 @@
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
:onchange => "attachment_contenttypes_searchex(this.value)" %>
<% end %>
</div>
<div id="upload_file_div" class="relation_file_div hidden">
<%= render :partial => 'new', locals: {project: @project} %>

View File

@ -183,12 +183,12 @@
<!--description-->
<div class="inf_user_context">
<div class="font_title_left">
<%= l(:label_course_overview) %>
<%= l(:label_new_course_description) %>
</div>
<div style="padding-bottom: 8px">
<% if @course.description && @course.description.size>0 %>
<div class="font_lighter_sidebar">
<div class="font_lighter_sidebar" style="word-break:break-all; word-wrap:break-all;">
<%= textilizable @course.description %>
</div>

View File

@ -937,6 +937,7 @@ en:
label_cross_project_hierarchy: With project hierarchy
label_cross_project_system: With all projects
label_gantt_progress_line: Progress line
label_files_filter: Files Filter
button_login: Login
button_submit: Submit

View File

@ -1742,6 +1742,7 @@ zh:
label_file_number: 文档的数量
label_code_submit_number: 代码提交数量
label_topic_number: 讨论区帖子数量
label_files_filter: 资源过滤:
label_course_contribute_to: 参与了 %{project_count} 个项目:
label_x_course_contribute_to:

View File

@ -45,6 +45,8 @@ class AttachmentsControllerTest < ActionController::TestCase
role.save
}
User.current = nil
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end

View File

@ -41,6 +41,8 @@ class CodeReviewControllerTest < ActionController::TestCase
role.permissions << :view_code_review
role.save
}
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end
context "index" do

View File

@ -42,6 +42,8 @@ class CodeReviewSettingsControllerTest < ActionController::TestCase
role.permissions << :view_code_review
role.save
}
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end

View File

@ -62,6 +62,8 @@ class IssuesControllerTest < ActionController::TestCase
role.permissions << :view_code_review
role.save
}
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end
def test_show

View File

@ -26,6 +26,8 @@ class ProjectsControllerTest < ActionController::TestCase
@controller = ProjectsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end
context "#settings" do

View File

@ -52,6 +52,8 @@ class RepositoriesControllerTest < ActionController::TestCase
role.permissions << :browse_repository
role.save
}
@request.session[:ctime] = Time.now.to_i
@request.session[:atime] = Time.now.to_i
end
def test_revision

View File

@ -116,4 +116,10 @@ FactoryGirl.define do
end
end
end
ActiveRecord::Fixtures.create_fixtures(File.dirname(__FILE__)+ '/fixtures/',
[ :code_review_assignments,
:code_reviews,
:code_review_project_settings,
:code_review_user_settings])

View File

@ -21,6 +21,11 @@ class CodeReviewAssignmentTest < ActiveSupport::TestCase
fixtures :code_review_assignments, :issues, :issue_statuses,
:projects, :trackers, :projects_trackers, :users, :members, :repositories,
:enumerations
ActiveRecord::Fixtures.create_fixtures(File.dirname(__FILE__)+ '/../fixtures/',
[ :code_review_assignments,
:code_reviews,
:code_review_project_settings,
:code_review_user_settings])
def setup
@assignment = CodeReviewAssignment.new

View File

@ -1852,7 +1852,7 @@ span.required {color: #bb0000;}
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
a.remove-upload:hover {text-decoration:none !important;}
#attachments_fields input.is_public_checkbox {width:20px;}
#attachments_fields span.ispublic-label {display:inline-block;width:50px;margin-left:10px; }
#attachments_fields span.ispublic-label {display:inline-block;width:30px;margin-left:10px; }
/*gcm upload file count and deleteall*/
#upload_file_count #count {color:red; font-size:1.5em;}