Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed show auction action issue #1299

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin/auctions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def apply_auction_participants
auction = Auction.find_by_uuid(params[:auction_uuid])
users = User.where(id: params[:user_ids])
users.each do |user|
DomainParticipateAuction.create!(user: user, auction: auction)
DomainParticipateAuction.create!(user:, auction:)
end

redirect_to admin_auction_path(auction)
Expand Down
11 changes: 9 additions & 2 deletions app/controllers/auctions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ class AuctionsController < ApplicationController
def index
set_cors_header
@auctions_list = fetch_auctions_list
per_page = params[:per_page] || per_page_count
@pagy, @auctions = pagy(@auctions_list, items: per_page, link_extra: 'data-turbo-action="advance"')
end

def show
redirect_to root_path, status: :moved_permanently
end

# OPTIONS /auctions
def cors_preflight_check
set_access_control_headers
Expand All @@ -33,8 +36,12 @@ def should_sort_auctions?
params[:sort_by].blank? && params[:sort_direction].blank?
end

def per_page
params[:per_page] || DEFAULT_PAGE_LIMIT
end

def per_page_count
count = params[:show_all] == 'true' ? @auctions_list.count : DEFAULT_PAGE_LIMIT
count = params[:show_all] == 'true' ? @auctions_list.count : per_page
count = nil if count.zero?
count
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/english_offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def show
# GET /english_offers/aa450f1a-45e2-4f22-b2c3-f5f46b5f906b/edit
def edit
@auction = @offer.auction
redirect_to auction_path(@auction.uuid) and return if update_not_allowed(@auction)
redirect_to root_path and return if update_not_allowed(@auction)
end

# PUT /english_offers/aa450f1a-45e2-4f22-b2c3-f5f46b5f906b
def update
@auction = Auction.english.with_user_offers(current_user.id).find_by(uuid: @offer.auction.uuid)
redirect_to auction_path(@auction.uuid) and return if update_not_allowed(@auction)
redirect_to root_path and return if update_not_allowed(@auction)
inform_invalid_captcha and return unless recaptcha_valid

if update_predicate(@auction)
Expand Down
18 changes: 11 additions & 7 deletions app/models/billing_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BillingProfile < ApplicationRecord
has_many :domain_offer_histories
has_many :invoices

scope :with_search_scope, ->(origin) {
scope :with_search_scope, lambda { |origin|
if origin.present?
joins(:user)
.includes(:user)
Expand All @@ -39,10 +39,12 @@ def self.search(params = {})

def vat_code_must_be_registered_in_vies
# Vat code validation only for EU countries
vat_rate = Countries.vat_rate_from_alpha2_code(self.country_code)
vat_rate = Countries.vat_rate_from_alpha2_code(country_code)
return if vat_code.blank? || vat_rate == BigDecimal(0)

errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_error')) unless Valvat.new(self.vat_code).exists?
errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_error')) unless Valvat.new(vat_code).exists?
rescue Valvat::RateLimitError
errors.add(:vat_code, I18n.t('billing_profiles.vat_validation_rate_limit_error'))
end

def issued_invoices
Expand All @@ -67,7 +69,7 @@ def vat_rate
# if Time.zone.now.year < 2024
# return BigDecimal(OLD_EST_RATE_VAT)
# else
return BigDecimal(Setting.find_by(code: :estonian_vat_rate).retrieve, 2)
return BigDecimal(Setting.find_by(code: :estonian_vat_rate).retrieve, 2)
# end
end

Expand All @@ -77,11 +79,11 @@ def vat_rate
end

def self.create_default_for_user(user_id)
return if find_by(user_id: user_id)
return if find_by(user_id:)

user = User.find(user_id)

billing_profile = new(user: user, country_code: user.country_code, name: user.display_name)
billing_profile = new(user:, country_code: user.country_code, name: user.display_name)
billing_profile.save!

billing_profile
Expand Down Expand Up @@ -116,11 +118,13 @@ def mirror_address_to_attached_invoices
private

def update_billing_information_for_invoices
return unless name_changed? || street_changed? || city_changed? || postal_code_changed? || country_code_changed?

issued_invoices.update_all(
billing_name: name,
billing_address: address,
billing_vat_code: vat_code,
billing_alpha_two_country_code: alpha_two_country_code
) if name_changed? || street_changed? || city_changed? || postal_code_changed? || country_code_changed?
)
end
end
22 changes: 0 additions & 22 deletions app/views/admin/auctions/deprecated/_auction.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/admin/auctions/deprecated/_auctions.html.erb

This file was deleted.

11 changes: 0 additions & 11 deletions app/views/admin/auctions/deprecated/_deposit_participant.html.erb

This file was deleted.

65 changes: 0 additions & 65 deletions app/views/admin/auctions/deprecated/_deposit_participants.html.erb

This file was deleted.

26 changes: 0 additions & 26 deletions app/views/admin/auctions/deprecated/_form.html.erb

This file was deleted.

Loading