Skip to content

v3.12.0 #610

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 11 commits into from
Mar 26, 2021
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
12 changes: 8 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def authenticate_superuser!
superuser? || redirect_to(root_path)
end

# To get locate from client supplied information
# see http://guides.rubyonrails.org/i18n.html#setting-the-locale-from-the-client-supplied-information
def options_locale
current_user.try(:locale) ||
session[:locale] ||
Expand All @@ -103,15 +101,14 @@ def options_locale
end

def set_locale
# read locale from params, the session or the Accept-Language header
I18n.locale =
if params[:locale]
current_user.update(locale: params[:locale]) if current_user
params[:locale]
else
options_locale
end
# set in the session (so ppl can override what the browser sends)

session[:locale] = I18n.locale
end

Expand All @@ -123,4 +120,11 @@ def user_not_authorized
def resource_not_found
render 'errors/not_found', status: 404
end

def member_should_be_active
if !current_member.active
flash[:error] = I18n.t('users.index.account_deactivated')
redirect_to select_organization_path
end
end
end
4 changes: 4 additions & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def set_current
redirect_to root_path
end

def select_organization
@organizations = current_user.organizations
end

private

def load_resource
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class TagsController < ApplicationController
before_action :authenticate_user!, :member_should_be_active

def index
posts = Post.by_organization(current_organization)
@all_tags = posts.find_like_tag(params[:term])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_user!, :member_should_be_active

def index
search_and_load_members current_organization.members.active, { s: 'user_last_sign_in_at DESC' }
Expand Down
58 changes: 58 additions & 0 deletions app/views/organizations/select_organization.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<div class="panel panel-default table-responsive">
<div class="panel-body">
<table class='table table-hover table-condensed panel'>
<thead>
<tr>
<th><%= t 'activerecord.attributes.organization.name' %></th>
<th><%= t 'global.information' %></th>
<th><%= t 'global.enter_to_timebank' %></th>
</tr>
</thead>
<tbody>
<% @organizations.each_with_index do |organization, index| %>
<tr>
<td><%= organization.name %></td>
<td><a href='#' data-toggle='modal' data-target='#org_dialog<%= index %>'> <%= t 'global.show' %></a></td>
<td>
<% if current_user.active?(organization) %>
<%= link_to set_current_organization_path(organization), method: :post do %>
<%= glyph 'arrow-right' %>
<%= t 'application.landing.button' %>
<% end %>
<% else %>
<span class="label label-default"><%= t 'activerecord.attributes.user.deactivated' %></span>
<% end %>
</td>
</tr>

<div class='modal fade' id='org_dialog<%= index %>'>
<div class='modal-dialog modal-dialog-centered'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>X</button>
<h4 class='modal-title'><%= organization.name %></h4>
</div>
<div class='modal-body'>
<strong><%= t 'activerecord.attributes.organization.address' %>:</strong>
<%= organization.address %> <%= organization.neighborhood %> <%= organization.city %>
<br>
<strong><%= t 'activerecord.attributes.organization.phone' %>:</strong>
<%= organization.phone %>
<br>
<strong><%= t 'activerecord.attributes.organization.email '%>:</strong>
<%= organization.email %>
<br>
<strong>Web:</strong>
<a href="<%= organization.web %>"><%= organization.web %></a>
</div>
</div>
</div>
</div>
<% end %>
</tbody>
</table>
</div>
</div>
<div class='alert alert-info'>
* <%= t 'users.index.deactivated_warning' %>
</div>
4 changes: 2 additions & 2 deletions app/views/shared/_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<% end %>
</div>
</div>
<% if current_user && current_organization == post.organization %>
<% if current_user && current_organization == post.organization && current_user.active?(current_organization) %>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">
Expand Down Expand Up @@ -69,7 +69,7 @@
</div>
</div>
</div>
<% if !current_user || post.organization != current_organization %>
<% if !current_user || post.organization != current_organization || !current_user.active?(current_organization) %>
<div class="alert alert-info">
<%= t 'posts.show.info',
type: post.class.model_name.human,
Expand Down
4 changes: 1 addition & 3 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@
</div>
<div class="panel-body">
<% if @member.manager %>
<p class="danger">
ADMIN
</p>
<p><span class="label label-default">ADMIN</span></p>
<% end %>
<p>
<strong>
Expand Down
9 changes: 7 additions & 2 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ca:
alt_phone: Telèfon alternatiu
created_at: Creat
date_of_birth: Data de naixement
deactivated: Desactivat
description: Descripció
email: Correu
gender: Gènere
Expand Down Expand Up @@ -135,6 +136,7 @@ ca:
admin: Administrar
administration: Administració
adminshort: Admin
all_transfers: Totes les transferències
categories: Serveis
demographics: Dades demogràfiques
global_activity: Activitat global
Expand All @@ -146,7 +148,7 @@ ca:
reports: Informes
sign_out: Desconnectar
statistics: Estadístiques
statistics_all_transfers: Totes les transferències
statistics_all_transfers: Totes les Transferències
stats: Estadístiques
tags: Etiquetes
type_of_swaps: Tipus d'intercanvis
Expand Down Expand Up @@ -297,6 +299,7 @@ ca:
delete: Esborrar
demote: Convertir en usuari normal
edit: Modificar
enter_to_timebank: Entrar al Banc de Temps
filter: Filtre
from: Des de
give_time: Transferir temps
Expand Down Expand Up @@ -384,7 +387,7 @@ ca:
offered_by: Oferents
organization_notifier:
recent_posts:
subject: Boletín semanal
subject: Butlletí setmanal
text1: 'Últimas ofertas publicadas:'
text2: 'Últimas demandas publicadas:'
organizations:
Expand Down Expand Up @@ -528,12 +531,14 @@ ca:
give_time:
give_time: Donar Temps a
index:
account_deactivated: El teu compte ha estat desactivat per aquest Banc de Temps
actions: Accions
active_warning: Estàs a punt de canviar l'estat de l'usuari %{username}
active_warning_angular: Vas a canviar l'estat del compte de l'usuari {{username}}
cancel_warning: Estàs a punt d'esborrar el compte de l'usuari %{username}
cancel_warning_angular: Vas a eliminar del banc a l'usuari {{username}}
create: Crear nou usuari
deactivated_warning: 'Si creus que el vostre compte es podria haver desactivat per error, poseu-vos en contacte amb l''administrador amb la informació que es proporciona a continuació. '
manage_warning: Estàs a punt de canviar els permisos de l'usuari %{username}
manage_warning_angular: Vas a canviar els permisos de l'usuari {{username}}
members: Membres
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ en:
unconfirmed_email: Unconfirmed Email
updated_at: Updated
username: Name
deactivated: Deactivated
errors:
models:
organization:
Expand Down Expand Up @@ -300,6 +301,7 @@ en:
delete: Delete
demote: Demote to normal user
edit: Update
enter_to_timebank: Enter to timebank
filter: Filter
give_time: Time transfer
home: Home
Expand Down Expand Up @@ -535,6 +537,8 @@ en:
cancel_warning: You are going to delete account from the Time Bank for user %{username}
cancel_warning_angular: You are going to delete account from the Time Bank for user {{username}}
create: Create new user
account_deactivated: Your account have been deactivated from this timebank
deactivated_warning: If you think your account might have been deactivated by mistake, please contact the administrator with the information provided below.
manage_warning: You are going to change privileges for user %{username}
manage_warning_angular: You are going to change privileges for user {{username}}
user_created: User %{uid} %{name} saved
Expand Down
5 changes: 5 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ es:
alt_phone: Teléfono alternativo
created_at: Creado
date_of_birth: Fecha de nacimiento
deactivated: Desactivado
description: Descripción
email: Correo
gender: Género
Expand Down Expand Up @@ -135,6 +136,7 @@ es:
admin: Administrar
administration: Administración
adminshort: Admin
all_transfers: Todas las transferencias
categories: Servicios
demographics: Datos demográficos
global_activity: Actividad global
Expand Down Expand Up @@ -297,6 +299,7 @@ es:
delete: Borrar
demote: Convertir en usuario normal
edit: Modificar
enter_to_timebank: Entrar al Banco de Tiempo
filter: Filtro
from: De
give_time: Transferir tiempo
Expand Down Expand Up @@ -528,12 +531,14 @@ es:
give_time:
give_time: Dar Tiempo a
index:
account_deactivated: Tu cuenta ha sido desactivada para este Banco de Tiempo
actions: Acciones
active_warning: Estás a punto de cambiar el estado del usuario %{username}
active_warning_angular: Va a cambiar el estado de la cuenta del usuario {{username}}
cancel_warning: Estás a punto de borrar la cuenta al usuario %{username}
cancel_warning_angular: Va a eliminar del banco al usuario {{username}}
create: Crear nuevo usuario
deactivated_warning: 'Si crees que tu cuenta podría haber sido desactivada por error, comunícate con el administrador con la información que se proporciona a continuación. '
manage_warning: Estás a punto de cambiar los permisos del usuario %{username}
manage_warning_angular: Va a cambiar los privilegios del usuario {{username}}
members: Miembros
Expand Down
Loading