# 页面返回异常处理

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

View File

@ -138,10 +138,10 @@ class Issue < ActiveRecord::Base
nil nil
when 'default' when 'default'
user_ids = [user.id] + user.groups.map(&:id) 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' when 'own'
user_ids = [user.id] + user.groups.map(&:id) 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 else
'1=0' '1=0'
end end
@ -159,9 +159,9 @@ class Issue < ActiveRecord::Base
when 'all' when 'all'
true true
when 'default' 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' 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 else
false false
end end
@ -1009,9 +1009,10 @@ class Issue < ActiveRecord::Base
s << ' overdue' if overdue? s << ' overdue' if overdue?
s << ' child' if child? s << ' child' if child?
s << ' parent' unless leaf? 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 << ' 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 << ' 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 s
end end

View File

@ -21,7 +21,7 @@
<% k.each do |c1|%> <% k.each do |c1|%>
<div class="table_row1 <%= cycle 'odd', 'even' %>"> <div class="table_row1 <%= cycle 'odd', 'even' %>">
<div class="filename table_cell1 filename1" > <div class="filename table_cell1 filename1" >
<%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %> <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %>
</div> </div>
<div class="table_cell1 filedown1"> <div class="table_cell1 filedown1">
<%= c1.downloads %> <%= c1.downloads %>
@ -32,7 +32,7 @@
</div> </div>
<% end -%> <% end -%>
</div> </div>
</div> </div>
<% end; reset_cycle %> <% end; reset_cycle %>
</div> </div>

View File

@ -14,7 +14,7 @@
$('#' + id).val(''); $('#' + id).val('');
} }
} }
$(function(){ $(function(){
$("#main").find("a").attr("target", "_blank"); $("#main").find("a").attr("target", "_blank");
setCss(); setCss();
@ -118,23 +118,23 @@
<div id="identifier-pannel" style="display:none"> <div id="identifier-pannel" style="display:none">
<%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %> <%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
<div class="weixin-content"><%=l(:label_weixin)%></div> <div class="weixin-content"><%=l(:label_weixin)%></div>
</div> </div>
<div class="main-content-bar" id="main-content-bar"> <div class="main-content-bar" id="main-content-bar">
<!--文字--> <!--文字-->
<div style="float: left;padding-left:15px;"> <div style="float: left;padding-left:15px;">
<% if get_avatar?(@contest_page) %> <% if get_avatar?(@contest_page) %>
<%= image_tag(url_to_avatar(@contest_page), width:@contest_page.image_width,height: @contest_page.image_height) %> <%= image_tag(url_to_avatar(@contest_page), width:@contest_page.image_width,height: @contest_page.image_height) %>
<% else %> <% else %>
<%= image_tag '/images/transparent.png', width:@contest_page.image_width,height: @contest_page.image_height %> <%= image_tag '/images/transparent.png', width:@contest_page.image_width,height: @contest_page.image_height %>
<% end %> <% end %>
</div> </div>
<div class="welcome_left" id="welcome_left"> <div class="welcome_left" id="welcome_left">
<% unless @contest_page.nil? %> <% unless @contest_page.nil? %>
<span class="font_welcome_trustie"><%= @contest_page.title %></span> <span class="font_welcome_tdescription">, <%= @contest_page.description %></span> <span class="font_welcome_trustie"><%= @contest_page.title %></span> <span class="font_welcome_tdescription">, <%= @contest_page.description %></span>
<% end %> <% end %>
</div> </div>
<!--搜索框--> <!--搜索框-->
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> <%= form_tag({controller: :welcome, action: :search }, method: :get) do %>
<%= text_field_tag 'name', params[:name], :placeholder => l(:label_search_intimation), name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%> <%= text_field_tag 'name', params[:name], :placeholder => l(:label_search_intimation), name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%>
@ -162,7 +162,7 @@
<div class="avatar-4" style="float: left; margin-top: 7px"> <div class="avatar-4" style="float: left; margin-top: 7px">
<%= image_tag('/images/contest1.png')%> <%= image_tag('/images/contest1.png')%>
</div> </div>
<div style="float: left; margin-left: 12px; margin-top: 10px; margin-bottom: -4px; width: 380px;"> <div style="float: left; margin-left: 12px; margin-top: 10px; margin-bottom: -4px; width: 380px;">
<!-- <%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> --> <!-- <%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> -->
<%= link_to(contest.name, contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> <%= link_to(contest.name, contest_contestnotifications_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
@ -172,19 +172,19 @@
<span class="font_lighter">(<span style="font-size: 13px"><%= link_to("#{contest.contesting_softapplications.count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %></span>)</span> <span class="font_lighter">(<span style="font-size: 13px"><%= link_to("#{contest.contesting_softapplications.count}"+l(:label_work_quantity), show_attendingcontest_contest_path(contest), :target => "_blank") %></span>)</span>
<% end %> <% end %>
</div> </div>
<div style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;" class="text_nowrap"> <div style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;" class="text_nowrap">
<span class='font_lighter' title ='<%=contest.description%>'><%=contest.description.truncate(100, omission: '...')%></span> <span class='font_lighter' title ='<%=contest.description%>'><%=contest.description.truncate(100, omission: '...')%></span>
</div><br /> </div><br />
<div style="padding-left: 57px; clear: left;"> <div style="padding-left: 57px; clear: left;">
<span class="font_lighter"><%=l(:label_release_time)%>:&nbsp;<%=format_time contest.created_on %></span> <span class="font_lighter"><%=l(:label_release_time)%>:&nbsp;<%=format_time contest.created_on %></span>
</div> </div>
</li> </li>
<% end; reset_cycle %> <% end; reset_cycle %>
</div> </div>
</div> </div>
</div> </div>
@ -299,31 +299,31 @@
<% if Softapplication.count > 0%> <% if Softapplication.count > 0%>
<div class="d-p-projectlist"> <div class="d-p-projectlist">
<% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %>
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'> <li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
<div class="avatar-4" style="float: left; margin-top: 7px"> <div class="avatar-4" style="float: left; margin-top: 7px">
<%= image_tag('/images/app1.png')%> <%= image_tag('/images/app1.png')%>
</div> </div>
<div style="float: left; margin-left: 10px; margin-top: 7px;margin-bottom: -2px; width: 380px;"> <div style="float: left; margin-left: 10px; margin-top: 7px;margin-bottom: -2px; width: 380px;">
<%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %> <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %>
</div> </div>
<div class='text_nowrap' style="float: left;margin:5px; margin-left: 10px; margin-bottom:1px; width: 380px;"> <div class='text_nowrap' style="float: left;margin:5px; margin-left: 10px; margin-bottom:1px; width: 380px;">
<span class='font_lighter' title =<%=softapplication.description.to_s%>><%=softapplication.description.to_s.truncate(50, omission: '...')%></span> <span class='font_lighter' title =<%=softapplication.description.to_s%>><%=softapplication.description.to_s.truncate(50, omission: '...')%></span>
</div><br /> </div><br />
<div style="padding-left: 55px; clear: left;"> <div style="padding-left: 55px; clear: left;">
<span class="font_lighter"><%=l(:label_release_time)%>:&nbsp;<%=format_time softapplication.created_at %></span> <span class="font_lighter"><%=l(:label_release_time)%>:&nbsp;<%=format_time softapplication.created_at %></span>
</div> </div>
</li> </li>
<% end; reset_cycle %> <% end; reset_cycle %>
</div> </div>
<% else %> <% else %>
<p class="font_lighter"><%= l(:label_no_ftapplication) %></p> <p class="font_lighter"><%= l(:label_no_ftapplication) %></p>
<% end %> <% end %>
</div> </div>
</div> </div>