Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
99e8a20c
Commit
99e8a20c
authored
3 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
categories ok
parent
4877dc00
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/admin/communication/website/categories_controller.rb
+4
-5
4 additions, 5 deletions
...lers/admin/communication/website/categories_controller.rb
app/models/communication/website/category.rb
+23
-19
23 additions, 19 deletions
app/models/communication/website/category.rb
with
27 additions
and
24 deletions
app/controllers/admin/communication/website/categories_controller.rb
+
4
−
5
View file @
99e8a20c
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website/category.rb
+
23
−
19
View file @
99e8a20c
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment