mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Basic domain renew
This commit is contained in:
parent
d62106da20
commit
b828645920
7 changed files with 69 additions and 0 deletions
|
@ -9,6 +9,10 @@ class Epp::CommandsController < ApplicationController
|
|||
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||
end
|
||||
|
||||
def renew
|
||||
send("renew_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||
end
|
||||
|
||||
def check
|
||||
send("check_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||
end
|
||||
|
|
|
@ -19,6 +19,23 @@ module Epp::DomainsHelper
|
|||
render '/epp/domains/check'
|
||||
end
|
||||
|
||||
def renew_domain
|
||||
ph = params_hash['epp']['command']['renew']['renew']
|
||||
|
||||
@domain = Domain.find_by(name: ph[:name])
|
||||
unless @domain
|
||||
epp_errors << {code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: {obj: 'domain', val: ph[:name]}}
|
||||
render '/epp/error' and return
|
||||
end
|
||||
|
||||
if @domain.renew(ph[:curExpDate], ph[:period])
|
||||
render '/epp/domains/renew'
|
||||
else
|
||||
handle_errors
|
||||
render '/epp/error'
|
||||
end
|
||||
end
|
||||
|
||||
### HELPER METHODS ###
|
||||
private
|
||||
|
||||
|
|
|
@ -124,6 +124,16 @@ class Domain < ActiveRecord::Base
|
|||
errors.add(:admin_contacts, :blank) if admin_contacts.empty?
|
||||
end
|
||||
|
||||
def renew(cur_exp_date, period, unit='y')
|
||||
if cur_exp_date == valid_to
|
||||
valid_to = period.to_i.years
|
||||
else
|
||||
errors[:base] << {msg: I18n.t('errors.messages.epp_exp_dates_do_not_match'), obj: 'domain', val: cur_exp_date}
|
||||
end
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
class << self
|
||||
def check_availability(domains)
|
||||
domains = [domains] if domains.is_a?(String)
|
||||
|
|
16
app/views/epp/domains/renew.xml.builder
Normal file
16
app/views/epp/domains/renew.xml.builder
Normal file
|
@ -0,0 +1,16 @@
|
|||
xml.epp_head do
|
||||
xml.response do
|
||||
xml.result('code' => '1000') do
|
||||
xml.msg 'Command completed successfully'
|
||||
end
|
||||
|
||||
xml.resData do
|
||||
xml.tag!('domain:renData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
xml.tag!('domain:name', @domain[:name])
|
||||
xml.tag!('domain:exDate', @domain.valid_to)
|
||||
end
|
||||
end
|
||||
|
||||
xml << render('/epp/shared/trID')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue