-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple languages for seed data in extension and form genera…
…ted seeds file.
- Loading branch information
Showing
2 changed files
with
47 additions
and
39 deletions.
There are no files selected for viewing
38 changes: 21 additions & 17 deletions
38
core/lib/generators/refinery/engine/templates/db/seeds.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
if defined?(::Refinery::User) | ||
::Refinery::User.all.each do |user| | ||
if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank? | ||
user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>', | ||
:position => (user.plugins.maximum(:position) || -1) +1) | ||
Refinery::I18n.frontend_locales.each do |lang| | ||
I18n.locale = lang | ||
|
||
if defined?(Refinery::User) | ||
Refinery::User.all.each do |user| | ||
if user.plugins.where(:name => 'refinerycms-<%= namespacing.underscore %>').blank? | ||
user.plugins.create(:name => 'refinerycms-<%= namespacing.underscore %>', | ||
:position => (user.plugins.maximum(:position) || -1) +1) | ||
end | ||
end | ||
end | ||
end | ||
|
||
<% unless skip_frontend? -%> | ||
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>" | ||
if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty? | ||
page = ::Refinery::Page.create( | ||
:title => '<%= class_name.pluralize.underscore.titleize %>', | ||
:link_url => url, | ||
:deletable => false, | ||
:menu_match => "^#{url}(\/|\/.+?|)$" | ||
) | ||
Refinery::Pages.default_parts.each_with_index do |default_page_part, index| | ||
page.parts.create(:title => default_page_part, :body => nil, :position => index) | ||
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>" | ||
if defined?(Refinery::Page) && Refinery::Page.where(:link_url => url).empty? | ||
page = Refinery::Page.create( | ||
:title => '<%= class_name.pluralize.underscore.titleize %>', | ||
:link_url => url, | ||
:deletable => false, | ||
:menu_match => "^#{url}(\/|\/.+?|)$" | ||
) | ||
Refinery::Pages.default_parts.each_with_index do |default_page_part, index| | ||
page.parts.create(:title => default_page_part, :body => nil, :position => index) | ||
end | ||
end | ||
end | ||
<% end -%> | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
if defined?(::Refinery::User) | ||
::Refinery::User.all.each do |user| | ||
if user.plugins.find_by_name('<%= plural_name %>').nil? | ||
user.plugins.create(:name => "<%= plural_name %>", | ||
:position => (user.plugins.maximum(:position) || -1) +1) | ||
Refinery::I18n.frontend_locales.each do |lang| | ||
I18n.locale = lang | ||
|
||
if defined?(Refinery::User) | ||
Refinery::User.all.each do |user| | ||
if user.plugins.find_by_name('<%= plural_name %>').nil? | ||
user.plugins.create(:name => "<%= plural_name %>", | ||
:position => (user.plugins.maximum(:position) || -1) +1) | ||
end | ||
end | ||
end | ||
end | ||
|
||
if defined?(::Refinery::Page) | ||
page = ::Refinery::Page.create( | ||
:title => "<%= class_name.pluralize.underscore.titleize %>", | ||
:link_url => "/<%= plural_name %>/new", | ||
:deletable => false, | ||
:menu_match => "^/<%= plural_name %>(\/|\/.+?|)$" | ||
) | ||
thank_you_page = page.children.create( | ||
:title => "Thank You", | ||
:link_url => "/<%= plural_name %>/thank_you", | ||
:deletable => false, | ||
:show_in_menu => false | ||
) | ||
Refinery::Pages.default_parts.each do |default_page_part| | ||
page.parts.create(:title => default_page_part, :body => nil) | ||
thank_you_page.parts.create(:title => default_page_part, :body => nil) | ||
if defined?(Refinery::Page) | ||
page = Refinery::Page.create( | ||
:title => "<%= class_name.pluralize.underscore.titleize %>", | ||
:link_url => "/<%= plural_name %>/new", | ||
:deletable => false, | ||
:menu_match => "^/<%= plural_name %>(\/|\/.+?|)$" | ||
) | ||
thank_you_page = page.children.create( | ||
:title => "Thank You", | ||
:link_url => "/<%= plural_name %>/thank_you", | ||
:deletable => false, | ||
:show_in_menu => false | ||
) | ||
Refinery::Pages.default_parts.each do |default_page_part| | ||
page.parts.create(:title => default_page_part, :body => nil) | ||
thank_you_page.parts.create(:title => default_page_part, :body => nil) | ||
end | ||
end | ||
end |