diff --git a/app/models/verification/management/document.rb b/app/models/verification/management/document.rb index 69ab1affc..6c9a8897f 100644 --- a/app/models/verification/management/document.rb +++ b/app/models/verification/management/document.rb @@ -6,6 +6,8 @@ class Verification::Management::Document validates :document_type, :document_number, presence: true + delegate :username, :email, to: :user, allow_nil: true + def user @user = User.by_document(document_type, document_number).first end diff --git a/app/models/verification/management/email.rb b/app/models/verification/management/email.rb index 7cd815dd5..9863b05d6 100644 --- a/app/models/verification/management/email.rb +++ b/app/models/verification/management/email.rb @@ -9,6 +9,8 @@ class Verification::Management::Email validates :email, format: { with: Devise.email_regexp }, allow_blank: true validate :validate_user + delegate :username, to: :user, allow_nil: true + def user @user ||= User.where(email: email).first end diff --git a/app/views/management/_account_info.html.erb b/app/views/management/_account_info.html.erb index fae1179d1..972398e89 100644 --- a/app/views/management/_account_info.html.erb +++ b/app/views/management/_account_info.html.erb @@ -1,8 +1,10 @@
- <%= t("management.document_type_label") %> <%= humanize_document_type(verification.document_type) %> - <%= t("management.document_number") %> <%= verification.document_number %> - <% if verification.user? %> - <%= t("management.username_label") %> <%= verification.user.username %> - <%= t("management.email_label") %> <%= verification.user.email %> + <%= t("management.document_type_label") %> <%= humanize_document_type(account.document_type) %> + <%= t("management.document_number") %> <%= account.document_number %> + <% if account.username.present? %> + <%= t("management.username_label") %> <%= account.username %> + <% end %> + <% if account.email.present? %> + <%= t("management.email_label") %> <%= account.email %> <% end %>
diff --git a/app/views/management/document_verifications/invalid_document.html.erb b/app/views/management/document_verifications/invalid_document.html.erb index a3ae68c52..d5e1b78fe 100644 --- a/app/views/management/document_verifications/invalid_document.html.erb +++ b/app/views/management/document_verifications/invalid_document.html.erb @@ -1,4 +1,4 @@ -<%= render 'management/account_info.html', verification: @document_verification %> +<%= render 'management/account_info.html', account: @document_verification %>