diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3726856b..53a0a259 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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'] diff --git a/app/models/project.rb b/app/models/project.rb index e85d5007..0e023da6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 } diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index be9ae7af..25ff12a9 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -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)%> <% end %> <% unless User.current.member_of?(@project) %> diff --git a/app/views/projects/course.html.erb b/app/views/projects/course.html.erb index b11d0226..864d22c7 100644 --- a/app/views/projects/course.html.erb +++ b/app/views/projects/course.html.erb @@ -16,6 +16,7 @@
<%= 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 %>
|
diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb
index e10be86f..8671d5ad 100644
--- a/app/views/projects/search.html.erb
+++ b/app/views/projects/search.html.erb
@@ -6,12 +6,21 @@
<%= l(:label_project_plural)%> | ++ <% if params[:project_type] == '0'%> + <%= l(:label_project_plural)%> + | <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> | - + <% else %> + <%= l(:label_new_course)%> + + +<%= 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) %> | + <% end %>
<%= 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 %>
|