]> git.openstreetmap.org Git - rails.git/commitdiff
Make the message reply link prefill the title with "Re: original title".
authorTom Hughes <tom@compton.nu>
Tue, 15 Jan 2008 19:05:17 +0000 (19:05 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 15 Jan 2008 19:05:17 +0000 (19:05 +0000)
Closes #634.

app/controllers/message_controller.rb
app/models/notifier.rb
app/views/message/_message_summary.rhtml
app/views/message/new.rhtml
app/views/message/read.rhtml
config/routes.rb

index b54fdf9d131db521ed3c8b6a40b4156393b6dc35..9dc1d69229348291b9da97d5d9a7bd724c7ad210 100644 (file)
@@ -20,6 +20,14 @@ class MessageController < ApplicationController
     end
   end
 
+  def reply
+    message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
+    title = message.title.sub(/^Re:\s*/, "Re: ")
+    redirect_to :action => 'new', :user_id => message.from_user_id, :title => title
+  rescue ActiveRecord::RecordNotFound
+    render :nothing => true, :status => :not_found
+  end
+
   def read
     @title = 'read message'
     @message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
index bc4db6477ecc1c4295199b2d83b51ca6e456674a..f934a8bde42a6a95939fd81c7ea2495cb8018f42 100644 (file)
@@ -59,8 +59,8 @@ class Notifier < ActionMailer::Base
                              :controller => "message", :action => "read",
                              :message_id => message.id),
          :replyurl => url_for(:host => SERVER_URL,
-                              :controller => "message", :action => "new",
-                              :user_id => message.from_user_id)
+                              :controller => "message", :action => "reply",
+                              :message_id => message.id)
   end
 
   def friend_notification(friend)
index d1604e9b5425193b4f8d62186128f2d794a4b9a5..381a6cce1d6ea2d4d7a135af4bd38b887ccc8594 100644 (file)
@@ -9,5 +9,5 @@
   <% else %>
     <td><%= button_to 'Mark as read', :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %></td>
   <% end %>
-  <td><%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => message_summary.from_user_id %></td>
+  <td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => message_summary.id %></td>
 </tr>
index 27c50132218e0388d7e27fba2eea93c0eb81d360..84b3bfdc880f030a877cce5ccc0164c73637f96a 100644 (file)
@@ -1,4 +1,5 @@
-<% display_name = (User.find_by_id(params[:user_id])).display_name %>
+<% display_name = User.find_by_id(params[:user_id]).display_name %>
+<% title = params[:message] ? params[:message][:title] : params[:title] %>
 
 <h2>Send a new message to <%= display_name %></h2>
 
@@ -13,7 +14,7 @@
   <table>
     <tr valign="top">
       <th>Subject</th>
-      <td><%= f.text_field :title, :size => 60 %></td>
+      <td><%= text_field_tag 'message[title]', title, :size => 60 %></td>
     </tr>
     <tr valign="top">
       <th>Body</th>
index b3dcd1f23a84d3fb562c7603bef3b444e73f22bf..d0517d0bfbb0b76d2dd743e64427a6b259643e99 100644 (file)
@@ -25,7 +25,7 @@
 
 <table>
   <tr>
-    <td><%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => @message.from_user_id %></td>
+    <td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => @message.id %></td>
     <td><%= button_to 'Mark as unread', :controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread' %></td>
     <td><%= link_to 'Back to inbox', :controller => 'message', :action => 'inbox', :display_name => @user.display_name %></td>
   </tr>
index dce4042de6589f8c316cc6bb5b9c8274bce904cf..3cfc519770db310833ac10bfd53d3feaf089a58c 100644 (file)
@@ -122,7 +122,8 @@ ActionController::Routing::Routes.draw do |map|
   map.connect '/message/new/:user_id', :controller => 'message', :action => 'new'
   map.connect '/message/read/:message_id', :controller => 'message', :action => 'read'
   map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark'
-  
+  map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply'
+
   # fall through
      map.connect ':controller/:id/:action'
   map.connect ':controller/:action'