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 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 end

View file

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