dmails: replace hard deletions with soft deletions.

Turn deletions into soft deletions (set the is_deleted flag) instead of
hard deletions (remove from database). The is_deleted flag actually
already existed, but it was never used before.
This commit is contained in:
evazion
2020-01-30 21:49:55 -06:00
parent 5df8d08aae
commit f8db577c25
7 changed files with 26 additions and 24 deletions

View File

@@ -4,6 +4,7 @@
<%= subnav_link_to "Received", received_dmails_path(set_default_folder: true) %>
<%= subnav_link_to "Sent", sent_dmails_path(set_default_folder: true) %>
<%= subnav_link_to "Spam", spam_dmails_path %>
<%= subnav_link_to "Deleted", dmails_path(search: { is_deleted: true }) %>
<li>|</li>
<%= subnav_link_to "New", new_dmail_path %>
<%= subnav_link_to "Mark all as read", {:controller => "dmails", :action => "mark_all_as_read"}, :method => :post, :remote => true %></li>

View File

@@ -27,7 +27,14 @@
<%= link_to dmail.title, dmail_path(dmail) %>
<% end %>
<% t.column do |dmail| %>
<%= link_to "delete", dmail_path(dmail), :method => :delete, :data => {:confirm => "Are you sure you want to delete this Dmail?"} %>
<% if dmail.is_deleted? %>
<%= link_to "Undelete", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_deleted]=false" %>
<% else %>
<%= link_to "Delete", dmail_path(dmail, format: :js), remote: true, method: :put, "data-params": "dmail[is_deleted]=true", "data-confirm": "Are you sure you want to delete this dmail?" %>
<% end %>
<% if dmail.reportable_by?(CurrentUser.user) %>
| <%= link_to "Report", new_moderation_report_path(moderation_report: { model_type: "Dmail", model_id: dmail.id }), remote: true, title: "Report this dmail to the moderators" %>
<% end %>
<% end %>
<% end %>