# 页面返回异常处理

This commit is contained in:
zhanghaitao 2014-08-13 15:37:28 +08:00
parent 7b3468718f
commit 4934c8c801
4 changed files with 35 additions and 28 deletions

View File

@ -5,12 +5,18 @@ class StoresController < ApplicationController
layout 'base_stores'
def search
begin
q = "%#{params[:name].strip}%"
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
result = find_public_attache q
@searched_attach = paginateHelper result
@result_all_count = result.count;
rescue Exception => e
#render 'stores'
redirect_to stores_path
end
end
def find_public_attache keywords

View File

@ -138,10 +138,10 @@ class Issue < ActiveRecord::Base
nil
when 'default'
user_ids = [user.id] + user.groups.map(&:id)
"(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
"(#{table_name}.is_private = #{connection.quoted_false}) OR (#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
when 'own'
user_ids = [user.id] + user.groups.map(&:id)
"(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
"(#{table_name}.author_id = #{user.id} OR #{table_name}.tracker_id IN (#{user_ids.join(',')}) OR #{table_name}.assigned_to_id IN (#{user_ids.join(',')}))"
else
'1=0'
end
@ -159,9 +159,9 @@ class Issue < ActiveRecord::Base
when 'all'
true
when 'default'
!self.is_private? || (self.author == user || user.is_or_belongs_to?(assigned_to))
(!self.is_private? ||self.tracker == user) || (self.author == user || user.is_or_belongs_to?(assigned_to))
when 'own'
self.author == user || user.is_or_belongs_to?(assigned_to)
self.tracker == user || self.author == user || user.is_or_belongs_to?(assigned_to)
else
false
end
@ -1009,9 +1009,10 @@ class Issue < ActiveRecord::Base
s << ' overdue' if overdue?
s << ' child' if child?
s << ' parent' unless leaf?
s << ' private' if is_private?
#s << ' private' if is_private?
s << ' created-by-me' if User.current.logged? && author_id == User.current.id
s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
s << ' tracker-id' if User.current.logged? && tracker_id == User.current.id
s
end