Refactors account_info partial

This commit is contained in:
kikito
2015-10-07 19:39:59 +02:00
parent bc841a4799
commit d5d5e683d1
8 changed files with 16 additions and 10 deletions

View File

@@ -6,6 +6,8 @@ class Verification::Management::Document
validates :document_type, :document_number, presence: true validates :document_type, :document_number, presence: true
delegate :username, :email, to: :user, allow_nil: true
def user def user
@user = User.by_document(document_type, document_number).first @user = User.by_document(document_type, document_number).first
end end

View File

@@ -9,6 +9,8 @@ class Verification::Management::Email
validates :email, format: { with: Devise.email_regexp }, allow_blank: true validates :email, format: { with: Devise.email_regexp }, allow_blank: true
validate :validate_user validate :validate_user
delegate :username, to: :user, allow_nil: true
def user def user
@user ||= User.where(email: email).first @user ||= User.where(email: email).first
end end

View File

@@ -1,8 +1,10 @@
<p class="account-info"> <p class="account-info">
<%= t("management.document_type_label") %> <strong><%= humanize_document_type(verification.document_type) %></strong> <%= t("management.document_type_label") %> <strong><%= humanize_document_type(account.document_type) %></strong>
<%= t("management.document_number") %> <strong><%= verification.document_number %></strong> <%= t("management.document_number") %> <strong><%= account.document_number %></strong>
<% if verification.user? %> <% if account.username.present? %>
<%= t("management.username_label") %> <strong><%= verification.user.username %></strong> <%= t("management.username_label") %> <strong><%= account.username %></strong>
<%= t("management.email_label") %> <strong><%= verification.user.email %></strong> <% end %>
<% if account.email.present? %>
<%= t("management.email_label") %> <strong><%= account.email %></strong>
<% end %> <% end %>
</p> </p>

View File

@@ -1,4 +1,4 @@
<%= render 'management/account_info.html', verification: @document_verification %> <%= render 'management/account_info.html', account: @document_verification %>
<div class="alert-box alert radius"> <div class="alert-box alert radius">
<%= t("management.document_verifications.not_in_census") %> <%= t("management.document_verifications.not_in_census") %>

View File

@@ -1,4 +1,4 @@
<%= render 'management/account_info.html', verification: @document_verification %> <%= render 'management/account_info.html', account: @document_verification %>
<div class="alert-box success radius"> <div class="alert-box success radius">
<%= t("management.document_verifications.please_check_account_data") %> <%= t("management.document_verifications.please_check_account_data") %>

View File

@@ -1,4 +1,4 @@
<%= render 'management/account_info.html', verification: @document_verification %> <%= render 'management/account_info.html', account: @document_verification %>
<div class="alert-box success radius"> <div class="alert-box success radius">
<%= t("management.document_verifications.already_verified") %> <%= t("management.document_verifications.already_verified") %>

View File

@@ -1,4 +1,4 @@
<%= render 'management/account_info.html', verification: @email_verification %> <%= render 'management/account_info.html', account: @email_verification %>
<div class="alert-box success radius"> <div class="alert-box success radius">
<%= t("management.email_verifications.document_found_in_census") %> <%= t("management.email_verifications.document_found_in_census") %>

View File

@@ -1,4 +1,4 @@
<%= render 'management/account_info.html', verification: @email_verification %> <%= render 'management/account_info.html', account: @email_verification %>
<div class="alert-box success radius"> <div class="alert-box success radius">
<%= t("management.email_verifications.email_sent_instructions") %> <%= t("management.email_verifications.email_sent_instructions") %>