@@ -29,16 +29,20 class AdminController < ApplicationController | |||
|
29 | 29 | sort_init 'name', 'asc' |
|
30 | 30 | sort_update |
|
31 | 31 | |
|
32 |
@status = params[:status] ? params[:status].to_i : |
|
|
33 | conditions = nil | |
|
34 | conditions = ["status=?", @status] unless @status == 0 | |
|
32 | @status = params[:status] ? params[:status].to_i : 1 | |
|
33 | c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status]) | |
|
35 | 34 | |
|
36 | @project_count = Project.count(:conditions => conditions) | |
|
35 | unless params[:name].blank? | |
|
36 | name = "%#{params[:name].strip.downcase}%" | |
|
37 | c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name] | |
|
38 | end | |
|
39 | ||
|
40 | @project_count = Project.count(:conditions => c.conditions) | |
|
37 | 41 | @project_pages = Paginator.new self, @project_count, |
|
38 | 42 | per_page_option, |
|
39 | 43 | params['page'] |
|
40 | 44 | @projects = Project.find :all, :order => sort_clause, |
|
41 | :conditions => conditions, | |
|
45 | :conditions => c.conditions, | |
|
42 | 46 | :limit => @project_pages.items_per_page, |
|
43 | 47 | :offset => @project_pages.current.offset |
|
44 | 48 |
@@ -17,7 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | module AdminHelper |
|
19 | 19 | def project_status_options_for_select(selected) |
|
20 |
options_for_select([[l(:label_all), |
|
|
20 | options_for_select([[l(:label_all), ''], | |
|
21 | 21 | [l(:status_active), 1]], selected) |
|
22 | 22 | end |
|
23 | 23 | end |
@@ -4,11 +4,13 | |||
|
4 | 4 | |
|
5 | 5 | <h2><%=l(:label_project_plural)%></h2> |
|
6 | 6 | |
|
7 | <% form_tag() do %> | |
|
7 | <% form_tag({}, :method => :get) do %> | |
|
8 | 8 | <fieldset><legend><%= l(:label_filter_plural) %></legend> |
|
9 | 9 | <label><%= l(:field_status) %> :</label> |
|
10 | 10 | <%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> |
|
11 | <%= submit_tag l(:button_apply), :class => "small" %> | |
|
11 | <label><%= l(:label_project) %>:</label> | |
|
12 | <%= text_field_tag 'name', params[:name], :size => 30 %> | |
|
13 | <%= submit_tag l(:button_apply), :class => "small", :name => nil %> | |
|
12 | 14 | </fieldset> |
|
13 | 15 | <% end %> |
|
14 | 16 | |
@@ -45,6 +45,25 class AdminControllerTest < Test::Unit::TestCase | |||
|
45 | 45 | :attributes => { :class => /nodata/ } |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | def test_projects | |
|
49 | get :projects | |
|
50 | assert_response :success | |
|
51 | assert_template 'projects' | |
|
52 | assert_not_nil assigns(:projects) | |
|
53 | # active projects only | |
|
54 | assert_nil assigns(:projects).detect {|u| !u.active?} | |
|
55 | end | |
|
56 | ||
|
57 | def test_projects_with_name_filter | |
|
58 | get :projects, :name => 'store', :status => '' | |
|
59 | assert_response :success | |
|
60 | assert_template 'projects' | |
|
61 | projects = assigns(:projects) | |
|
62 | assert_not_nil projects | |
|
63 | assert_equal 1, projects.size | |
|
64 | assert_equal 'OnlineStore', projects.first.name | |
|
65 | end | |
|
66 | ||
|
48 | 67 | def test_load_default_configuration_data |
|
49 | 68 | delete_configuration_data |
|
50 | 69 | post :default_configuration, :lang => 'fr' |
General Comments 0
You need to be logged in to leave comments.
Login now