@@ -32,10 +32,9 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).order('lft') | |
36 | scope = scope.like(params[:name]) if params[:name].present? |
|
36 | scope = scope.like(params[:name]) if params[:name].present? | |
37 |
|
37 | @projects = scope.all | ||
38 | @projects = scope.all(:order => 'lft') |
|
|||
39 |
|
38 | |||
40 | render :action => "projects", :layout => false if request.xhr? |
|
39 | render :action => "projects", :layout => false if request.xhr? | |
41 | end |
|
40 | end |
@@ -43,17 +43,22 class BoardsController < ApplicationController | |||||
43 |
|
43 | |||
44 | @topic_count = @board.topics.count |
|
44 | @topic_count = @board.topics.count | |
45 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] |
|
45 | @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] | |
46 | @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all( |
|
46 | @topics = @board.topics. | |
47 | :include => [:author, {:last_reply => :author}], |
|
47 | reorder("#{Message.table_name}.sticky DESC"). | |
48 | :limit => @topic_pages.items_per_page, |
|
48 | includes(:author, {:last_reply => :author}). | |
49 | :offset => @topic_pages.current.offset) |
|
49 | limit(@topic_pages.items_per_page). | |
|
50 | offset(@topic_pages.current.offset). | |||
|
51 | order(sort_clause). | |||
|
52 | all | |||
50 | @message = Message.new(:board => @board) |
|
53 | @message = Message.new(:board => @board) | |
51 | render :action => 'show', :layout => !request.xhr? |
|
54 | render :action => 'show', :layout => !request.xhr? | |
52 | } |
|
55 | } | |
53 | format.atom { |
|
56 | format.atom { | |
54 |
@messages = @board.messages. |
|
57 | @messages = @board.messages. | |
55 | :include => [:author, :board], |
|
58 | reorder('created_on DESC'). | |
56 | :limit => Setting.feeds_limit.to_i |
|
59 | includes(:author, :board). | |
|
60 | limit(Setting.feeds_limit.to_i). | |||
|
61 | all | |||
57 | render_feed(@messages, :title => "#{@project}: #{@board}") |
|
62 | render_feed(@messages, :title => "#{@project}: #{@board}") | |
58 | } |
|
63 | } | |
59 | end |
|
64 | end |
@@ -27,7 +27,7 class DocumentsController < ApplicationController | |||||
27 |
|
27 | |||
28 | def index |
|
28 | def index | |
29 | @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' |
|
29 | @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' | |
30 |
documents = @project.documents. |
|
30 | documents = @project.documents.includes(:attachments, :category).all | |
31 | case @sort_by |
|
31 | case @sort_by | |
32 | when 'date' |
|
32 | when 'date' | |
33 | @grouped = documents.group_by {|d| d.updated_on.to_date } |
|
33 | @grouped = documents.group_by {|d| d.updated_on.to_date } |
@@ -36,7 +36,7 class TrackersController < ApplicationController | |||||
36 |
|
36 | |||
37 | def new |
|
37 | def new | |
38 | @tracker ||= Tracker.new(params[:tracker]) |
|
38 | @tracker ||= Tracker.new(params[:tracker]) | |
39 |
@trackers = Tracker. |
|
39 | @trackers = Tracker.sorted.all | |
40 | @projects = Project.all |
|
40 | @projects = Project.all | |
41 | end |
|
41 | end | |
42 |
|
42 |
@@ -47,10 +47,7 class UsersController < ApplicationController | |||||
47 | @user_count = scope.count |
|
47 | @user_count = scope.count | |
48 | @user_pages = Paginator.new self, @user_count, @limit, params['page'] |
|
48 | @user_pages = Paginator.new self, @user_count, @limit, params['page'] | |
49 | @offset ||= @user_pages.current.offset |
|
49 | @offset ||= @user_pages.current.offset | |
50 | @users = scope.find :all, |
|
50 | @users = scope.order(sort_clause).limit(@limit).offset(@offset).all | |
51 | :order => sort_clause, |
|
|||
52 | :limit => @limit, |
|
|||
53 | :offset => @offset |
|
|||
54 |
|
51 | |||
55 | respond_to do |format| |
|
52 | respond_to do |format| | |
56 | format.html { |
|
53 | format.html { |
@@ -213,11 +213,12 class WikiController < ApplicationController | |||||
213 | @version_count = @page.content.versions.count |
|
213 | @version_count = @page.content.versions.count | |
214 | @version_pages = Paginator.new self, @version_count, per_page_option, params['page'] |
|
214 | @version_pages = Paginator.new self, @version_count, per_page_option, params['page'] | |
215 | # don't load text |
|
215 | # don't load text | |
216 |
@versions = @page.content.versions. |
|
216 | @versions = @page.content.versions. | |
217 |
|
|
217 | select("id, author_id, comments, updated_on, version"). | |
218 | :order => 'version DESC', |
|
218 | reorder('version DESC'). | |
219 |
|
|
219 | limit(@version_pages.items_per_page + 1). | |
220 |
|
|
220 | offset(@version_pages.current.offset). | |
|
221 | all | |||
221 |
|
222 | |||
222 | render :layout => false if request.xhr? |
|
223 | render :layout => false if request.xhr? | |
223 | end |
|
224 | end |
@@ -685,12 +685,14 class Query < ActiveRecord::Base | |||||
685 | order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',') |
|
685 | order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',') | |
686 | order_option = nil if order_option.blank? |
|
686 | order_option = nil if order_option.blank? | |
687 |
|
687 | |||
688 | issues = Issue.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:status, :project] + (options[:include] || [])).uniq, |
|
688 | issues = Issue.visible.where(options[:conditions]).all( | |
|
689 | :include => ([:status, :project] + (options[:include] || [])).uniq, | |||
689 |
|
|
690 | :conditions => statement, | |
690 |
|
|
691 | :order => order_option, | |
691 |
|
|
692 | :joins => joins_for_order_statement(order_option), | |
692 |
|
|
693 | :limit => options[:limit], | |
693 |
|
|
694 | :offset => options[:offset] | |
|
695 | ) | |||
694 |
|
696 | |||
695 | if has_column?(:spent_hours) |
|
697 | if has_column?(:spent_hours) | |
696 | Issue.load_visible_spent_hours(issues) |
|
698 | Issue.load_visible_spent_hours(issues) | |
@@ -721,11 +723,13 class Query < ActiveRecord::Base | |||||
721 | # Returns the journals |
|
723 | # Returns the journals | |
722 | # Valid options are :order, :offset, :limit |
|
724 | # Valid options are :order, :offset, :limit | |
723 | def journals(options={}) |
|
725 | def journals(options={}) | |
724 | Journal.visible.find :all, :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}], |
|
726 | Journal.visible.all( | |
|
727 | :include => [:details, :user, {:issue => [:project, :author, :tracker, :status]}], | |||
725 |
|
|
728 | :conditions => statement, | |
726 |
|
|
729 | :order => options[:order], | |
727 |
|
|
730 | :limit => options[:limit], | |
728 |
|
|
731 | :offset => options[:offset] | |
|
732 | ) | |||
729 | rescue ::ActiveRecord::StatementInvalid => e |
|
733 | rescue ::ActiveRecord::StatementInvalid => e | |
730 | raise StatementInvalid.new(e.message) |
|
734 | raise StatementInvalid.new(e.message) | |
731 | end |
|
735 | end | |
@@ -733,7 +737,10 class Query < ActiveRecord::Base | |||||
733 | # Returns the versions |
|
737 | # Returns the versions | |
734 | # Valid options are :conditions |
|
738 | # Valid options are :conditions | |
735 | def versions(options={}) |
|
739 | def versions(options={}) | |
736 | Version.visible.scoped(:conditions => options[:conditions]).find :all, :include => :project, :conditions => project_statement |
|
740 | Version.visible.where(options[:conditions]).all( | |
|
741 | :include => :project, | |||
|
742 | :conditions => project_statement | |||
|
743 | ) | |||
737 | rescue ::ActiveRecord::StatementInvalid => e |
|
744 | rescue ::ActiveRecord::StatementInvalid => e | |
738 | raise StatementInvalid.new(e.message) |
|
745 | raise StatementInvalid.new(e.message) | |
739 | end |
|
746 | end |
@@ -248,14 +248,16 module ActiveRecord #:nodoc: | |||||
248 | def self.reloadable? ; false ; end |
|
248 | def self.reloadable? ; false ; end | |
249 | # find first version before the given version |
|
249 | # find first version before the given version | |
250 | def self.before(version) |
|
250 | def self.before(version) | |
251 |
|
|
251 | order('version desc'). | |
252 |
|
|
252 | where("#{original_class.versioned_foreign_key} = ? and version < ?", version.send(original_class.versioned_foreign_key), version.version). | |
|
253 | first | |||
253 | end |
|
254 | end | |
254 |
|
255 | |||
255 | # find first version after the given version. |
|
256 | # find first version after the given version. | |
256 | def self.after(version) |
|
257 | def self.after(version) | |
257 |
|
|
258 | order('version'). | |
258 |
|
|
259 | where("#{original_class.versioned_foreign_key} = ? and version > ?", version.send(original_class.versioned_foreign_key), version.version). | |
|
260 | first | |||
259 | end |
|
261 | end | |
260 |
|
262 | |||
261 | def previous |
|
263 | def previous | |
@@ -467,9 +469,9 module ActiveRecord #:nodoc: | |||||
467 |
|
469 | |||
468 | # Finds versions of a specific model. Takes an options hash like <tt>find</tt> |
|
470 | # Finds versions of a specific model. Takes an options hash like <tt>find</tt> | |
469 | def find_versions(id, options = {}) |
|
471 | def find_versions(id, options = {}) | |
470 |
versioned_class. |
|
472 | versioned_class.all({ | |
471 | :conditions => ["#{versioned_foreign_key} = ?", id], |
|
473 | :conditions => ["#{versioned_foreign_key} = ?", id], | |
472 | :order => 'version' }.merge(options) |
|
474 | :order => 'version' }.merge(options)) | |
473 | end |
|
475 | end | |
474 |
|
476 | |||
475 | # Returns an array of columns that are versioned. See non_versioned_columns |
|
477 | # Returns an array of columns that are versioned. See non_versioned_columns |
@@ -30,7 +30,7 task :migrate_from_mantis => :environment do | |||||
30 | assigned_status = IssueStatus.find_by_position(2) |
|
30 | assigned_status = IssueStatus.find_by_position(2) | |
31 | resolved_status = IssueStatus.find_by_position(3) |
|
31 | resolved_status = IssueStatus.find_by_position(3) | |
32 | feedback_status = IssueStatus.find_by_position(4) |
|
32 | feedback_status = IssueStatus.find_by_position(4) | |
33 |
closed_status = IssueStatus. |
|
33 | closed_status = IssueStatus.where(:is_closed => true).first | |
34 | STATUS_MAPPING = {10 => DEFAULT_STATUS, # new |
|
34 | STATUS_MAPPING = {10 => DEFAULT_STATUS, # new | |
35 | 20 => feedback_status, # feedback |
|
35 | 20 => feedback_status, # feedback | |
36 | 30 => DEFAULT_STATUS, # acknowledged |
|
36 | 30 => DEFAULT_STATUS, # acknowledged | |
@@ -347,7 +347,7 task :migrate_from_mantis => :environment do | |||||
347 | bug.bug_files.each do |file| |
|
347 | bug.bug_files.each do |file| | |
348 | a = Attachment.new :created_on => file.date_added |
|
348 | a = Attachment.new :created_on => file.date_added | |
349 | a.file = file |
|
349 | a.file = file | |
350 |
a.author = User. |
|
350 | a.author = User.first | |
351 | a.container = i |
|
351 | a.container = i | |
352 | a.save |
|
352 | a.save | |
353 | end |
|
353 | end |
@@ -30,7 +30,7 namespace :redmine do | |||||
30 | assigned_status = IssueStatus.find_by_position(2) |
|
30 | assigned_status = IssueStatus.find_by_position(2) | |
31 | resolved_status = IssueStatus.find_by_position(3) |
|
31 | resolved_status = IssueStatus.find_by_position(3) | |
32 | feedback_status = IssueStatus.find_by_position(4) |
|
32 | feedback_status = IssueStatus.find_by_position(4) | |
33 |
closed_status = IssueStatus. |
|
33 | closed_status = IssueStatus.where(:is_closed => true).first | |
34 | STATUS_MAPPING = {'new' => DEFAULT_STATUS, |
|
34 | STATUS_MAPPING = {'new' => DEFAULT_STATUS, | |
35 | 'reopened' => feedback_status, |
|
35 | 'reopened' => feedback_status, | |
36 | 'assigned' => assigned_status, |
|
36 | 'assigned' => assigned_status, |
@@ -45,7 +45,7 class AccountTest < ActionController::IntegrationTest | |||||
45 | # User logs in with 'autologin' checked |
|
45 | # User logs in with 'autologin' checked | |
46 | post '/login', :username => user.login, :password => 'admin', :autologin => 1 |
|
46 | post '/login', :username => user.login, :password => 'admin', :autologin => 1 | |
47 | assert_redirected_to '/my/page' |
|
47 | assert_redirected_to '/my/page' | |
48 |
token = Token. |
|
48 | token = Token.first | |
49 | assert_not_nil token |
|
49 | assert_not_nil token | |
50 | assert_equal user, token.user |
|
50 | assert_equal user, token.user | |
51 | assert_equal 'autologin', token.action |
|
51 | assert_equal 'autologin', token.action |
@@ -877,7 +877,7 class IssueTest < ActiveSupport::TestCase | |||||
877 |
|
877 | |||
878 | # Closing issue 1 |
|
878 | # Closing issue 1 | |
879 | issue1.init_journal(User.first, "Closing issue1") |
|
879 | issue1.init_journal(User.first, "Closing issue1") | |
880 |
issue1.status = IssueStatus. |
|
880 | issue1.status = IssueStatus.where(:is_closed => true).first | |
881 | assert issue1.save |
|
881 | assert issue1.save | |
882 | # 2 and 3 should be also closed |
|
882 | # 2 and 3 should be also closed | |
883 | assert issue2.reload.closed? |
|
883 | assert issue2.reload.closed? | |
@@ -896,7 +896,7 class IssueTest < ActiveSupport::TestCase | |||||
896 |
|
896 | |||
897 | # Closing issue 2 |
|
897 | # Closing issue 2 | |
898 | issue2.init_journal(User.first, "Closing issue2") |
|
898 | issue2.init_journal(User.first, "Closing issue2") | |
899 |
issue2.status = IssueStatus. |
|
899 | issue2.status = IssueStatus.where(:is_closed => true).first | |
900 | assert issue2.save |
|
900 | assert issue2.save | |
901 | # 1 should not be also closed |
|
901 | # 1 should not be also closed | |
902 | assert !issue1.reload.closed? |
|
902 | assert !issue1.reload.closed? |
General Comments 0
You need to be logged in to leave comments.
Login now