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
5a3bfbdb
Commit
5a3bfbdb
authored
2 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
Fix #771
parent
0dff135d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website.rb
+1
-1
1 addition, 1 deletion
app/models/communication/website.rb
app/models/communication/website/with_menus.rb
+25
-5
25 additions, 5 deletions
app/models/communication/website/with_menus.rb
with
26 additions
and
6 deletions
app/models/communication/website.rb
+
1
−
1
View file @
5a3bfbdb
...
...
@@ -43,9 +43,9 @@ class Communication::Website < ApplicationRecord
include
WithGit
include
WithGitRepository
include
WithImport
include
WithMenus
include
WithProgramCategories
include
WithSpecialPages
include
WithMenus
# Menus must be created after special pages, so we can fill legal menu
include
WithStyle
include
WithTheme
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website/with_menus.rb
+
25
−
5
View file @
5a3bfbdb
...
...
@@ -7,7 +7,7 @@ module Communication::Website::WithMenus
foreign_key: :communication_website_id
,
dependent: :destroy
after_
creat
e
:initialize_menus
after_
sav
e
:initialize_menus
end
def
menu_item_kinds
...
...
@@ -65,14 +65,34 @@ module Communication::Website::WithMenus
def
initialize_menus
create_menu
'primary'
create_menu
'legal'
create_menu
'social'
menu
=
create_menu
'legal'
fill_legal_menu
menu
end
def
fill_legal_menu
(
menu
)
return
if
menu
.
items
.
any?
[
Communication
::
Website
::
Page
::
LegalTerm
,
Communication
::
Website
::
Page
::
PrivacyPolicy
,
Communication
::
Website
::
Page
::
Accessibility
,
Communication
::
Website
::
Page
::
Sitemap
].
each
do
|
page_class
|
page
=
special_page
(
page_class
)
menu
.
items
.
where
(
kind:
'page'
,
about:
page
,
university:
university
,
website:
self
)
.
first_or_create
do
|
item
|
item
.
title
=
page
.
title
end
end
end
def
create_menu
(
identifier
)
title
=
Communication
::
Website
::
Menu
.
human_attribute_name
(
identifier
)
menus
.
create
title:
title
,
identifier:
identifier
,
university:
university
menus
.
where
(
identifier:
identifier
,
university:
university
).
first_or_create
do
|
menu
|
menu
.
title
=
title
end
end
end
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