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

al compilar el sitio volver al sitio

This commit is contained in:
f 2020-09-11 12:31:53 -03:00
parent d3f21dd150
commit 2c48730750

View file

@ -18,7 +18,6 @@ class SitesController < ApplicationController
# No tenemos propiedades de un sitio aún, así que vamos al listado de # No tenemos propiedades de un sitio aún, así que vamos al listado de
# artículos # artículos
def show def show
site = find_site
authorize site authorize site
redirect_to site_posts_path(site) redirect_to site_posts_path(site)
@ -35,51 +34,47 @@ class SitesController < ApplicationController
params: site_params) params: site_params)
if (@site = service.create).persisted? if (@site = service.create).persisted?
redirect_to site_path(@site) redirect_to site_posts_path(@site)
else else
render 'new' render 'new'
end end
end end
def edit def edit
@site = find_site authorize site
authorize @site SiteService.new(site: site).build_deploys
SiteService.new(site: @site).build_deploys
end end
def update 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) usuarie: current_usuarie)
if service.update.valid? if service.update.valid?
redirect_to site_path(@site) redirect_to site_posts_path(site)
else else
render 'edit' render 'edit'
end end
end end
def enqueue def enqueue
site = find_site
authorize site authorize site
# XXX: Convertir en una máquina de estados? # XXX: Convertir en una máquina de estados?
DeployJob.perform_async site.id if site.enqueue! DeployJob.perform_async site.id if site.enqueue!
redirect_to sites_path redirect_to site_posts_path(site)
end end
def reorder_posts def reorder_posts
@site = find_site authorize site
authorize @site
lang = params.require(:posts).require(:lang) lang = params.require(:posts).require(:lang)
result = if params[:posts][:force].present? result = if params[:posts][:force].present?
@site.reorder_collection! lang site.reorder_collection! lang
else else
@site site
.reorder_collection(lang, params.require(:posts).require(:order)) .reorder_collection(lang, params.require(:posts).require(:order))
end end
@ -89,21 +84,19 @@ class SitesController < ApplicationController
flash[:danger] = I18n.t('errors.posts.reorder') flash[:danger] = I18n.t('errors.posts.reorder')
end end
redirect_to site_posts_path @site redirect_to site_posts_path(site)
end end
def fetch def fetch
@site = find_site authorize site
authorize @site
@commits = @site.repository.commits @commits = site.repository.commits
end end
def merge 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') flash[:success] = I18n.t('sites.fetch.merge.success')
else else
flash[:error] = I18n.t('sites.fetch.merge.error') flash[:error] = I18n.t('sites.fetch.merge.error')
@ -114,6 +107,10 @@ class SitesController < ApplicationController
private private
def site
@site ||= find_site
end
def site_params def site_params
params.require(:site) params.require(:site)
.permit(:name, :design_id, :licencia_id, :description, :title, .permit(:name, :design_id, :licencia_id, :description, :title,