diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb
new file mode 100644
index 000000000..39834ac54
--- /dev/null
+++ b/app/controllers/admin/auctions_controller.rb
@@ -0,0 +1,41 @@
+module Admin
+ class AuctionsController < BaseController
+ load_and_authorize_resource
+
+ def index
+ params[:q] ||= {}
+
+ @auctions = Auction.with_status(params[:statuses_contains])
+
+ normalize_search_parameters do
+ @q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
+ @auctions = @q.result.page(params[:page])
+ end
+
+ @auctions = @auctions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
+
+ render_by_format('admin/auctions/index', 'auctions')
+ end
+
+ def update
+
+ redirect_to admin_auctions_path
+ end
+
+ private
+
+ def normalize_search_parameters
+ ca_cache = params[:q][:valid_to_lteq]
+ begin
+ end_time = params[:q][:valid_to_lteq].try(:to_date)
+ params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
+ rescue
+ logger.warn('Invalid date')
+ end
+
+ yield
+
+ params[:q][:valid_to_lteq] = ca_cache
+ end
+ end
+end
diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb
index 1bfade83e..aeebe8906 100644
--- a/app/controllers/admin/reserved_domains_controller.rb
+++ b/app/controllers/admin/reserved_domains_controller.rb
@@ -51,8 +51,26 @@ module Admin
redirect_to admin_reserved_domains_path
end
+ def release_to_auction
+ redirect_to admin_reserved_domains_path and return if params[:reserved_elements].nil?
+
+ reserved_domains_ids = params[:reserved_elements][:domain_ids]
+ reserved_domains = ReservedDomain.where(id: reserved_domains_ids)
+
+ reserved_domains.each do |domain|
+ Auction.create!(domain: domain.name, status: Auction.statuses[:started])
+ domain.destroy!
+ end
+
+ redirect_to admin_reserved_domains_path
+ end
+
private
+ def reserved_checked_elements
+ # params.require(:reserved_elements).permit(:name, :password)
+ end
+
def reserved_domain_params
params.require(:reserved_domain).permit(:name, :password)
end
diff --git a/app/helpers/auction_helper.rb b/app/helpers/auction_helper.rb
new file mode 100644
index 000000000..e4ef44736
--- /dev/null
+++ b/app/helpers/auction_helper.rb
@@ -0,0 +1,21 @@
+module AuctionHelper
+ include ActionView::Helpers::TagHelper
+
+ extend self
+
+ def colorize_auction(auction)
+ case auction.status
+ when 'started' then render_status_black(auction.domain)
+ when 'awaiting_payment' then render_status_black(auction.domain)
+ else render_status_green(auction.domain)
+ end
+ end
+
+ def render_status_black(name)
+ content_tag(:span, name.to_s, style: 'color: black;')
+ end
+
+ def render_status_green(name)
+ content_tag(:span, name.to_s , style: 'color: green;')
+ end
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index caca24524..bc2caa6ba 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -95,6 +95,7 @@ class Ability
can :manage, User
can :manage, ApiUser
can :manage, AdminUser
+ can :manage, Auction
can :manage, Certificate
can :manage, LegalDocument
can :manage, BankStatement
diff --git a/app/models/auction.rb b/app/models/auction.rb
index 791184d60..fd48c22f2 100644
--- a/app/models/auction.rb
+++ b/app/models/auction.rb
@@ -12,8 +12,13 @@ class Auction < ApplicationRecord
PENDING_STATUSES = [statuses[:started],
statuses[:awaiting_payment],
statuses[:payment_received]].freeze
+
private_constant :PENDING_STATUSES
+ scope :with_status, -> (status) {
+ where(status: status) if status.present?
+ }
+
def self.pending(domain_name)
find_by(domain: domain_name.to_s, status: PENDING_STATUSES)
end
diff --git a/app/views/admin/auctions/_search_form.html.erb b/app/views/admin/auctions/_search_form.html.erb
new file mode 100644
index 000000000..d675a70ca
--- /dev/null
+++ b/app/views/admin/auctions/_search_form.html.erb
@@ -0,0 +1,17 @@
+<%= search_form_for [:admin, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
+
+
+
+
+
+
+
+ <%= link_to t('.download_csv_btn'), admin_domains_path(format: :csv, params: params.permit!),
+ "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
+ class: 'btn btn-primary' %>
+
+
+
+
+
+<% end %>
diff --git a/app/views/admin/auctions/index.html.erb b/app/views/admin/auctions/index.html.erb
new file mode 100644
index 000000000..a9a708755
--- /dev/null
+++ b/app/views/admin/auctions/index.html.erb
@@ -0,0 +1,101 @@
+
+
+
+
+ <%= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %>
+
+
+
+ <%= f.label :domain %>
+ <%= f.search_field :domain_matches, value: params[:q][:domain_matches], class: 'form-control', placeholder: t(:name) %>
+
+
+ <%= f.label :status %>
+ <%= select_tag :statuses_contains, options_for_select(Auction.statuses.map { |x| [x[0], x[1]] }, params[:q][:status]), { include_blank:true, class: 'form-control' } %>
+
+
+
+
+ <%= f.label t(:created_at_from) %>
+ <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from) %>
+
+
+
+
+ <%= f.label t(:created_at_until) %>
+ <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until) %>
+
+
+
+
+ <%= label_tag t(:results_per_page) %>
+ <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
+
+
+
+
+ <%= link_to(t('.reset_btn'), admin_auctions_path, class: 'btn btn-default') %>
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+ <%= link_to 'Download auction list', admin_auctions_path(format: :csv, params: params.permit!),
+ "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_csv_btn'),
+ class: 'btn btn-primary' %>
+
+
+
+
+
+
+
+
+
+
+
+ <%= sort_link(@q, 'domain') %>
+ |
+
+ <%= sort_link(@q, 'status') %>
+ |
+
+ <%= sort_link(@q, 'created_at') %>
+ |
+
+ <%= sort_link(@q, 'registration_code') %>
+ |
+
+ <%= sort_link(@q, 'registration_deadline') %>
+ |
+
+
+
+
+
+ <% @auctions.each do |auction| %>
+
+ <%= AuctionHelper.colorize_auction(auction) %> |
+ <%= auction.status %> |
+ <%= auction.created_at %> |
+ <%= auction.registration_code %> |
+ <%= auction.registration_deadline %> |
+
+ <% end %>
+
+
+
+
+
diff --git a/app/views/admin/base/_menu.haml b/app/views/admin/base/_menu.haml
index c5edd4708..d233ad34d 100644
--- a/app/views/admin/base/_menu.haml
+++ b/app/views/admin/base/_menu.haml
@@ -21,6 +21,7 @@
%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
diff --git a/app/views/admin/reserved_domains/index.html.erb b/app/views/admin/reserved_domains/index.html.erb
new file mode 100644
index 000000000..6f1018875
--- /dev/null
+++ b/app/views/admin/reserved_domains/index.html.erb
@@ -0,0 +1,134 @@
+<% content_for :actions do %>
+ <%= link_to(t('.new_btn'), new_admin_reserved_domain_path, class: 'btn btn-primary') %>
+<% end %>
+
+<%= render 'shared/title', name: t('.title') %>
+
+
+ <%= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %>
+
+
+
+ <%= f.label :name %>
+ <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
+
+
+
+
+ <%= f.label t(:created_at_from) %>
+ <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from) %>
+
+
+
+
+ <%= f.label t(:created_at_until) %>
+ <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until) %>
+
+
+
+
+
+
+ <%= label_tag t(:results_per_page) %>
+ <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
+
+
+
+
+ <%= link_to(t('.csv_btn'), admin_reserved_domains_path(format: :csv, params: params.permit!), class: 'btn btn-default') %>
+ <%= link_to(t('.reset_btn'), admin_reserved_domains_path, class: 'btn btn-default') %>
+
+
+ <% end %>
+
+
+
+
+
+<%= form_for :reserved_elements, url: release_to_auction_admin_reserved_domains_path, html: { class: 'form-horizontal', autocomplete: 'off' } do |f| %>
+ <%= f.submit 'Send to the auction list', class: 'btn btn-primary', style: 'margin: 10px 0 20px 0;' %>
+
+
+
+
+
+
+
+
+ <%= check_box_tag :check_all %>
+ |
+
+ <%= sort_link(@q, 'name') %>
+ |
+
+ <%= sort_link(@q, 'password') %>
+ |
+
+ <%= sort_link(@q, 'created_at', t(:created_at)) %>
+ |
+
+ <%= sort_link(@q, 'updated_at', t(:updated_at)) %>
+ |
+
+ <%= t(:actions) %>
+ |
+
+
+
+ <% @domains.each do |x| %>
+
+
+ <%= f.check_box :domain_ids, { multiple: true }, x.id, nil %>
+ |
+
+ <%= x.name %>
+ |
+
+ <%= x.password %>
+ |
+
+ <%= l(x.created_at, format: :short) %>
+ |
+
+ <%= l(x.updated_at, format: :short) %>
+ |
+
+ <%= link_to(t(:edit_pw), edit_admin_reserved_domain_path(id: x.id), class: 'btn btn-primary btn-xs') %>
+ <%= link_to(t(:delete), delete_admin_reserved_domain_path(id: x.id), data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') %>
+ |
+
+ <% end %>
+
+
+
+
+
+<% end %>
+
+
+
+ <%= paginate @domains %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index2.haml
similarity index 90%
rename from app/views/admin/reserved_domains/index.haml
rename to app/views/admin/reserved_domains/index2.haml
index 5444ba34d..a3b49e0b0 100644
--- a/app/views/admin/reserved_domains/index.haml
+++ b/app/views/admin/reserved_domains/index2.haml
@@ -30,6 +30,7 @@
= link_to(t('.csv_btn'), admin_reserved_domains_path(format: :csv, params: params.permit!), class: 'btn btn-default')
= link_to(t('.reset_btn'), admin_reserved_domains_path, class: 'btn btn-default')
+ = link_to 'Send to auction',release_to_auction_admin_reserved_domains_path, method: :post, class: 'btn btn-default', style: 'margin-top: 5px;'
%hr
.row
.col-md-12
@@ -37,6 +38,7 @@
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
+ %th{class: 'col-xs-1'}
%th{class: 'col-xs-2'}
= sort_link(@q, 'name')
%th{class: 'col-xs-2'}
@@ -50,6 +52,8 @@
%tbody
- @domains.each do |x|
%tr
+ %td{class: 'text-center'}
+ = check_box_tag "reserved_domains[domain_ids][]", x.id, false
%td= x.name
%td= x.password
%td= l(x.created_at, format: :short)
diff --git a/config/routes.rb b/config/routes.rb
index a2a4556f7..38e263c94 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -266,6 +266,11 @@ Rails.application.routes.draw do
resources :accounts
resources :account_activities
+ resources :auctions, only: [ :index ] do
+ collection do
+ patch :update
+ end
+ end
resources :bank_statements do
resources :bank_transactions
@@ -335,6 +340,10 @@ Rails.application.routes.draw do
member do
get 'delete'
end
+
+ collection do
+ post 'release_to_auction', to: 'reserved_domains#release_to_auction', as: 'release_to_auction'
+ end
end
resources :disputes do
member do
diff --git a/db/structure.sql b/db/structure.sql
index 2c4723dce..4c22970d3 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -813,7 +813,8 @@ CREATE TABLE public.dnskeys (
updator_str character varying,
legacy_domain_id integer,
updated_at timestamp without time zone,
- validation_datetime timestamp without time zone
+ validation_datetime timestamp without time zone,
+ failed_validation_reason character varying
);
@@ -1089,6 +1090,7 @@ CREATE TABLE public.invoices (
buyer_vat_no character varying,
issue_date date NOT NULL,
e_invoice_sent_at timestamp without time zone,
+ payment_link character varying,
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
);
@@ -5084,6 +5086,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220406085500'),
('20220413073315'),
('20220413084536'),
-('20220413084748');
-
-
+('20220413084748'),
+('20220124105717'),
+('20220216113112'),
+('20220228093211');