修复课程和项目搜索bug
This commit is contained in:
parent
ec63fc41bb
commit
17a4f14f2a
|
@ -355,9 +355,9 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
|
#modified by nie
|
||||||
@projects = Project.visible
|
@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})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@project_count = @projects.visible.count
|
@project_count = @projects.visible.count
|
||||||
@project_pages = Paginator.new @project_count, @limit, params['page']
|
@project_pages = Paginator.new @project_count, @limit, params['page']
|
||||||
|
|
|
@ -145,7 +145,7 @@ class Project < ActiveRecord::Base
|
||||||
where(nil)
|
where(nil)
|
||||||
else
|
else
|
||||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
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
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<% if @course.teacher.id == User.current.id%>
|
<% if @course.teacher.id == User.current.id%>
|
||||||
<%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project} %>
|
<%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project} %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
<%= join_in_course(@project, User.current)%></div>
|
<%= join_in_course(@project, User.current)%></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless User.current.member_of?(@project) %>
|
<% unless User.current.member_of?(@project) %>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<div class="project-search">
|
<div class="project-search">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
<%= 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 %>
|
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
||||||
</div></td>
|
</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_tag(:controller => 'projects', :action => 'search', :method => :get) do %>
|
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
|
||||||
<div class="project-search-block">
|
<div class="project-search-block">
|
||||||
<table width="100%" valign="center">
|
<table width="100%" valign="center">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<div class="project-search">
|
<div class="project-search">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
<%= 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 %>
|
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
||||||
|
|
||||||
</div></td>
|
</div></td>
|
||||||
|
|
|
@ -6,12 +6,21 @@
|
||||||
<div class="project-search-block">
|
<div class="project-search-block">
|
||||||
<table width="100%" valign="center">
|
<table width="100%" valign="center">
|
||||||
<tr>
|
<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>
|
<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">
|
<td align="right">
|
||||||
<div class="project-search">
|
<div class="project-search">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
<%= 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 %>
|
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
|
||||||
</div></td>
|
</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -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_course, {:controller => 'projects', :action => 'course', :project_type => 1 }
|
||||||
menu.push :new_homework, {:controller => 'bids', :action => 'index', :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 :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 :developer, {:controller => 'users', :action => 'index', :project_type => 1 }
|
||||||
menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 }
|
menu.push :enterprise_into, {:controller=>'projects', :action=>'enterprise_course', :project_type => 0 }
|
||||||
# menu.push :investor, :home_path
|
# menu.push :investor, :home_path
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 826 KiB After Width: | Height: | Size: 581 KiB |
Loading…
Reference in New Issue