diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c8e1f0146..5fae18839 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? + after_filter :store_location include Pundit protect_from_forgery @@ -30,16 +31,28 @@ def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) << :username end + def store_location + # store last url - this is needed for post-login redirect to whatever the + # user last visited. + return unless request.get? + paths = ["/users/sign_in", "/users/sign_up", "/users/password/new", + "/users/password/edit", "/users/confirmation", "/users/sign_out"] + if !paths.include?(request.path) && !request.xhr? + session[:previous_url] = request.fullpath + end + end + def after_sign_in_path_for(user) - if user.members.present? - if user.members.any? &:manager - users_path + session[:previous_url] || + if user.members.present? + if user.members.any? &:manager + users_path + else + users_path + end else - users_path + page_path("home") end - else - page_path("home") - end end private diff --git a/app/views/offers/show.html.haml b/app/views/offers/show.html.haml index ee44015ac..8a8af86cc 100644 --- a/app/views/offers/show.html.haml +++ b/app/views/offers/show.html.haml @@ -10,7 +10,7 @@ = link_to @offer, data: {method: :DELETE, confirm: "sure?" }, :class => "btn btn-danger" do = glyph :trash = t ".delete" - - else + - elsif current_user = link_to(give_time_user_path(@offer.user, offer: @offer.id), {:class => "btn btn-success"}) do = glyph(:time) = t "global.give_time" diff --git a/app/views/shared/_post.html.haml b/app/views/shared/_post.html.haml index 2f1d74ffd..60447f1e1 100644 --- a/app/views/shared/_post.html.haml +++ b/app/views/shared/_post.html.haml @@ -26,8 +26,10 @@ = t '.created_at' = l post.created_at.to_date, format: :short - .col-md-9 - - %p.lead= post.description + +- unless current_user + .alert.alert-info + = t("posts.show.info", type: post.class.model_name.human, organization: post.organization.name) + = link_to t("layouts.application.login"), new_user_session_path, class: "btn btn-primary" diff --git a/config/locales/ca.yml b/config/locales/ca.yml index e8a0d1a9e..7eb3c4350 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -187,8 +187,10 @@ ca: tags: alpha_grouped_index: maintitle: "Etiquetes Disponibles" + terms: accept: Acceptar + offers: index: offered_by: "Ofertat per %{size} persones" @@ -207,6 +209,10 @@ ca: new: submit: Crear demanda + posts: + show: + info: "%{type} de %{organization} per veure les dades de la persona has de" + categories: index: all: Totes diff --git a/config/locales/en.yml b/config/locales/en.yml index a6f1eed4e..a6f2b2d9e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -187,8 +187,10 @@ en: tags: alpha_grouped_index: maintitle: Available Tags + terms: accept: Accept + offers: index: offered_by: "Offered by %{size} people" @@ -210,6 +212,10 @@ en: submit: Create inquiry edit: submit: Change inquiry + + posts: + show: + info: "%{type} of %{organization} to see person's details you have to" categories: index: all: All diff --git a/config/locales/es.yml b/config/locales/es.yml index 1c04c0d55..7e2a3f1cb 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -187,8 +187,10 @@ es: tags: alpha_grouped_index: maintitle: "Etiquetas Disponibles" + terms: accept: Aceptar + offers: index: offered_by: "Ofrecido por %{size} personas" @@ -210,6 +212,11 @@ es: submit: Crear demanda edit: submit: Cambiar demanda + + posts: + show: + info: "%{type} de %{organization} para ver los datos de la persona tienes que" + categories: index: all: Todas