From d6985dc78be01acb504af037c0735e1dcd349049 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Tue, 20 Jul 2021 01:03:18 +0300 Subject: [PATCH 1/4] fixed method update --- app/controllers/registrar/contacts_controller.rb | 2 +- app/models/depp/contact.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index 756495457..85a1adce5 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -83,7 +83,7 @@ class Registrar def update authorize! :edit, Depp::Contact - @contact = Depp::Contact.new(contact_params) + @contact = Depp::Contact.find_by_id(contact_params[:id]) if @contact.update_attributes(contact_params) redirect_to registrar_contact_url(@contact.id) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 33b7545b7..9050d8ca1 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -172,9 +172,9 @@ module Depp end def update_attributes(params) - self.ident_country_code = params[:ident_country_code] - self.ident_type = params[:ident_type] - self.ident = params[:ident] + self.ident_country_code ||= params[:ident_country_code] + self.ident_type ||= params[:ident_type] + self.ident ||= params[:ident] self.name = params[:name] self.email = params[:email] From 01840ef511be7fec5f055630c09ceb7e85650137 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Tue, 20 Jul 2021 07:02:58 +0300 Subject: [PATCH 2/4] fixed codeclimate error --- app/models/depp/contact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 9050d8ca1..710fff9f7 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -173,8 +173,8 @@ module Depp def update_attributes(params) self.ident_country_code ||= params[:ident_country_code] - self.ident_type ||= params[:ident_type] - self.ident ||= params[:ident] + self.ident_type ||= params[:ident_type] + self.ident ||= params[:ident] self.name = params[:name] self.email = params[:email] From cbfe2704b6b6cbd2aabc98b680255e7fffc64e31 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Tue, 20 Jul 2021 15:55:53 +0300 Subject: [PATCH 3/4] fixed form and contacts controller --- app/controllers/registrar/contacts_controller.rb | 2 +- app/views/registrar/contacts/form/_general.haml | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index 85a1adce5..756495457 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -83,7 +83,7 @@ class Registrar def update authorize! :edit, Depp::Contact - @contact = Depp::Contact.find_by_id(contact_params[:id]) + @contact = Depp::Contact.new(contact_params) if @contact.update_attributes(contact_params) redirect_to registrar_contact_url(@contact.id) diff --git a/app/views/registrar/contacts/form/_general.haml b/app/views/registrar/contacts/form/_general.haml index d7fcea38a..77443903d 100644 --- a/app/views/registrar/contacts/form/_general.haml +++ b/app/views/registrar/contacts/form/_general.haml @@ -15,9 +15,7 @@ = f.label :ident_country_code, t(:country) + '*' .col-md-7 - if ident_complete && @contact.persisted? && f.object.ident_country_code.present? - .disabled-value - = Country.new(f.object.ident_country_code).try(:to_s) - = " [#{f.object.ident_country_code}]" + = f.text_field :ident_country_code, value: f.object.ident_country_code, :readonly => true - else = f.select(:ident_country_code, ApplicationController.helpers.all_country_options(country_selected), {}, class: 'js-ident-country-code', required: true) @@ -27,9 +25,7 @@ = f.label :ident_type, t(:type) + '*' .col-md-7 - if ident_complete && @contact.persisted? && f.object.ident_type.present? - .disabled-value - = Depp::Contact.type_string(f.object.ident_type) - = " [#{f.object.ident_type}]" + = f.text_field :ident_type, value: f.object.ident_type, :readonly => true - else = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected }, class: 'js-ident-type', required: true) @@ -39,8 +35,7 @@ = f.label :ident, t(:ident) + '*' .col-md-7 - if ident_complete && @contact.persisted? && f.object.ident.present? - .disabled-value - = f.object.ident + = f.text_field :ident, value: f.object.ident, :readonly => true - else = f.text_field :ident, class: 'form-control', required: true - tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none' From 8fb8830dd013429e0ae38a03c626858af482ac98 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Wed, 21 Jul 2021 09:49:37 +0300 Subject: [PATCH 4/4] rolled back model changes --- app/models/depp/contact.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 710fff9f7..33b7545b7 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -172,9 +172,9 @@ module Depp end def update_attributes(params) - self.ident_country_code ||= params[:ident_country_code] - self.ident_type ||= params[:ident_type] - self.ident ||= params[:ident] + self.ident_country_code = params[:ident_country_code] + self.ident_type = params[:ident_type] + self.ident = params[:ident] self.name = params[:name] self.email = params[:email]