From 154b93fd2af050f4c81e051c81afef101836484c Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 3 Jan 2022 22:35:58 +0100 Subject: [PATCH] post can be saved --- .../admin/communication/website/posts_controller.rb | 2 ++ app/services/git/providers/github.rb | 13 ++----------- .../communication/website/posts/static.html.erb | 2 ++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/communication/website/posts_controller.rb b/app/controllers/admin/communication/website/posts_controller.rb index 8e5e72a86..309996e3f 100644 --- a/app/controllers/admin/communication/website/posts_controller.rb +++ b/app/controllers/admin/communication/website/posts_controller.rb @@ -28,6 +28,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def create @post.website = @website if @post.save + @post.sync_with_git redirect_to admin_communication_website_post_path(@post), notice: t('admin.successfully_created_html', model: @post.to_s) else breadcrumb @@ -37,6 +38,7 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web def update if @post.update(post_params) + @post.sync_with_git redirect_to admin_communication_website_post_path(@post), notice: t('admin.successfully_updated_html', model: @post.to_s) else breadcrumb diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 714e65953..78fea8cb2 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -53,13 +53,8 @@ class Git::Providers::Github @client ||= Octokit::Client.new access_token: access_token end - def access_token - @access_token ||= website&.access_token - end - - # Path of the repo - def repository - @repository ||= website&.repository + def batch + @batch ||= [] end def default_branch @@ -74,10 +69,6 @@ class Git::Providers::Github @tree ||= client.tree repository, branch_sha, recursive: true end - def batch - @batch ||= [] - end - def git_sha(path) begin content = client.content repository, path: path diff --git a/app/views/admin/communication/website/posts/static.html.erb b/app/views/admin/communication/website/posts/static.html.erb index 308ab2a29..19c9445b1 100644 --- a/app/views/admin/communication/website/posts/static.html.erb +++ b/app/views/admin/communication/website/posts/static.html.erb @@ -5,8 +5,10 @@ slug: "<%= @post.slug %>" <% if @post.pinned %> weight: 1 <% end %> +<% if @post.author %> persons: - "<%= @post.author.slug %>" +<% end %> <% if @post.categories.any? %> categories: <% @post.categories.each do |category| %> -- GitLab