修复课程和项目搜索bug

This commit is contained in:
nieguanghui 2013-10-15 16:29:35 +08:00
parent ec63fc41bb
commit 17a4f14f2a
8 changed files with 19 additions and 8 deletions

View File

@ -355,9 +355,9 @@ class ProjectsController < ApplicationController
end
def search
#modified by nie
@projects = Project.visible
@projects = @projects.visible.like(params[:name]) if params[:name].present?
@projects = @projects.visible.where('project_type = ?', params[:project_type]).like(params[:name]) if params[:name].present?
@offset, @limit = api_offset_and_limit({:limit => 10})
@project_count = @projects.visible.count
@project_pages = Paginator.new @project_count, @limit, params['page']

View File

@ -145,7 +145,7 @@ class Project < ActiveRecord::Base
where(nil)
else
pattern = "%#{arg.to_s.strip.downcase}%"
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", :p => pattern)
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
end
}

View File

@ -56,6 +56,7 @@
<% if @course.teacher.id == User.current.id%>
<%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project} %>
<% else %>
<%= join_in_course(@project, User.current)%></div>
<% end %>
<% unless User.current.member_of?(@project) %>

View File

@ -16,6 +16,7 @@
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>
</tr>

View File

@ -2,7 +2,7 @@
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
<% end %>
<%= form_tag(:controller => 'projects', :action => 'search', :method => :get) do %>
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<div class="project-search-block">
<table width="100%" valign="center">
<tr>
@ -13,7 +13,7 @@
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>

View File

@ -6,12 +6,21 @@
<div class="project-search-block">
<table width="100%" valign="center">
<tr>
<td width="16%"><span style="margin-left:0px"><%= l(:label_project_plural)%></span></td>
<td width="16%"><span style="margin-left:0px">
<% if params[:project_type] == '0'%>
<%= l(:label_project_plural)%>
</span></td>
<td valign="center"><%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td>
<% else %>
<%= l(:label_new_course)%>
</span></td>
<td valign="center"><%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td>
<% end %>
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type]%>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>
</tr>

View File

@ -240,7 +240,7 @@ Redmine::MenuManager.map :top_college_menu do |menu|
menu.push :new_course, {:controller => 'projects', :action => 'course', :project_type => 1 }
menu.push :new_homework, {:controller => 'bids', :action => 'index', :project_type => 1 }
menu.push :new_contest, {:controller => 'bids', :action => 'contest', :project_type => 1}
menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 1 }, :caption => :label_project_plural
menu.push :projects, { :controller => 'projects', :action => 'index', :project_type => 0 }, :caption => :label_project_plural
menu.push :developer, {:controller => 'users', :action => 'index', :project_type => 1 }
menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 }
# menu.push :investor, :home_path

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 KiB

After

Width:  |  Height:  |  Size: 581 KiB