diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cff97e423..18093b790 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -443,12 +443,7 @@ class UsersController < ApplicationController # 资源分享请求弹框 def apply_resource - if User.current.logged? - @attachment = Attachment.find params[:attachment_id] - @state = 2 - else - @state = 1 - end + @attachment = Attachment.find params[:attachment_id] respond_to do |format| format.js end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4d92808d4..ce6d2259c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,7 +70,6 @@ module ApplicationHelper attach = Attachment.find(attachment_id) # 条件取否,result结果为true则不能下载 result = attach.is_public == 0 && attach.author != User.current && !attach.get_apply_resource_status(attach.id, User.current.id) && !attach_show_allow(attach) - return result end # Time 2015-03-24 15:27:29 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8f9ee2d85..aa4ef8670 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -143,7 +143,7 @@ class Attachment < ActiveRecord::Base def get_apply_resource_status attachment_id, author_id status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status) - status == 2 ? true :false + status == 2 end # add by nwb diff --git a/app/views/users/apply_resource.js.erb b/app/views/users/apply_resource.js.erb index 14a795fe5..601cafa11 100644 --- a/app/views/users/apply_resource.js.erb +++ b/app/views/users/apply_resource.js.erb @@ -1,6 +1,6 @@ -<% if @state == 1 %> +<% if !User.current.logged? %> alert("您还未登录"); -<% elsif @state == 2 %> +<% else %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/apply_resource', :locals => {:attachment => @attachment}) %>'); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove();