mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Merge pull request #2683 from internetee/fix-contact-name-issues
Updated contact name data type in db schemas
This commit is contained in:
commit
ee5cf99b13
12 changed files with 109 additions and 45 deletions
|
@ -74,6 +74,7 @@ module Epp
|
|||
|
||||
def validate_against_schema
|
||||
return if %w[hello error].include?(params[:action])
|
||||
|
||||
schema.validate(params[:nokogiri_frame]).each do |error|
|
||||
epp_errors.add(:epp_errors,
|
||||
code: 2001,
|
||||
|
@ -100,6 +101,7 @@ module Epp
|
|||
|
||||
def current_user
|
||||
return unless signed_in?
|
||||
|
||||
epp_session.user
|
||||
end
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ module EppErrors
|
|||
errors.each do |err|
|
||||
code, value = find_epp_code_and_value(err)
|
||||
next unless code
|
||||
|
||||
msg = attr.to_sym == :base ? err : "#{err} [#{attr}]"
|
||||
epp_errors.add(attr, code: code, msg: msg, value: value)
|
||||
end
|
||||
|
|
|
@ -46,6 +46,7 @@ class Contact < ApplicationRecord
|
|||
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x
|
||||
|
||||
validates :name, :email, presence: true
|
||||
validates :name, length: { maximum: 255, message: :too_long_contact_name }
|
||||
validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }
|
||||
|
||||
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
||||
|
|
|
@ -12,6 +12,7 @@ class Epp::Contact < Contact
|
|||
|
||||
def manage_permissions
|
||||
return unless update_prohibited? || delete_prohibited?
|
||||
|
||||
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
|
||||
throw(:abort)
|
||||
end
|
||||
|
@ -76,6 +77,7 @@ class Epp::Contact < Contact
|
|||
],
|
||||
'2005' => [ # Value syntax error
|
||||
[:name, :invalid],
|
||||
[:name, :too_long_contact_name],
|
||||
[:phone, :invalid],
|
||||
[:email, :invalid],
|
||||
[:country_code, :invalid],
|
||||
|
|
|
@ -15,6 +15,7 @@ en:
|
|||
name:
|
||||
blank: "Required parameter missing - name"
|
||||
invalid: "Name is invalid"
|
||||
too_long_contact_name: "Contact name is too long, max 255 characters"
|
||||
phone:
|
||||
blank: "Required parameter missing - phone"
|
||||
invalid: "Phone nr is invalid"
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||
# be faster and is potentially less error prone than running all of your
|
||||
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||
# migrations use external dependencies or application code.
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
|
@ -17,35 +16,33 @@ ActiveRecord::Schema.define(version: 0) do
|
|||
enable_extension "plpgsql"
|
||||
|
||||
create_table "epp_logs", force: :cascade do |t|
|
||||
t.text "request"
|
||||
t.text "response"
|
||||
t.string "request_command", limit: 255
|
||||
t.string "request_object", limit: 255
|
||||
t.boolean "request_successful"
|
||||
t.string "api_user_name", limit: 255
|
||||
t.string "api_user_registrar", limit: 255
|
||||
t.string "ip", limit: 255
|
||||
t.text "request"
|
||||
t.text "response"
|
||||
t.string "request_command", limit: 255
|
||||
t.string "request_object"
|
||||
t.boolean "request_successful"
|
||||
t.string "api_user_name", limit: 255
|
||||
t.string "api_user_registrar", limit: 255
|
||||
t.string "ip", limit: 255
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "uuid"
|
||||
t.string "uuid"
|
||||
t.index ["uuid"], name: "epp_logs_uuid"
|
||||
end
|
||||
|
||||
add_index "epp_logs", ["uuid"], name: "epp_logs_uuid", using: :btree
|
||||
|
||||
create_table "repp_logs", force: :cascade do |t|
|
||||
t.string "request_path", limit: 255
|
||||
t.string "request_method", limit: 255
|
||||
t.text "request_params"
|
||||
t.text "response"
|
||||
t.string "response_code", limit: 255
|
||||
t.string "api_user_name", limit: 255
|
||||
t.string "api_user_registrar", limit: 255
|
||||
t.string "ip", limit: 255
|
||||
t.string "request_path", limit: 255
|
||||
t.string "request_method", limit: 255
|
||||
t.text "request_params"
|
||||
t.text "response"
|
||||
t.string "response_code", limit: 255
|
||||
t.string "api_user_name", limit: 255
|
||||
t.string "api_user_registrar", limit: 255
|
||||
t.string "ip", limit: 255
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "uuid"
|
||||
t.string "uuid"
|
||||
t.index ["uuid"], name: "repp_logs_uuid"
|
||||
end
|
||||
|
||||
add_index "repp_logs", ["uuid"], name: "repp_logs_uuid", using: :btree
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class RemoveLogDomainStatuses < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
drop_table :log_domain_statuses
|
||||
drop_table :log_domain_statuses if table_exists?(:log_domain_statuses)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
class ChangeRequestObjectTypeInEppLogs < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
with_api_log_connection do |connection|
|
||||
connection.change_column :epp_logs, :request_object, :string, limit: nil
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_api_log_connection do |connection|
|
||||
connection.change_column :epp_logs, :request_object, :string, limit: 255
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_api_log_connection
|
||||
api_log_connection = ActiveRecord::Base.establish_connection("api_log_#{Rails.env}".to_sym).connection
|
||||
|
||||
yield(api_log_connection)
|
||||
|
||||
ensure
|
||||
# Re-establish the original connection
|
||||
ActiveRecord::Base.establish_connection(original_connection_config)
|
||||
end
|
||||
|
||||
def original_connection_config
|
||||
Rails.configuration.database_configuration[Rails.env]
|
||||
end
|
||||
end
|
29
db/migrate/20240816092636_change_data_type_in_contacts.rb
Normal file
29
db/migrate/20240816092636_change_data_type_in_contacts.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
class ChangeDataTypeInContacts < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
change_column :contacts, :code, :string, limit: 255
|
||||
change_column :contacts, :phone, :string, limit: 255
|
||||
change_column :contacts, :email, :string, limit: 255
|
||||
change_column :contacts, :fax, :string, limit: 255
|
||||
change_column :contacts, :ident, :string, limit: 255
|
||||
change_column :contacts, :ident_type, :string, limit: 255
|
||||
change_column :contacts, :auth_info, :string, limit: 255
|
||||
change_column :contacts, :name, :string, limit: 255
|
||||
change_column :contacts, :org_name, :string, limit: 255
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_column :contacts, :code, :string, limit: nil
|
||||
change_column :contacts, :phone, :string, limit: nil
|
||||
change_column :contacts, :email, :string, limit: nil
|
||||
change_column :contacts, :fax, :string, limit: nil
|
||||
change_column :contacts, :ident, :string, limit: nil
|
||||
change_column :contacts, :ident_type, :string, limit: nil
|
||||
change_column :contacts, :auth_info, :string, limit: nil
|
||||
change_column :contacts, :name, :string, limit: nil
|
||||
change_column :contacts, :org_name, :string, limit: nil
|
||||
end
|
||||
end
|
||||
end
|
|
@ -661,17 +661,17 @@ ALTER SEQUENCE public.contact_requests_id_seq OWNED BY public.contact_requests.i
|
|||
|
||||
CREATE TABLE public.contacts (
|
||||
id integer NOT NULL,
|
||||
code character varying NOT NULL,
|
||||
phone character varying,
|
||||
email character varying NOT NULL,
|
||||
fax character varying,
|
||||
code character varying(255) NOT NULL,
|
||||
phone character varying(255),
|
||||
email character varying(255) NOT NULL,
|
||||
fax character varying(255),
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
ident character varying,
|
||||
ident_type character varying,
|
||||
auth_info character varying NOT NULL,
|
||||
name character varying NOT NULL,
|
||||
org_name character varying,
|
||||
ident character varying(255),
|
||||
ident_type character varying(255),
|
||||
auth_info character varying(255) NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
org_name character varying(255),
|
||||
registrar_id integer NOT NULL,
|
||||
creator_str character varying,
|
||||
updator_str character varying,
|
||||
|
@ -5470,6 +5470,8 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20221214073933'),
|
||||
('20221214074252'),
|
||||
('20230531111154'),
|
||||
('20230707084741');
|
||||
('20230707084741'),
|
||||
('20240816091049'),
|
||||
('20240816092636');
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||
# be faster and is potentially less error prone than running all of your
|
||||
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||
# migrations use external dependencies or application code.
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ if ENV['COVERAGE']
|
|||
end
|
||||
end
|
||||
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
ENV['RAILS_ENV'] = 'test'
|
||||
require_relative '../config/environment'
|
||||
require 'rails/test_help'
|
||||
require 'minitest/mock'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue