This commit is contained in:
albert
2012-01-13 18:28:01 -05:00
parent 28212516df
commit a3821d0397
5 changed files with 10 additions and 3 deletions

View File

@@ -5,6 +5,10 @@ div#c-dmails {
max-width: 50em; max-width: 50em;
} }
tr.read-false {
font-weight: bold;
}
div#preview { div#preview {
margin: 1em 0; margin: 1em 0;
border: 1px solid #CCC; border: 1px solid #CCC;

View File

@@ -27,6 +27,7 @@ class DmailsController < ApplicationController
def show def show
@dmail = Dmail.find(params[:id]) @dmail = Dmail.find(params[:id])
check_privilege(@dmail) check_privilege(@dmail)
@dmail.mark_as_read!
respond_with(@dmail) respond_with(@dmail)
end end

View File

@@ -49,7 +49,9 @@ class Dmail < ActiveRecord::Base
Dmail.transaction do Dmail.transaction do
copy = Dmail.new(params) copy = Dmail.new(params)
copy.owner_id = copy.to_id copy.owner_id = copy.to_id
copy.save! unless copy.to_id == CurrentUser.id
copy.save!
end
copy = Dmail.new(params) copy = Dmail.new(params)
copy.owner_id = CurrentUser.id copy.owner_id = CurrentUser.id

View File

@@ -1,6 +1,6 @@
<%= simple_form_for(dmail) do |f| %> <%= simple_form_for(dmail) do |f| %>
<%= f.input :to_name, :label => "To" %> <%= f.input :to_name, :label => "To" %>
<%= f.input :title %> <%= f.input :title, :as => :string %>
<%= dtext_field "dmail", "body" %> <%= dtext_field "dmail", "body" %>
<%= f.button :submit, "Send" %> <%= f.button :submit, "Send" %>
<%= dtext_preview_button "dmail", "body" %> <%= dtext_preview_button "dmail", "body" %>

View File

@@ -13,7 +13,7 @@
</thead> </thead>
<tbody> <tbody>
<% @dmails.each do |dmail| %> <% @dmails.each do |dmail| %>
<tr> <tr class="read-<%= dmail.is_read? %>">
<td><%= compact_time(dmail.created_at) %></td> <td><%= compact_time(dmail.created_at) %></td>
<td><%= link_to dmail.from_name, user_path(dmail.from) %></td> <td><%= link_to dmail.from_name, user_path(dmail.from) %></td>
<td><%= link_to dmail.to_name, user_path(dmail.to) %></td> <td><%= link_to dmail.to_name, user_path(dmail.to) %></td>