Restructure bounced mails view

This commit is contained in:
Karl Erik Õunapuu 2020-09-17 13:26:48 +03:00
parent 140df0acf7
commit 6af37a787d
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 55 additions and 28 deletions

View file

@ -1,2 +1,24 @@
class BouncedMailAddress < ApplicationRecord
validates :email, presence: true
validates :bounce_reason, presence: true
def diagnostic
response_json['diagnosticCode']
end
def action
response_json['action']
end
def status
response_json['status']
end
def self.record(json)
bounced_records = json['bounce']['bouncedRecipients']
bounced_records.each do |record|
bounce_record = BouncedMailAddress.new(email: record['emailAddress'], response_json: record)
bounce_record.save
end
end
end

View file

@ -2,14 +2,19 @@
<h1>Bounced Mail Addresses</h1>
<table>
<div class="row">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th>Email</th>
<th>Bounce reason</th>
<th>Incidents</th>
<th>Response json</th>
<th colspan="3"></th>
<th>Action</th>
<th>Status</th>
<th>Diagnostic</th>
<th>Tracked</th>
<th colspan="2">Actions</th>
</tr>
</thead>
@ -17,17 +22,17 @@
<% @bounced_mail_addresses.each do |mail_addr| %>
<tr>
<td><%= mail_addr.email %></td>
<td><%= mail_addr.bounce_reason %></td>
<td><%= mail_addr.incidents %></td>
<td><%= mail_addr.response_json %></td>
<td><%= link_to 'Show', admin_bounced_mail_address_path(mail_addr) %></td>
<td><%= link_to 'Edit', edit_admin_bounced_mail_address_path(mail_addr) %></td>
<td><%= mail_addr.action %></td>
<td><%= mail_addr.status %></td>
<td><%= mail_addr.diagnostic %></td>
<td><%= mail_addr.created_at %></td>
<td><%= link_to 'Detailed', admin_bounced_mail_address_path(mail_addr) %></td>
<td><%= link_to 'Destroy', admin_bounced_mail_address_path(mail_addr), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Bounced Mail Address', new_admin_bounced_mail_address_path %>
</table>
</div>
</div>
</div>
</div>