Permalink
Browse files

Update most of the AR query syntax to the rails3 syntax, fix image ro…

…utes, change pagination from paginating_find to will_paginate.
  • Loading branch information...
1 parent 86f288f commit f42a7e32da993aca188fccfc8008c8674c05ab79 @jamesu committed Aug 21, 2011
Showing with 126 additions and 1,247 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +10 −10 app/assets/stylesheets/general/construction.css
  4. +2 −2 app/assets/stylesheets/general/rewrites.css
  5. +8 −10 app/controllers/categories_controller.rb
  6. +1 −1 app/controllers/configurations_controller.rb
  7. +1 −1 app/controllers/dashboard_controller.rb
  8. +6 −7 app/controllers/files_controller.rb
  9. +6 −7 app/controllers/folders_controller.rb
  10. +9 −11 app/controllers/messages_controller.rb
  11. +1 −1 app/controllers/projects_controller.rb
  12. +2 −2 app/controllers/task_lists_controller.rb
  13. +1 −1 app/controllers/tasks_controller.rb
  14. +9 −10 app/controllers/times_controller.rb
  15. +1 −1 app/controllers/users_controller.rb
  16. +3 −3 app/helpers/application_helper.rb
  17. +2 −2 app/models/attached_file.rb
  18. +1 −1 app/models/company.rb
  19. +1 −1 app/models/im_type.rb
  20. +21 −20 app/models/project.rb
  21. +6 −2 app/models/project_file.rb
  22. +1 −1 app/models/project_file_revision.rb
  23. +4 −6 app/models/project_milestone.rb
  24. +4 −2 app/models/project_time.rb
  25. +1 −1 app/models/user.rb
  26. +1 −1 app/views/layouts/_application_logs.html.erb
  27. +1 −1 app/views/projects/_permissions.html.erb
  28. +1 −1 app/views/times/by_task.html.erb
  29. +1 −1 app/views/times/index.html.erb
  30. +3 −1 config/routes.rb
  31. +4 −4 db/migrate/009_new_timezone.rb
  32. +3 −3 db/migrate/014_paperclip_files.rb
  33. +2 −2 db/migrate/015_longer_country.rb
  34. +1 −1 db/migrate_basecamp.rb
  35. +1 −1 lib/authenticated_system.rb
  36. +1 −1 lib/login_system.rb
  37. +1 −1 test/unit/company_test.rb
  38. +0 −93 vendor/plugins/paginating_find/CHANGELOG
  39. +0 −88 vendor/plugins/paginating_find/README
  40. +0 −2 vendor/plugins/paginating_find/init.rb
  41. +0 −125 vendor/plugins/paginating_find/lib/paginating_find.rb
  42. +0 −147 vendor/plugins/paginating_find/lib/paging_enumerator.rb
  43. +0 −47 vendor/plugins/paginating_find/lib/paging_helper.rb
  44. +0 −10 vendor/plugins/paginating_find/test_app/Rakefile
  45. +0 −2 vendor/plugins/paginating_find/test_app/app/controllers/application.rb
  46. +0 −44 vendor/plugins/paginating_find/test_app/config/boot.rb
  47. +0 −6 vendor/plugins/paginating_find/test_app/config/database.yml
  48. +0 −53 vendor/plugins/paginating_find/test_app/config/environment.rb
  49. +0 −19 vendor/plugins/paginating_find/test_app/config/environments/test.rb
  50. +0 −22 vendor/plugins/paginating_find/test_app/config/routes.rb
  51. +0 −16 vendor/plugins/paginating_find/test_app/db/schema.rb
  52. +0 −3 vendor/plugins/paginating_find/test_app/script/breakpointer
  53. +0 −3 vendor/plugins/paginating_find/test_app/script/console
  54. +0 −19 vendor/plugins/paginating_find/test_app/test/fixtures/articles.yml
  55. +0 −7 vendor/plugins/paginating_find/test_app/test/fixtures/authors.yml
  56. +0 −11 vendor/plugins/paginating_find/test_app/test/fixtures/edits.yml
  57. +0 −14 vendor/plugins/paginating_find/test_app/test/fixtures/models.rb
  58. +0 −33 vendor/plugins/paginating_find/test_app/test/test_helper.rb
  59. +0 −7 vendor/plugins/paginating_find/test_app/test/unit/abstract_test.rb
  60. +0 −29 vendor/plugins/paginating_find/test_app/test/unit/group_test.rb
  61. +0 −181 vendor/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb
  62. +0 −143 vendor/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb
  63. +2 −2 vendor/plugins/ssl_requirement/lib/ssl_requirement.rb
View
@@ -8,6 +8,7 @@ gem 'haml'
gem 'uglifier'
gem 'paperclip'
gem 'dynamic_form'
+gem 'will_paginate', '~> 3.0'
#group :test, :development do
# gem 'rspec-rails', '~> 2.3.1'
View
@@ -111,6 +111,7 @@ GEM
uglifier (0.5.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ will_paginate (3.0.0)
PLATFORMS
java
@@ -128,3 +129,4 @@ DEPENDENCIES
sqlite3
therubyracer-heroku (= 0.8.1.pre3)
uglifier
+ will_paginate (~> 3.0)
@@ -130,14 +130,14 @@ body {
#tabs ul li {
margin: 0 1px;
float: left;
- background: url('../../images/layout/tab_right.gif') no-repeat top right;
+ background: url('../../assets/layout/tab_right.gif') no-repeat top right;
}
#tabs ul li a {
border: 0;
display: block;
padding: 2px 12px;
- background: url('../../images/layout/tab_left.gif') no-repeat top left;
+ background: url('../../assets/layout/tab_left.gif') no-repeat top left;
text-align: center;
color: #333;
font-size: 10px;
@@ -153,11 +153,11 @@ body {
}
#tabs ul li.active {
- background: url('../../images/layout/tab_active_right.gif') no-repeat top right;
+ background: url('../../assets/layout/tab_active_right.gif') no-repeat top right;
}
#tabs ul li.active a {
- background: url('../../images/layout/tab_active_left.gif') no-repeat top left;
+ background: url('../../assets/layout/tab_active_left.gif') no-repeat top left;
color: white;
}
@@ -250,7 +250,7 @@ body {
#outerContentWrapper {
clear: both;
- background: url('../../images/layout/content-back.gif') repeat-x;
+ background: url('../../assets/layout/content-back.gif') repeat-x;
}
#innerContentWrapper {
@@ -331,7 +331,7 @@ body {
padding: 0 15px 0 0;
color: #444;
text-decoration: underline;
- background: url('../../images/icons/more_down.gif') no-repeat right bottom;
+ background: url('../../assets/icons/more_down.gif') no-repeat right bottom;
}
#page_actions ul li a:hover {
@@ -377,7 +377,7 @@ body {
#listOfRssFeeds li {
padding-left: 16px;
- background: url('../../images/icons/feed.gif') no-repeat;
+ background: url('../../assets/icons/feed.gif') no-repeat;
line-height: 12px;
margin: 2px 0;
}
@@ -483,11 +483,11 @@ div.private {
width: 37px;
overflow: hidden;
margin-left: 2px;
- background: url('../../images/icons/private.gif') no-repeat;
+ background: url('../../assets/icons/private.gif') no-repeat;
}
#pageTitle.private {
- background: url('../../images/icons/private.gif') no-repeat;
+ background: url('../../assets/icons/private.gif') no-repeat;
}
div.private span {
@@ -502,7 +502,7 @@ div.billable {
width: 37px;
overflow: hidden;
margin-left: 2px;
- background: url('../../images/icons/billable.gif') no-repeat;
+ background: url('../../assets/icons/billable.gif') no-repeat;
}
div.billable span {
@@ -308,11 +308,11 @@ a.selected {
}
a.iCalSubscribe {
- background: url('../../images/icons/icalendar.png') no-repeat;
+ background: url('../../assets/icons/icalendar.png') no-repeat;
padding: 4px 0 0 20px;
}
a.csvExport {
- background: url('../../images/icons/csv.png') no-repeat;
+ background: url('../../assets/icons/csv.png') no-repeat;
padding: 4px 0 0 20px;
}
@@ -189,27 +189,25 @@ def posts
@content_for_sidebar = 'messages/index_sidebar'
@page = params[:page].to_i
- @page = 0 unless @page > 0
+ @page = 1 unless @page > 0
- @messages = @category.project_messages.find(:all,
- :conditions => msg_conditions,
- :page => {:size => Rails.configuration.messages_per_page, :current => @page})
+ @messages = @category.project_messages.where(msg_conditions)
+ .paginate(:page => @page, :per_page => Rails.configuration.messages_per_page)
@pagination = []
- @messages.page_count.times {|page| @pagination << page+1}
+ @messages.total_pages.times {|page| @pagination << page+1}
# Important messages (html only)
important_conditions = {'is_important' => true}
important_conditions['is_private'] = false unless @logged_user.member_of_owner?
- @important_messages = @active_project.project_messages.find(:all, :conditions => important_conditions)
+ @important_messages = @active_project.project_messages.where(important_conditions)
render :template => 'messages/index'
}
format.xml {
- @messages = @category.project_messages.find(:all,
- :conditions => msg_conditions,
- :offset => params[:offset],
- :limit => params[:limit] || Rails.configuration.messages_per_page)
+ @messages = @category.project_messages.where(msg_conditions)
+ .offset(params[:offset])
+ .limit(params[:limit] || Rails.configuration.messages_per_page)
render :xml => @messages.to_xml(:only => [:id,
:title,
@@ -51,7 +51,7 @@ def update
protected
def find_categories
sys_conds = params[:system] ? [] : ['is_system = ?', false]
- @categories = ConfigCategory.all(:conditions => sys_conds, :order => 'category_order DESC')
+ @categories = ConfigCategory.where(sys_conds).order('category_order DESC')
end
def find_category
@@ -32,7 +32,7 @@ def index
{ :project_id => project_ids } :
{ :project_id => project_ids, :is_private => false }
- @activity_log = ApplicationLog.all(:conditions => activity_conditions, :order => 'created_on DESC, id DESC', :limit => Rails.configuration.project_logs_per_page)
+ @activity_log = ApplicationLog.where(activity_conditions).order('created_on DESC, id DESC').limit(Rails.configuration.project_logs_per_page)
else
@activity_log = []
end
@@ -48,21 +48,20 @@ def index
@content_for_sidebar = 'index_sidebar'
@page = params[:page].to_i
- @page = 0 unless @page > 0
+ @page = 1 unless @page > 0
- result_set, @files = ProjectFile.find_grouped(sort_type, :conditions => file_conditions, :page => {:size => Rails.configuration.files_per_page, :current => @page}, :order => "#{sort_type} #{sort_order}")
+ result_set, @files = ProjectFile.find_grouped(sort_type, :conditions => file_conditions, :page => @page, :per_page => Rails.configuration.files_per_page, :order => "#{sort_type} #{sort_order}")
@pagination = []
- result_set.page_count.times {|page| @pagination << page+1}
+ result_set.total_pages.times {|page| @pagination << page+1}
# Important files and folders (html only)
@important_files = @active_project.project_files.important(@logged_user.member_of_owner?)
@folders = @active_project.project_folders
}
format.xml {
- @files = ProjectFile.find(:all,
- :conditions => file_conditions,
- :offset => params[:offset],
- :limit => params[:limit] || Rails.configuration.files_per_page)
+ @files = ProjectFile.where(file_conditions)
+ .offset(params[:offset])
+ .limit(params[:limit] || Rails.configuration.files_per_page)
render :xml => @files.to_xml(:only => [:id,
:filename,
@@ -157,11 +157,11 @@ def files
@content_for_sidebar = 'files/index_sidebar'
@page = params[:page].to_i
- @page = 0 unless @page > 0
+ @page = 1 unless @page > 0
- result_set, @files = ProjectFile.find_grouped(sort_type, :conditions => file_conditions, :page => {:size => Rails.configuration.files_per_page, :current => @page}, :order => "#{sort_type} #{sort_order}")
+ result_set, @files = ProjectFile.find_grouped(sort_type, :conditions => file_conditions, :page => @page, :per_page => Rails.configuration.files_per_page, :order => "#{sort_type} #{sort_order}")
@pagination = []
- result_set.page_count.times {|page| @pagination << page+1}
+ result_set.total_pages.times {|page| @pagination << page+1}
# Important files and folders (html only)
@important_files = @active_project.project_files.important(@logged_user.member_of_owner?)
@@ -170,10 +170,9 @@ def files
render :template => 'files/index'
}
format.xml {
- @files = ProjectFile.find(:all,
- :conditions => file_conditions,
- :offset => params[:offset],
- :limit => params[:limit] || Rails.configuration.files_per_page)
+ @files = ProjectFile.where(file_conditions)
+ .offset(params[:offset])
+ .limit(params[:limit] || Rails.configuration.files_per_page)
render :xml => @files.to_xml(:only => [:id,
:filename,
@@ -58,28 +58,26 @@ def index
@content_for_sidebar = 'index_sidebar'
@page = params[:page].to_i
- @page = 0 unless @page > 0
+ @page = 1 unless @page > 0
- @messages = @active_project.project_messages.find(:all,
- :conditions => msg_conditions,
- :page => {:size => Rails.configuration.messages_per_page, :current => @page})
+ @messages = @active_project.project_messages.where(msg_conditions)
+ .paginate(:page => @page+1, :per_page => Rails.configuration.messages_per_page)
@pagination = []
- @messages.page_count.times {|page| @pagination << page+1}
+ @messages.total_pages.times {|page| @pagination << page+1}
# Important messages (html only)
important_conditions = {'is_important' => true}
important_conditions['category_id'] = @category.id unless @category.nil?
important_conditions['is_private'] = false unless @logged_user.member_of_owner?
- @important_messages = @active_project.project_messages.find(:all, :conditions => important_conditions)
+ @important_messages = @active_project.project_messages.where(important_conditions)
render :template => 'messages/index'
}
format.xml {
- @messages = @active_project.project_messages.find(:all,
- :conditions => msg_conditions,
- :offset => params[:offset],
- :limit => params[:limit] || Rails.configuration.messages_per_page)
+ @messages = @active_project.project_messages.where(msg_conditions)
+ .offset(params[:offset])
+ .limit(params[:limit] || Rails.configuration.messages_per_page)
render :xml => @messages.to_xml(:root => 'messages')
}
end
@@ -123,7 +121,7 @@ def new
if @category
@message.category_id = @category.id
else
- @category = @active_project.project_message_categories.find(:first, :conditions => ['name = ?', Rails.configuration.default_project_message_category])
+ @category = @active_project.project_message_categories.where(:conditions => ['name = ?', Rails.configuration.default_project_message_category]).first
end
@message.comments_enabled = true unless (params[:message] and params[:message].has_key?(:comments_enabled))
@@ -27,7 +27,7 @@ class ProjectsController < ApplicationController
after_filter :user_track, :only => [:index, :search, :people]
def index
- @projects = @logged_user.is_admin ? Project.find(:all) : @logged_user.projects
+ @projects = @logged_user.is_admin ? Project.all : @logged_user.projects
respond_to do |format|
format.html { render :layout => 'administration' }
format.xml {
@@ -38,8 +38,8 @@ def index
render :template => 'task_lists/index'
}
format.xml {
- conds = include_private ? {} : {'is_private', false}
- @task_lists = @active_project.project_task_lists.find(:all, :conditions => conds)
+ conds = include_private ? {} : {'is_private' => false}
+ @task_lists = @active_project.project_task_lists.where(conds)
render :xml => @task_lists.to_xml(:root => 'task-lists')
}
end
@@ -37,7 +37,7 @@ def index
@content_for_sidebar = 'task_lists/index_sidebar'
}
format.xml {
- @tasks = @task_list.project_tasks.find(:all)
+ @tasks = @task_list.project_tasks
render :xml => @tasks.to_xml(:root => 'tasks')
}
end
@@ -40,20 +40,19 @@ def index
@project = @active_project
@content_for_sidebar = 'index_sidebar'
- @times = @project.project_times.find(:all,
- :conditions => @time_conditions,
- :page => {:size => Rails.configuration.times_per_page, :current => @current_page},
- :order => "#{@sort_type} #{@sort_order}")
+ @times = @project.project_times.where(@time_conditions)
+ .paginate(:page => @current_page, :per_page => Rails.configuration.times_per_page)
+ .order("#{@sort_type} #{@sort_order}")
@pagination = []
- @times.page_count.times {|page| @pagination << page+1}
+ @times.total_pages.times {|page| @pagination << page+1}
}
format.xml {
- @times = @project.project_times.find(:all, :conditions => @time_conditions,
- :offset => params[:offset],
- :limit => params[:limit] || Rails.configuration.times_per_page,
- :order => "#{@sort_type} #{@sort_order}")
+ @times = @project.project_times.where(@time_conditions)
+ .offset(params[:offset])
+ .limit(params[:limit] || Rails.configuration.times_per_page)
+ .order("#{@sort_type} #{@sort_order}")
render :xml => @times.to_xml(:root => 'times')
}
@@ -200,7 +199,7 @@ def obtain_time
def prepare_times
@current_page = params[:page].to_i
- @current_page = 0 unless @current_page > 0
+ @current_page = 1 unless @current_page > 0
@time_conditions = @logged_user.member_of_owner? ? {} : {'is_private' => false}
@sort_type = params[:orderBy]
@@ -32,7 +32,7 @@ def index
}
format.xml {
if @logged_user.is_admin
- @users = User.find(:all)
+ @users = User.all
render :xml => @users.to_xml(:root => 'user')
else
return error_status(true, :insufficient_permissions)
@@ -34,11 +34,11 @@ def pagination_links(url, ids)
end
def icon_url(filename)
- "/images/icons/#{filename}.gif"
+ "/assets/icons/#{filename}.gif"
end
def checkbox_link(link, checked=false, hint=nil, attrs={})
- icon_url = checked ? "/images/icons/checked.gif" : "/images/icons/not-checked.gif"
+ icon_url = checked ? "/assets/icons/checked.gif" : "/assets/icons/not-checked.gif"
method = attrs[:method] || :post
link_to "<img src='#{icon_url}' alt='' />".html_safe, link, attrs.merge({:method => method, :class => 'checkboxLink', :title => ( hint.nil? ? '' : (html_escape hint) )})
@@ -47,7 +47,7 @@ def checkbox_link(link, checked=false, hint=nil, attrs={})
def render_icon(filename, alt, attrs={})
attr_values = attrs.keys.collect{ |a| "#{a}='#{attrs[a]}'" }.join(' ')
- "<img src='/images/icons/#{filename}.gif' alt='#{alt}' #{attr_values}/>".html_safe
+ "<img src='/assets/icons/#{filename}.gif' alt='#{alt}' #{attr_values}/>".html_safe
end
def action_list(actions)
@@ -29,7 +29,7 @@ def self.clear_attachment(object, attach_id)
object.id,
attach_id]
- AttachedFile.find(:all, :conditions => conds).each do |attach|
+ AttachedFile.where(conds).each do |attach|
if !attach.project_file.nil? and !attach.project_file.is_visible and attach.project_file.attached_files.length <= 1
attach.project_file.destroy
end
@@ -43,7 +43,7 @@ def self.clear_attachments(object)
object.class.to_s,
object.id]
- AttachedFile.find(:all, :conditions => conds).each do |attach|
+ AttachedFile.where(conds).each do |attach|
if !attach.project_file.nil? and !attach.project_file.is_visible and attach.project_file.attached_files.length <= 1
AttachedFile.delete_all(['rel_object_type = ? AND rel_object_id = ? AND file_id = ?',
object.class.to_s,
View
@@ -112,7 +112,7 @@ def has_logo?
def logo_url
if !logo?
- "/themes/#{Rails.configuration.site_theme}/images/logo.gif"
+ "/assets/logo.gif"
else
logo.url(:thumb)
end
Oops, something went wrong.

0 comments on commit f42a7e3

Please sign in to comment.