Skip to content

translation keys & minor fixes #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/petitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<li>
<%= link_to manage_petitions_path do %>
<%= glyph 'list-alt' %>
<%= 'Manage Applications' %>
<%= t('petitions.applications') %>
<% end %>
</li>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<li role="presentation">
<%= link_to organizations_path do %>
<%= glyph :list %>
Manage memberships
<%= t('layouts.application.manage_memberships') %>
<% end %>
</li>

Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
</div>
</div>
</div>
OR
<%= t('global.or').upcase %>
<div class="form-group">
<div class="row">
<div class="col-xs-12">
<%= 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" %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/organization_notifier/new_petition.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
2 changes: 1 addition & 1 deletion app/views/organization_notifier/petition_sent.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hello! your application to <%= @organization_name %> has been sent correctly.
<%= t('petitions.application_sent_body', organization_name: @organization_name) %>
6 changes: 3 additions & 3 deletions app/views/organizations/_organizations_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</td>
Expand Down
16 changes: 8 additions & 8 deletions app/views/petitions/manage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-md-12">
<h1>
<%= link_to current_organization.name, current_organization %>
<%= 'Applications' %>
<%= t('petitions.applications') %>
</h1>
</div>
</div>
Expand All @@ -15,19 +15,19 @@
<li class="<%= "active" if @status == 'pending' %>">
<%= link_to manage_petitions_path(status: 'pending') do %>
<%= glyph :minus %>
<%= 'Pending applications' %>
<%= status_applications('pending') %>
<% end %>
</li>
<li class="<%= "active" if @status == 'accepted' %>">
<%= link_to manage_petitions_path(status: 'accepted') do %>
<%= glyph :ok %>
<%= 'Accepted applications' %>
<%= status_applications('accepted') %>
<% end %>
</li>
<li class="<%= "active" if @status == 'declined' %>">
<%= link_to manage_petitions_path(status: 'declined') do %>
<%= glyph :remove %>
<%= 'Declined applications' %>
<%= status_applications('declined') %>
<% end %>
</li>
</ul>
Expand All @@ -43,13 +43,13 @@
<tr>
<th></th>
<th><%= 'ID' %></th>
<th><%= 'username' %></th>
<th><%= t('activerecord.attributes.user.username') %></th>
<th><%= User.human_attribute_name(:email) %></th>
<th><%= User.human_attribute_name(:phone) %></th>
<% if current_user.manages?(current_organization) && @status == 'pending' %>
<th>
<span class="glyphicon glyphicon-hand-down"></span>
<%= t(".actions") %>
<%= t("global.table.actions") %>
</th>
<% end %>
</tr>
Expand All @@ -65,8 +65,8 @@
<td><%= phone_to user.phone %></td>
<% if current_user.manages?(current_organization) && @status == 'pending' %>
<td>
<%= 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 %>
</td>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<% if short %>
<div class="form-group password required user_password">
<label class="password required control-label" for="user_password"><abbr title="required">*</abbr> Password</label>
<label class="password required control-label" for="user_password"><abbr title="required">*</abbr> <%= t('application.login_form.password') %></label>
<div class="input__password-eye">
<input class="form-control password required form-control" required="required" aria-required="true" type="password" name="user[password]" id="user_password">
<span class="show-password">
Expand Down
4 changes: 2 additions & 2 deletions app/views/users/please_confirm.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h1>Please, confirm the email</h1>
An email has been sent to <%= current_user.email %>. After confirm you will be able to apply to any organization.
<h1><%= t('users.confirm_email.please') %></h1>
<%= t('users.confirm_email.email_sent', email: current_user.email) %>
24 changes: 24 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ en:
table:
actions: Actions
to: To
here: here
decline: decline
or: or
inquiries:
edit:
submit: Change inquiry
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -556,10 +563,27 @@ 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
last: Last
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

2 changes: 1 addition & 1 deletion spec/controllers/petitions_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down