From 2c4873075014e78513bf5ed4d62d57e98c404e4a Mon Sep 17 00:00:00 2001 From: f Date: Fri, 11 Sep 2020 12:31:53 -0300 Subject: [PATCH] al compilar el sitio volver al sitio --- app/controllers/sites_controller.rb | 41 +++++++++++++---------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 222d49b..a5d9032 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -18,7 +18,6 @@ class SitesController < ApplicationController # No tenemos propiedades de un sitio aún, así que vamos al listado de # artículos def show - site = find_site authorize site redirect_to site_posts_path(site) @@ -35,51 +34,47 @@ class SitesController < ApplicationController params: site_params) if (@site = service.create).persisted? - redirect_to site_path(@site) + redirect_to site_posts_path(@site) else render 'new' end end def edit - @site = find_site - authorize @site - SiteService.new(site: @site).build_deploys + authorize site + SiteService.new(site: site).build_deploys end def update - @site = find_site - authorize @site + authorize site - service = SiteService.new(site: @site, params: site_params, + service = SiteService.new(site: site, params: site_params, usuarie: current_usuarie) if service.update.valid? - redirect_to site_path(@site) + redirect_to site_posts_path(site) else render 'edit' end end def enqueue - site = find_site authorize site # XXX: Convertir en una máquina de estados? DeployJob.perform_async site.id if site.enqueue! - redirect_to sites_path + redirect_to site_posts_path(site) end def reorder_posts - @site = find_site - authorize @site + authorize site lang = params.require(:posts).require(:lang) result = if params[:posts][:force].present? - @site.reorder_collection! lang + site.reorder_collection! lang else - @site + site .reorder_collection(lang, params.require(:posts).require(:order)) end @@ -89,21 +84,19 @@ class SitesController < ApplicationController flash[:danger] = I18n.t('errors.posts.reorder') end - redirect_to site_posts_path @site + redirect_to site_posts_path(site) end def fetch - @site = find_site - authorize @site + authorize site - @commits = @site.repository.commits + @commits = site.repository.commits end def merge - @site = find_site - authorize @site + authorize site - if @site.repository.merge(current_usuarie) + if site.repository.merge(current_usuarie) flash[:success] = I18n.t('sites.fetch.merge.success') else flash[:error] = I18n.t('sites.fetch.merge.error') @@ -114,6 +107,10 @@ class SitesController < ApplicationController private + def site + @site ||= find_site + end + def site_params params.require(:site) .permit(:name, :design_id, :licencia_id, :description, :title,