diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 514f68d49..23fe19333 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -600,7 +600,7 @@ private
def has_login
unless @attachment && @attachment.container_type == "PhoneAppVersion"
- render_403 if !User.current.logged? && @attachment.container_type != 'OrgSubfield' && @attachment.container_type != 'OrgDocumentComment'
+ render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download)
end
end
end
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 0ba6d35a6..361303833 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -116,6 +116,7 @@ class OrganizationsController < ApplicationController
@organization.description = params[:organization][:description]
# @organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
+ @organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0
#@organization.name = params[:organization][:name]
@organization.save
respond_to do |format|
diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb
index ab0a4ec50..ea7fbbb30 100644
--- a/app/views/organizations/new.html.erb
+++ b/app/views/organizations/new.html.erb
@@ -34,6 +34,12 @@
(打钩为公开,不打钩则不公开,若不公开,仅组织成员可见该组织。)
+
+
+
+ (打钩为允许游客下载文件)
+
+
创建
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb
index 45ac302ca..436d571f5 100644
--- a/app/views/organizations/setting.html.erb
+++ b/app/views/organizations/setting.html.erb
@@ -65,6 +65,9 @@
公开 :
class="ml3" />
+ 允许游客下载:
+ class="ml3" />
+
保存
<% end %>
diff --git a/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb b/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb
new file mode 100644
index 000000000..edf5c47b0
--- /dev/null
+++ b/db/migrate/20160121070232_add_allow_guest_download_to_organizations.rb
@@ -0,0 +1,5 @@
+class AddAllowGuestDownloadToOrganizations < ActiveRecord::Migration
+ def change
+ add_column :organizations, :allow_guest_download, :boolean, :default => true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 92cf224fc..7ced70118 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20160120032758) do
+ActiveRecord::Schema.define(:version => 20160121070232) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1262,8 +1262,9 @@ ActiveRecord::Schema.define(:version => 20160120032758) do
t.integer "home_id"
t.string "domain"
t.boolean "is_public"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "allow_guest_download", :default => true
end
create_table "phone_app_versions", :force => true do |t|