From 6f799ae32e9a6fe96bcfd8e0acab47a64cd69408 Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 5 Oct 2015 11:49:15 +0200 Subject: [PATCH] Extracts common elements out of management views --- app/views/management/_account_info.html.erb | 8 +++++ .../management/_user_permissions.html.erb | 20 ++++++++++++ .../invalid_document.html.erb | 30 ++++++----------- .../document_verifications/new.html.erb | 32 ++++++------------- .../document_verifications/verified.html.erb | 22 +++---------- .../email_verifications/new.html.erb | 5 +-- .../email_verifications/sent.html.erb | 26 ++++----------- 7 files changed, 58 insertions(+), 85 deletions(-) create mode 100644 app/views/management/_account_info.html.erb create mode 100644 app/views/management/_user_permissions.html.erb diff --git a/app/views/management/_account_info.html.erb b/app/views/management/_account_info.html.erb new file mode 100644 index 000000000..fae1179d1 --- /dev/null +++ b/app/views/management/_account_info.html.erb @@ -0,0 +1,8 @@ +

+ <%= 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 %> + <% end %> +

diff --git a/app/views/management/_user_permissions.html.erb b/app/views/management/_user_permissions.html.erb new file mode 100644 index 000000000..c77cab17c --- /dev/null +++ b/app/views/management/_user_permissions.html.erb @@ -0,0 +1,20 @@ +<% + # Parameters: + # message: A string explaining the permissions + # permissions: An array of symbols containing the permissions + # (can be :debates, :proposal, :support_proposal, :votes) +%> +
+ +

<%= message %>

+ + + +
diff --git a/app/views/management/document_verifications/invalid_document.html.erb b/app/views/management/document_verifications/invalid_document.html.erb index d662b6c08..42e2e63c0 100644 --- a/app/views/management/document_verifications/invalid_document.html.erb +++ b/app/views/management/document_verifications/invalid_document.html.erb @@ -1,27 +1,15 @@ -

- <%= t("management.document_type_label") %> <%= humanize_document_type(@document_verification.document_type) %> - <%= t("management.document_number") %> <%= @document_verification.document_number %> -

+<%= render 'management/account_info.html', verification: @document_verification %>
<%= t("management.users.census_error") %>
-
+<%= render 'management/user_permissions', + message: t("management.users.census_error_info"), + permissions: [:debates, :proposal] %> -

<%= t("management.users.census_error_info") %>

- - - -

- <%= t("management.users.has_not_account_html", - url: link_to(t("management.users.portal_url"), t("management.users.portal_url"), - target: "_blank")).html_safe %> -

- -
+

+ <%= t("management.users.has_not_account_html", + url: link_to(t("management.users.portal_url"), t("management.users.portal_url"), + target: "_blank")).html_safe %> +

diff --git a/app/views/management/document_verifications/new.html.erb b/app/views/management/document_verifications/new.html.erb index ad9623107..f263ecbca 100644 --- a/app/views/management/document_verifications/new.html.erb +++ b/app/views/management/document_verifications/new.html.erb @@ -1,29 +1,15 @@ -

- <%= t("management.document_type_label") %> <%= humanize_document_type(@document_verification.document_type) %> - <%= t("management.document_number") %> <%= @document_verification.document_number %> - <%= t("management.username_label") %> <%= @document_verification.user.username %> - <%= t("management.email_label") %> <%= @document_verification.user.email %> -

+<%= render 'management/account_info.html', verification: @document_verification %>
<%= t("management.users.census_success_account") %>
-
+<%= render 'management/user_permissions', + message: t("management.users.census_success_info"), + permissions: [:debates, :proposal, :support_proposal] %> -

<%= t("management.users.census_success_info") %>

- - - - <%= form_for @document_verification, url: management_on_site_verifications_path do |f| %> - <%= f.hidden_field :document_type %> - <%= f.hidden_field :document_number %> - <%= f.submit t("management.users.verify"), class: "button success radius" %> - <% end %> - -
+<%= form_for @document_verification, url: management_on_site_verifications_path do |f| %> + <%= f.hidden_field :document_type %> + <%= f.hidden_field :document_number %> + <%= f.submit t("management.users.verify"), class: "button success radius" %> +<% end %> diff --git a/app/views/management/document_verifications/verified.html.erb b/app/views/management/document_verifications/verified.html.erb index dae7ce17a..40ea294fa 100644 --- a/app/views/management/document_verifications/verified.html.erb +++ b/app/views/management/document_verifications/verified.html.erb @@ -1,25 +1,11 @@ -

- <%= t("management.document_type_label") %> <%= humanize_document_type(@document_verification.document_type) %> - <%= t("management.document_number") %> <%= @document_verification.document_number %> - <%= t("management.username_label") %> <%= @document_verification.user.username %> - <%= t("management.email_label") %> <%= @document_verification.user.email %> -

+<%= render 'management/account_info.html', verification: @document_verification %>
<%= t("management.users.already_verified") %>
-
- -

<%= t("management.users.census_success_info") %>

- - - -
+<%= render 'management/user_permissions', + message: t("management.users.census_success_info"), + permissions: [:debates, :proposal, :support_proposal] %> <%= t("management.print_info") %> diff --git a/app/views/management/email_verifications/new.html.erb b/app/views/management/email_verifications/new.html.erb index d6987cf26..782110cf5 100644 --- a/app/views/management/email_verifications/new.html.erb +++ b/app/views/management/email_verifications/new.html.erb @@ -1,7 +1,4 @@ -

- <%= t("management.document_type_label") %> <%= humanize_document_type(@email_verification.document_type) %> - <%= t("management.document_number") %> <%= @email_verification.document_number %> -

+<%= render 'management/account_info.html', verification: @email_verification %>
<%= t("management.users.census_success") %> diff --git a/app/views/management/email_verifications/sent.html.erb b/app/views/management/email_verifications/sent.html.erb index 470e9c292..6b0c3da8a 100644 --- a/app/views/management/email_verifications/sent.html.erb +++ b/app/views/management/email_verifications/sent.html.erb @@ -1,26 +1,14 @@ - +<%= render 'management/account_info.html', verification: @email_verification %>
<%= t("management.users.email_sent") %>
-
+<%= render 'management/user_permissions', + message: t("management.users.census_success_info"), + permissions: [:debates, :proposal, :support_proposal, :votes] %> -

<%= t("management.users.census_success_info") %>

- -
    -
  • <%= t("management.users.user_permission_debates") %>
  • -
  • <%= t("management.users.user_permission_proposal") %>
  • -
  • <%= t("management.users.user_permission_support_proposal") %>
  • -
  • <%= t("management.users.user_permission_votes") %>
  • -
- -
- -<%= t("management.print_info") %> +

+ <%= t("management.print_info") %> +