From a7312a6191342c39418a281ee97cac6487d154a4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 14 Mar 2016 14:43:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B8=B8=E5=AE=A2=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/models/user.rb | 3 +++ db/migrate/20160309022930_set_priority_for_org_subfields.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 13cf8b20f..8c5d4acea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2023,7 +2023,7 @@ module ApplicationHelper candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1) elsif attachment_history.container_type == "OrgSubfield" org = OrgSubfield.find(attachment_history.container_id) - candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1) + candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1 && (User.current.logged? || org.organization.allow_guest_download?)) end end diff --git a/app/models/user.rb b/app/models/user.rb index a74c20751..2c7d61b5c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -822,6 +822,9 @@ class User < Principal end def member_of_org?(org) + if !self.logged? + return false + end OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 end diff --git a/db/migrate/20160309022930_set_priority_for_org_subfields.rb b/db/migrate/20160309022930_set_priority_for_org_subfields.rb index f82400a62..56bafd071 100644 --- a/db/migrate/20160309022930_set_priority_for_org_subfields.rb +++ b/db/migrate/20160309022930_set_priority_for_org_subfields.rb @@ -3,7 +3,7 @@ class SetPriorityForOrgSubfields < ActiveRecord::Migration Organization.all.each do |org| org.transaction do org.org_subfields.where("field_type='default'").each do|field| - case field.field_type + case field.name when 'activity' field.update_attribute(:priority, 1) when 'course'