文件下载权限判断优化

This commit is contained in:
nwb 2014-07-25 14:05:25 +08:00
parent d6a425849a
commit 735d7f2c1f
1 changed files with 2 additions and 2 deletions

View File

@ -54,13 +54,13 @@ class AttachmentsController < ApplicationController
# modify by nwb
# 下载添加权限设置
candown = false
if @attachment.container.has_attribute?(:project) && @attachment.container.project
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)
elsif @attachment.container.is_a?(Project)
project = @attachment.container
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course
course = @attachment.container.course
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Course)