Skip to content
Snippets Groups Projects
Commit 99e8a20c authored by Arnaud Levy's avatar Arnaud Levy
Browse files

categories ok

parent 4877dc00
No related branches found
No related tags found
No related merge requests found
...@@ -22,8 +22,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication ...@@ -22,8 +22,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication
skip_github_publication: true skip_github_publication: true
) )
end end
github = Github.with_website @website categories.first.sync_with_git
github.send_batch_to_website(categories, message: '[Category] Reorder categories.')
end end
def children def children
...@@ -54,7 +53,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication ...@@ -54,7 +53,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication
def create def create
@category.website = @website @category.website = @website
if @category.save if @category.save_and_sync
redirect_to admin_communication_website_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s) redirect_to admin_communication_website_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s)
else else
breadcrumb breadcrumb
...@@ -63,7 +62,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication ...@@ -63,7 +62,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication
end end
def update def update
if @category.update(category_params) if @category.update_and_sync(category_params)
redirect_to admin_communication_website_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s) redirect_to admin_communication_website_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s)
else else
breadcrumb breadcrumb
...@@ -73,7 +72,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication ...@@ -73,7 +72,7 @@ class Admin::Communication::Website::CategoriesController < Admin::Communication
end end
def destroy def destroy
@category.destroy @category.destroy_and_sync
redirect_to admin_communication_website_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) redirect_to admin_communication_website_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s)
end end
......
...@@ -37,25 +37,25 @@ class Communication::Website::Category < ApplicationRecord ...@@ -37,25 +37,25 @@ class Communication::Website::Category < ApplicationRecord
include WithSlug # We override slug_unavailable? method include WithSlug # We override slug_unavailable? method
include WithTree include WithTree
has_one :imported_category, has_one :imported_category,
class_name: 'Communication::Website::Imported::Category', class_name: 'Communication::Website::Imported::Category',
dependent: :destroy dependent: :destroy
belongs_to :university belongs_to :university
belongs_to :website, belongs_to :website,
foreign_key: :communication_website_id foreign_key: :communication_website_id
belongs_to :parent, belongs_to :parent,
class_name: 'Communication::Website::Category', class_name: 'Communication::Website::Category',
optional: true optional: true
belongs_to :program, belongs_to :program,
class_name: 'Education::Program', class_name: 'Education::Program',
optional: true optional: true
has_one :imported_category, has_one :imported_category,
class_name: 'Communication::Website::Imported::Category', class_name: 'Communication::Website::Imported::Category',
dependent: :destroy dependent: :destroy
has_many :children, has_many :children,
class_name: 'Communication::Website::Category', class_name: 'Communication::Website::Category',
foreign_key: :parent_id, foreign_key: :parent_id,
dependent: :destroy dependent: :destroy
has_and_belongs_to_many :posts, has_and_belongs_to_many :posts,
class_name: 'Communication::Website::Post', class_name: 'Communication::Website::Post',
join_table: 'communication_website_categories_posts', join_table: 'communication_website_categories_posts',
...@@ -83,6 +83,10 @@ class Communication::Website::Category < ApplicationRecord ...@@ -83,6 +83,10 @@ class Communication::Website::Category < ApplicationRecord
"content/categories/#{path}/_index.html".gsub(/\/+/, '/') "content/categories/#{path}/_index.html".gsub(/\/+/, '/')
end end
def git_dependencies(identifier)
posts
end
def update_children_paths def update_children_paths
children.each do |child| children.each do |child|
child.update_column :path, child.generated_path child.update_column :path, child.generated_path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment