summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-12-10 17:58:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-12-10 17:58:07 +0000
commit6d9490ddcc9c501d31a8b403146cd4ba6d8cc5b5 (patch)
treead4a6a8cbc3ec2dadf61886a67c19ffc66ec6710 /app
parentf58db70bdecdbfd0a0d81c0c452d58b88391f9f1 (diff)
downloadredmine-6d9490ddcc9c501d31a8b403146cd4ba6d8cc5b5.tar.gz
redmine-6d9490ddcc9c501d31a8b403146cd4ba6d8cc5b5.zip
Merged Rails 2.0 compatibility changes.
Compatibility with Rails 1.2 is preserved. git-svn-id: http://redmine.rubyforge.org/svn/trunk@975 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/search_controller.rb7
-rw-r--r--app/models/mailer.rb7
-rw-r--r--app/models/project.rb9
-rw-r--r--app/views/mailer/issue_add.text.html.rhtml2
-rw-r--r--app/views/mailer/issue_add.text.plain.rhtml2
-rw-r--r--app/views/mailer/issue_edit.text.html.rhtml2
-rw-r--r--app/views/mailer/issue_edit.text.plain.rhtml2
7 files changed, 22 insertions, 9 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index ee4f863aa..69e1ee503 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -90,9 +90,10 @@ class SearchController < ApplicationController
end
else
operator = @all_words ? ' AND ' : ' OR '
- Project.with_scope(:find => {:conditions => Project.visible_by(User.current)}) do
- @results += Project.find(:all, :limit => limit, :conditions => [ (["(LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects'
- end
+ @results += Project.find(:all,
+ :limit => limit,
+ :conditions => [ (["(#{Project.visible_by(User.current)}) AND (LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort]
+ ) if @scope.include? 'projects'
# if only one project is found, user is redirected to its overview
redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 9639e1a9c..257f57726 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -150,6 +150,11 @@ class Mailer < ActionMailer::Base
def render_message(method_name, body)
layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
body[:content_for_layout] = render(:file => method_name, :body => body)
- ActionView::Base.new(File.join(template_root, 'mailer'), body, self).render(:file => layout)
+ ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}")
end
+
+ # Makes partial rendering work with Rails 1.2 (retro-compatibility)
+ def self.controller_path
+ ''
+ end unless respond_to?('controller_path')
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 5788732d7..70b1eccd1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
STATUS_ACTIVE = 1
STATUS_ARCHIVED = 9
- has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
+ has_many :members, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
has_many :users, :through => :members
has_many :custom_values, :dependent => :delete_all, :as => :customized
has_many :enabled_modules, :dependent => :delete_all
@@ -62,6 +62,8 @@ class Project < ActiveRecord::Base
validates_length_of :identifier, :in => 3..20
validates_format_of :identifier, :with => /^[a-z0-9\-]*$/
+ before_destroy :delete_all_members
+
def identifier=(identifier)
super unless identifier_frozen?
end
@@ -129,6 +131,11 @@ class Project < ActiveRecord::Base
children.select {|child| child.active?}
end
+ # Deletes all project's members
+ def delete_all_members
+ Member.delete_all(['project_id = ?', id])
+ end
+
# Users issues can be assigned to
def assignable_users
members.select {|m| m.role.assignable?}.collect {|m| m.user}.sort
diff --git a/app/views/mailer/issue_add.text.html.rhtml b/app/views/mailer/issue_add.text.html.rhtml
index adcb4c9fe..6d20c333f 100644
--- a/app/views/mailer/issue_add.text.html.rhtml
+++ b/app/views/mailer/issue_add.text.html.rhtml
@@ -1,3 +1,3 @@
<%= l(:text_issue_added, "##{@issue.id}") %>
<hr />
-<%= render :file => "_issue_text_html", :use_full_path => true, :locals => { :issue => @issue, :issue_url => @issue_url } %>
+<%= render :partial => "issue_text_html", :locals => { :issue => @issue, :issue_url => @issue_url } %>
diff --git a/app/views/mailer/issue_add.text.plain.rhtml b/app/views/mailer/issue_add.text.plain.rhtml
index 797fb11b6..38c17e777 100644
--- a/app/views/mailer/issue_add.text.plain.rhtml
+++ b/app/views/mailer/issue_add.text.plain.rhtml
@@ -1,3 +1,3 @@
<%= l(:text_issue_added, "##{@issue.id}") %>
----------------------------------------
-<%= render :file => "_issue_text_plain", :use_full_path => true, :locals => { :issue => @issue, :issue_url => @issue_url } %>
+<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>
diff --git a/app/views/mailer/issue_edit.text.html.rhtml b/app/views/mailer/issue_edit.text.html.rhtml
index 40d34968e..9af8592b4 100644
--- a/app/views/mailer/issue_edit.text.html.rhtml
+++ b/app/views/mailer/issue_edit.text.html.rhtml
@@ -7,4 +7,4 @@
</ul>
<%= textilizable(@journal.notes) %>
<hr />
-<%= render :file => "_issue_text_html", :use_full_path => true, :locals => { :issue => @issue, :issue_url => @issue_url } %>
+<%= render :partial => "issue_text_html", :locals => { :issue => @issue, :issue_url => @issue_url } %>
diff --git a/app/views/mailer/issue_edit.text.plain.rhtml b/app/views/mailer/issue_edit.text.plain.rhtml
index 32019eaea..04b1bc54a 100644
--- a/app/views/mailer/issue_edit.text.plain.rhtml
+++ b/app/views/mailer/issue_edit.text.plain.rhtml
@@ -5,4 +5,4 @@
<% end %>
<%= @journal.notes if @journal.notes? %>
----------------------------------------
-<%= render :file => "_issue_text_plain", :use_full_path => true, :locals => { :issue => @issue, :issue_url => @issue_url } %>
+<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>