From 76bab839c7e5ebbd00757025f5251e1c3b42591c Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 15 Oct 2014 17:26:58 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=A0=B9=E6=8D=AE=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AF=84=E5=AE=A1=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E3=80=82?= =?UTF-8?q?2=E3=80=81=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=87=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 23 +++++++++++++---------- app/controllers/attachments_controller.rb | 2 +- app/models/attachment.rb | 12 ++---------- app/views/courses/new.html.erb | 1 + app/views/school/index.html.erb | 2 +- app/views/stores/index.html.erb | 3 ++- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 380baab0c..0947301ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -256,16 +256,19 @@ class ApplicationController < ActionController::Base end def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) - if @attachment.container_type == "Memo" - allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) - elsif @attachment.container_type == "Message" && !@project.nil? - allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) - elsif @attachment.container_type == "Message" && !@course.nil? - allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) - elsif @attachment.container_type == "contest" - return true - else - return true + case @attachment.container_type + when "Memo" + allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) + when "Message" + if @project + allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) + elsif @course + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) + end + when "contest" + return true + else + return true end if allowed diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 08469ac48..905bbb0a2 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -61,7 +61,7 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = false + candown = false if (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project project = @attachment.container.project candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 90cfed429..c934a5ce8 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -402,13 +402,8 @@ class Attachment < ActiveRecord::Base # Finds an attachment that matches the given token and that has no container def self.find_by_token(token) - if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ - attachment_id, attachment_digest = $1, $2 - attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first - if attachment && attachment.container.nil? - attachment - end - end + attachment = find_by_token_only(token) + attachment if attachment.container.nil? end # Finds an attachment that matches the given token @@ -416,9 +411,6 @@ class Attachment < ActiveRecord::Base if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ attachment_id, attachment_digest = $1, $2 attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first - if attachment - attachment - end end end diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 336bca071..8d153a447 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -11,3 +11,4 @@ <%= javascript_tag "$('#course_name').focus();" %> <% end %> +<% html_title(l(:label_course_new)) -%> \ No newline at end of file diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index 02b934581..37febe309 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -98,4 +98,4 @@ - +<% html_title(l(:label_school_all)) -%> diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 5df6ecca8..afd2244af 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -68,4 +68,5 @@ $("#IE_resource_sum_css").children(".line_block").css("width","45%"); } }); - \ No newline at end of file + +<% html_title(l(:label_stores_index)) -%> \ No newline at end of file