diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 084d4a3b..1a7f0d1a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -131,7 +131,7 @@ def member_should_exist_and_be_active end def user_should_be_confirmed - return if current_user.confirmed? + return if !current_user || current_user.confirmed? redirect_to please_confirm_users_path end diff --git a/app/controllers/petitions_controller.rb b/app/controllers/petitions_controller.rb index 1fcbbb2a..005c29b0 100644 --- a/app/controllers/petitions_controller.rb +++ b/app/controllers/petitions_controller.rb @@ -8,9 +8,9 @@ def create OrganizationNotifier.new_petition(petition).deliver_now OrganizationNotifier.petition_sent(petition).deliver_now - flash[:notice] = 'Application sent' + flash[:notice] = t('petitions.application_status', status: t("petitions.status.sent")) else - flash[:error] = 'Something went wrong' + flash[:error] = t('errors.internal_server_error.description') end redirect_to organizations_path @@ -22,9 +22,9 @@ def update if petition.update(status: status) petition.user.add_to_organization(petition.organization) if status == 'accepted' - flash[:notice] = "Application #{status}" + flash[:notice] = t('petitions.application_status', status: t("petitions.status.#{status}")) else - flash[:error] = 'Something went wrong' + flash[:error] = t('errors.internal_server_error.description') end redirect_to manage_petitions_path diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 75ac944c..e0562469 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -38,4 +38,8 @@ def toggle_active_member_path(member) def can_toggle_active?(_member) superadmin? || admin? end + + def status_applications(status) + t('petitions.status_applications', status: t("petitions.status.#{status}").humanize) + end end diff --git a/app/views/application/menus/_organization_listings_menu.html.erb b/app/views/application/menus/_organization_listings_menu.html.erb index 57b3ccde..a95177c0 100644 --- a/app/views/application/menus/_organization_listings_menu.html.erb +++ b/app/views/application/menus/_organization_listings_menu.html.erb @@ -14,7 +14,7 @@
  • <%= link_to manage_petitions_path do %> <%= glyph 'list-alt' %> - <%= 'Manage Applications' %> + <%= t('petitions.applications') %> <% end %>
  • diff --git a/app/views/application/menus/_user_admin_menu_items.html.erb b/app/views/application/menus/_user_admin_menu_items.html.erb index f2d10c9b..cfbadd21 100644 --- a/app/views/application/menus/_user_admin_menu_items.html.erb +++ b/app/views/application/menus/_user_admin_menu_items.html.erb @@ -24,7 +24,7 @@
  • <%= link_to organizations_path do %> <%= glyph :list %> - Manage memberships + <%= t('layouts.application.manage_memberships') %> <% end %>
  • diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 2ecaac46..010677f1 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -43,11 +43,11 @@ - OR + <%= t('global.or').upcase %>
    - <%= link_to 'Sign up', signup_users_path, class: "btn btn-primary btn-lg col-xs-12" %> + <%= link_to t('devise.registrations.new.sign_up'), signup_users_path, class: "btn btn-primary btn-lg col-xs-12" %>
    diff --git a/app/views/organization_notifier/new_petition.html.erb b/app/views/organization_notifier/new_petition.html.erb index 43a265cd..783cb9df 100644 --- a/app/views/organization_notifier/new_petition.html.erb +++ b/app/views/organization_notifier/new_petition.html.erb @@ -1 +1 @@ -Hello! New petition from user <%= @user.username %>. manage your applications <%= link_to 'here', manage_petitions_url %>. +<%= t('petitions.new_body', username: @user.username, here_link: link_to(t('global.here'), manage_petitions_url)).html_safe %> diff --git a/app/views/organization_notifier/petition_sent.html.erb b/app/views/organization_notifier/petition_sent.html.erb index deb351cb..e63c3f70 100644 --- a/app/views/organization_notifier/petition_sent.html.erb +++ b/app/views/organization_notifier/petition_sent.html.erb @@ -1 +1 @@ -Hello! your application to <%= @organization_name %> has been sent correctly. +<%= t('petitions.application_sent_body', organization_name: @organization_name) %> diff --git a/app/views/organizations/_organizations_row.html.erb b/app/views/organizations/_organizations_row.html.erb index 232eb231..638204a8 100644 --- a/app/views/organizations/_organizations_row.html.erb +++ b/app/views/organizations/_organizations_row.html.erb @@ -9,15 +9,15 @@ <% petition = current_user.petitions.where(organization_id: org.id).last %> <% if member = Member.where(user: current_user, organization: org).first %> - <%= link_to 'Delete membership', + <%= link_to t('users.user_rows.delete_membership'), member, method: :delete, - data: { confirm: "Are you sure you want to delete your membership from #{org.name}?" }, + data: { confirm: t('users.user_rows.sure_delete', organization_name: org.name) }, class: 'btn btn-danger' %> <% elsif petition && !current_user.was_member?(petition) %> <%= petition.status %> <% else %> - <%= link_to 'Apply to join', petitions_path(user_id: current_user.id, organization_id: org.id, status: 'pending'), method: :post %> + <%= link_to t('petitions.apply'), petitions_path(user_id: current_user.id, organization_id: org.id, status: 'pending'), method: :post %> <% end %> <% end %> diff --git a/app/views/petitions/manage.html.erb b/app/views/petitions/manage.html.erb index 2b0500de..c09a3342 100644 --- a/app/views/petitions/manage.html.erb +++ b/app/views/petitions/manage.html.erb @@ -3,7 +3,7 @@

    <%= link_to current_organization.name, current_organization %> - <%= 'Applications' %> + <%= t('petitions.applications') %>

    @@ -15,19 +15,19 @@
  • "> <%= link_to manage_petitions_path(status: 'pending') do %> <%= glyph :minus %> - <%= 'Pending applications' %> + <%= status_applications('pending') %> <% end %>
  • "> <%= link_to manage_petitions_path(status: 'accepted') do %> <%= glyph :ok %> - <%= 'Accepted applications' %> + <%= status_applications('accepted') %> <% end %>
  • "> <%= link_to manage_petitions_path(status: 'declined') do %> <%= glyph :remove %> - <%= 'Declined applications' %> + <%= status_applications('declined') %> <% end %>
  • @@ -43,13 +43,13 @@ <%= 'ID' %> - <%= 'username' %> + <%= t('activerecord.attributes.user.username') %> <%= User.human_attribute_name(:email) %> <%= User.human_attribute_name(:phone) %> <% if current_user.manages?(current_organization) && @status == 'pending' %> - <%= t(".actions") %> + <%= t("global.table.actions") %> <% end %> @@ -65,8 +65,8 @@ <%= phone_to user.phone %> <% if current_user.manages?(current_organization) && @status == 'pending' %> - <%= link_to 'Accept', petition_path(id: petition.id, status: 'accepted'), class: 'btn btn-primary', method: :put %> - <%= link_to 'Decline', petition_path(id: petition.id, status: 'declined'), class: 'btn btn-danger', method: :put %> + <%= link_to t('terms.accept'), petition_path(id: petition.id, status: 'accepted'), class: 'btn btn-primary', method: :put %> + <%= link_to t('global.decline'), petition_path(id: petition.id, status: 'declined'), class: 'btn btn-danger', method: :put %> <% end %> <% end %> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 3a52b3cd..52b031a1 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -14,7 +14,7 @@ <% if short %>
    - +
    diff --git a/app/views/users/please_confirm.html.erb b/app/views/users/please_confirm.html.erb index 3a26821c..5660e9f7 100644 --- a/app/views/users/please_confirm.html.erb +++ b/app/views/users/please_confirm.html.erb @@ -1,2 +1,2 @@ -

    Please, confirm the email

    -An email has been sent to <%= current_user.email %>. After confirm you will be able to apply to any organization. +

    <%= t('users.confirm_email.please') %>

    +<%= t('users.confirm_email.email_sent', email: current_user.email) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 96f49810..3ef1bec6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -300,6 +300,9 @@ en: table: actions: Actions to: To + here: here + decline: decline + or: or inquiries: edit: submit: Change inquiry @@ -313,6 +316,7 @@ en: bdtnear: Search Timebank edit_org: Update %{organization} edit_profile: Update my profile + manage_memberships: Manage memberships help: Help login: Login report: @@ -502,6 +506,9 @@ en: new: error_amount: Time must be greater than 0 users: + confirm_email: + please: Please, confirm the email + email_sent: An email has been sent to %{email}. After confirm you will be able to apply to any organization. avatar: change_your_image: Change your image crop_the_image: Crop the image @@ -556,6 +563,8 @@ en: cancel_warning: You are going to delete account from the Time Bank for user %{user} deactivate: Deactivate manage_warning: You are going to change privileges for user %{user} + delete_membership: Delete membership + sure_delete: Are you sure you want to delete your membership from %{organization_name}? views: pagination: first: First @@ -563,3 +572,18 @@ en: next: Next previous: Previous truncate: Truncate + petitions: + status: + pending: pending + accepted: accepted + declined: declined + sent: sent + application_status: Application %{status} + status_applications: "%{status} applications" + application_sent: Application sent correctly + application_sent_body: Hello! your application to %{organization_name} has been sent correctly. + new: New Application + new_body: Hello! New petition from user %{username}. Manage your applications %{here_link}. + apply: Apply to join + applications: Applications + diff --git a/spec/controllers/petitions_controller_spec.rb b/spec/controllers/petitions_controller_spec.rb index b3612fca..be689706 100644 --- a/spec/controllers/petitions_controller_spec.rb +++ b/spec/controllers/petitions_controller_spec.rb @@ -1,7 +1,7 @@ RSpec.describe PetitionsController do let!(:organization) { Fabricate(:organization) } let(:user) { Fabricate(:user) } - let(:admin) { Fabricate(:member, organization: organization, manager: true) } + let!(:admin) { Fabricate(:member, organization: organization, manager: true) } describe 'POST #create' do before { login(user) }