@@ -32,7 +32,7 class AdminController < ApplicationController | |||||
32 | def projects |
|
32 | def projects | |
33 | @status = params[:status] || 1 |
|
33 | @status = params[:status] || 1 | |
34 |
|
34 | |||
35 |
scope = Project.status(@status). |
|
35 | scope = Project.status(@status).sorted | |
36 | scope = scope.like(params[:name]) if params[:name].present? |
|
36 | scope = scope.like(params[:name]) if params[:name].present? | |
37 | @projects = scope.to_a |
|
37 | @projects = scope.to_a | |
38 |
|
38 |
@@ -40,21 +40,22 class ProjectsController < ApplicationController | |||||
40 |
|
40 | |||
41 | # Lists visible projects |
|
41 | # Lists visible projects | |
42 | def index |
|
42 | def index | |
|
43 | scope = Project.visible.sorted | |||
|
44 | ||||
43 | respond_to do |format| |
|
45 | respond_to do |format| | |
44 | format.html { |
|
46 | format.html { | |
45 | scope = Project |
|
|||
46 | unless params[:closed] |
|
47 | unless params[:closed] | |
47 | scope = scope.active |
|
48 | scope = scope.active | |
48 | end |
|
49 | end | |
49 |
@projects = scope. |
|
50 | @projects = scope.to_a | |
50 | } |
|
51 | } | |
51 | format.api { |
|
52 | format.api { | |
52 | @offset, @limit = api_offset_and_limit |
|
53 | @offset, @limit = api_offset_and_limit | |
53 |
@project_count = |
|
54 | @project_count = scope.count | |
54 |
@projects = |
|
55 | @projects = scope.offset(@offset).limit(@limit).to_a | |
55 | } |
|
56 | } | |
56 | format.atom { |
|
57 | format.atom { | |
57 |
projects = |
|
58 | projects = scope.reorder(:created_on => :desc).limit(Setting.feeds_limit.to_i).to_a | |
58 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") |
|
59 | render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") | |
59 | } |
|
60 | } | |
60 | end |
|
61 | end |
@@ -111,6 +111,7 class Project < ActiveRecord::Base | |||||
111 | where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", :p => pattern) |
|
111 | where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p", :p => pattern) | |
112 | end |
|
112 | end | |
113 | } |
|
113 | } | |
|
114 | scope :sorted, lambda {order(:lft)} | |||
114 |
|
115 | |||
115 | def initialize(attributes=nil, *args) |
|
116 | def initialize(attributes=nil, *args) | |
116 | super |
|
117 | super |
General Comments 0
You need to be logged in to leave comments.
Login now