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