5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 00:56:21 +00:00

autorizar acceso a traduccion

This commit is contained in:
f 2019-07-03 21:51:44 -03:00
parent c804d386f0
commit 847b798a82
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 10 additions and 5 deletions

View file

@ -18,6 +18,7 @@ Metrics/AbcSize:
- 'app/controllers/sites_controller.rb' - 'app/controllers/sites_controller.rb'
- 'app/controllers/posts_controller.rb' - 'app/controllers/posts_controller.rb'
- 'app/controllers/invitadxs_controller.rb' - 'app/controllers/invitadxs_controller.rb'
- 'app/controllers/i18n_controller.rb'
Metrics/MethodLength: Metrics/MethodLength:
Exclude: Exclude:
@ -27,6 +28,7 @@ Metrics/MethodLength:
- 'app/controllers/sites_controller.rb' - 'app/controllers/sites_controller.rb'
- 'app/controllers/posts_controller.rb' - 'app/controllers/posts_controller.rb'
- 'app/controllers/invitadxs_controller.rb' - 'app/controllers/invitadxs_controller.rb'
- 'app/controllers/i18n_controller.rb'
Metrics/BlockLength: Metrics/BlockLength:
Exclude: Exclude:

View file

@ -6,15 +6,16 @@ class I18nController < ApplicationController
before_action :authenticate_usuarie! before_action :authenticate_usuarie!
def index def index
authorize :i18n
@site = find_site @site = find_site
authorize SiteTranslation.new(@site)
redirect_to site_i18n_edit_path(@site) redirect_to site_i18n_edit_path(@site)
end end
def edit def edit
authorize :i18n
@site = find_site @site = find_site
authorize SiteTranslation.new(@site)
@lang_from = params.fetch(:from, I18n.locale.to_s) @lang_from = params.fetch(:from, I18n.locale.to_s)
@lang_to = params.fetch(:to, @lang_from) @lang_to = params.fetch(:to, @lang_from)
@options = I18n.available_locales.map do |lang| @options = I18n.available_locales.map do |lang|
@ -23,15 +24,17 @@ class I18nController < ApplicationController
end end
def update def update
authorize :i18n
@site = find_site @site = find_site
authorize SiteTranslation.new(@site)
@lang_to = params.require(:i18n).require(:lang_to) @lang_to = params.require(:i18n).require(:lang_to)
# No usamos params porque nos obliga a hacer una lista blanca de # No usamos params porque nos obliga a hacer una lista blanca de
# todos los parámetros que queremos, pero no tenemos forma aun de # todos los parámetros que queremos, pero no tenemos forma aun de
# pasarse a permit un array de todas las keys y sus tipos en base al # pasarse a permit un array de todas las keys y sus tipos en base al
# idioma que ya existe # idioma que ya existe
p = request.parameters[:i18n][@lang_to] i = JekyllI18n.new(site: @site,
i = JekyllI18n.new(site: @site, lang: @lang_to, attributes: p) lang: @lang_to,
attributes: request.parameters[:i18n][@lang_to])
if i.save if i.save
redirect_to site_path(@site) redirect_to site_path(@site)