mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
fix issues
This commit is contained in:
parent
9766650ae4
commit
3b9ff74bd2
7 changed files with 66 additions and 14 deletions
|
@ -24,7 +24,7 @@ module Admin
|
|||
end
|
||||
|
||||
def create
|
||||
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: 'english')
|
||||
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: 'manually')
|
||||
|
||||
if auction.save
|
||||
remove_from_reserved(auction)
|
||||
|
@ -40,17 +40,40 @@ module Admin
|
|||
filename = params[:q][:file]
|
||||
table = CSV.parse(File.read(filename), headers: true)
|
||||
|
||||
table.each do |row|
|
||||
record = row.to_h
|
||||
auction = Auction.new(domain: record['name'], status: Auction.statuses[:started], platform: 'english')
|
||||
remove_from_reserved(auction) if auction.save!
|
||||
if validate_table(table)
|
||||
table.each do |row|
|
||||
record = row.to_h
|
||||
auction = Auction.new(domain: record['name'], status: Auction.statuses[:started], platform: 'manually')
|
||||
remove_from_reserved(auction) if auction.save!
|
||||
end
|
||||
flash[:notice] = "Domains added"
|
||||
redirect_to admin_auctions_path
|
||||
else
|
||||
flash[:alert] = "Invalid CSV format."
|
||||
redirect_to admin_auctions_path
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to admin_auctions_path
|
||||
def send_to_auction
|
||||
auction = Auction.find(params[:id])
|
||||
|
||||
p ">>>>>.."
|
||||
p auction
|
||||
p ">>>>>>"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_table(table)
|
||||
first_row = table.headers
|
||||
first_row[0] == 'id' &&
|
||||
first_row[1] == 'created_at' &&
|
||||
first_row[2] == 'updated_at' &&
|
||||
first_row[3] == 'creator_str' &&
|
||||
first_row[4] == 'updator_str' &&
|
||||
first_row[5] == 'name'
|
||||
end
|
||||
|
||||
def remove_from_reserved(auction)
|
||||
domain = ReservedDomain.find_by(name: auction.domain)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ module Admin
|
|||
reserved_domains = ReservedDomain.where(id: reserved_domains_ids)
|
||||
|
||||
reserved_domains.each do |domain|
|
||||
Auction.create!(domain: domain.name, status: Auction.statuses[:started], platform: 'english')
|
||||
Auction.create!(domain: domain.name, status: Auction.statuses[:started], platform: 'manually')
|
||||
domain.destroy!
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class Auction < ApplicationRecord
|
|||
domain_not_registered: 'domain_not_registered',
|
||||
}
|
||||
|
||||
enum platform: %i[blind english]
|
||||
enum platform: %i[automatically manually]
|
||||
|
||||
PENDING_STATUSES = [statuses[:started],
|
||||
statuses[:awaiting_payment],
|
||||
|
@ -21,6 +21,14 @@ class Auction < ApplicationRecord
|
|||
where(status: status) if status.present?
|
||||
}
|
||||
|
||||
scope :with_start_created_at_date, -> (start_created_at) {
|
||||
where("created_at >= ?", start_created_at) if start_created_at.present?
|
||||
}
|
||||
|
||||
scope :with_end_created_at_date, -> (end_created_at) {
|
||||
where("created_at <= ?", end_created_at) if end_created_at.present?
|
||||
}
|
||||
|
||||
def self.pending(domain_name)
|
||||
find_by(domain: domain_name.to_s, status: PENDING_STATUSES)
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module DNS
|
|||
def sell_at_auction
|
||||
auction = Auction.new
|
||||
auction.domain = name
|
||||
auction.platform = 'blind'
|
||||
auction.platform = 'automatically'
|
||||
auction.start
|
||||
ToStdout.msg "Created the auction: #{auction.inspect}"
|
||||
update_whois_from_auction(auction)
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
|
||||
</button>
|
||||
<div style="margin-right: 10px;">
|
||||
<%= link_to(t('.reset_btn'), admin_auctions_path, class: 'btn btn-default') %>
|
||||
<%= link_to('Clear', admin_auctions_path, class: 'btn btn-default') %>
|
||||
</div>
|
||||
<div style="margin-right: 10px;">
|
||||
<%= link_to 'Download auction list', admin_auctions_path(format: :csv, params: params.permit!),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
|
||||
"data-toggle" => "tooltip", "data-placement" => "bottom", "title" => 'Download CSV',
|
||||
class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<div >
|
||||
|
@ -114,10 +114,12 @@
|
|||
<th class="col-xs-2">
|
||||
<%= sort_link(@q, 'registration_deadline') %>
|
||||
</th>
|
||||
<th class="col-xs-2">
|
||||
<th class="col-xs-1">
|
||||
<%= sort_link(@q, 'type') %>
|
||||
</th>
|
||||
|
||||
<th class="col-xs-3">
|
||||
Action
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
@ -130,6 +132,11 @@
|
|||
<td><%= auction.registration_code %></td>
|
||||
<td><%= auction.registration_deadline %></td>
|
||||
<td><%= auction.platform %></td>
|
||||
<td>
|
||||
<%= button_tag type: 'button', data: { confirm: "Are you sure?" }, class: 'btn btn-primary' do %>
|
||||
<% link_to 'Send to auction', send_to_auction_admin_auction_path(auction), method: :post, style: "color: white;" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
@ -138,6 +145,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<%= paginate @auctions %>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<div class="pagination">
|
||||
<%= t(:result_count, count: @auctions.total_count) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#user-form-edit').on("show.bs.modal", function(e) {
|
||||
$(this).find('.modal-body').load(e.relatedTarget.dataset.url);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
%li= link_to t('.prices'), admin_prices_path
|
||||
%li= link_to t(:bank_statements), admin_bank_statements_path
|
||||
%li= link_to t(:invoices), admin_invoices_path
|
||||
%li= link_to t(:auctions), admin_auctions_path
|
||||
%li= link_to t(:accounts), admin_accounts_path
|
||||
%li= link_to t(:account_activities), admin_account_activities_path(created_after: 'today')
|
||||
%li.divider
|
||||
|
@ -32,6 +31,7 @@
|
|||
%li.dropdown-header= t(:system)
|
||||
%li= link_to t('.settings'), admin_settings_path
|
||||
%li= link_to t('.zones'), admin_zones_path
|
||||
%li= link_to t(:auctions), admin_auctions_path
|
||||
%li= link_to t('.blocked_domains'), admin_blocked_domains_path
|
||||
%li= link_to t('.reserved_domains'), admin_reserved_domains_path
|
||||
%li= link_to t('.disputed_domains'), admin_disputes_path
|
||||
|
|
|
@ -267,6 +267,9 @@ Rails.application.routes.draw do
|
|||
resources :accounts
|
||||
resources :account_activities
|
||||
resources :auctions, only: [ :index, :create ] do
|
||||
member do
|
||||
post 'send_to_auction', to: 'auctions#send_to_auction', as: :send_to_auction
|
||||
end
|
||||
collection do
|
||||
post 'upload_spreadsheet', to: 'auctions#upload_spreadsheet', as: :upload_spreadsheet
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue