Merge pull request #2449 from internetee/2441-delete-auction

Admin: option to delete auction record
This commit is contained in:
Timo Võhmar 2022-10-06 10:51:35 +03:00 committed by GitHub
commit a64582c1a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 3 deletions

View file

@ -44,7 +44,7 @@ module Admin
if auction.save
reserved_domain = auction.domain if remove_from_reserved(auction)
flash[:notice] = "Auction #{params[:domain]} created.
flash[:notice] = "Auction #{params[:domain]} created.
#{reserved_domain.present? ? 'These domain will be removed from reserved list: ' + reserved_domain : ' '}"
else
flash[:alert] = 'Something goes wrong'
@ -53,6 +53,18 @@ module Admin
redirect_to admin_auctions_path
end
def destroy
auction = Auction.find(params[:id])
if auction.destroy
flash[:notice] = I18n.t('record_deleted')
else
flash.now[:alert] = I18n.t('failed_to_delete_record')
end
redirect_to admin_auctions_path
end
def upload_spreadsheet
if params[:q].nil?
flash[:alert] = 'No file upload! Look at the left of upload button!'

View file

@ -129,6 +129,7 @@
<td style="width: 100px !important; word-break: break-all;"><%= auction.registration_code %></td>
<td><%= auction.registration_deadline %></td>
<td><%= auction.platform.nil? ? 'auto' : auction.platform %></td>
<td><%= link_to(t(:delete), admin_auction_path(auction), method: :delete, data: { confirm: t(:are_you_sure_you_want_to_delete_auction) }, class: 'btn btn-danger', id: "delete-auction-#{auction.id}") %></td>
</tr>
<% end %>
</tbody>
@ -152,4 +153,4 @@
$('#user-form-edit').on("show.bs.modal", function(e) {
$(this).find('.modal-body').load(e.relatedTarget.dataset.url);
});
</script>
</script>