Class: AdminDefaultPagesMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/02_admin_default_pages.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



96
97
98
# File 'lib/migrations/02_admin_default_pages.rb', line 96

def self.down(site)
  site.pages.where(path: '/admin').first.destroy
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/migrations/02_admin_default_pages.rb', line 2

def self.up(site)
  home_page = site.pages.where(path: '/').first
  
  # root admin page
  admin = site.admin_root_pages.new
  admin.title = 'Admin'
  admin.parent = home_page
  admin.show_in_menus = false
  admin.save
  
  # pages
  pages = site.admin_tree_pages.new
  pages.title = 'Pages'
  pages.parent = admin
  pages.root = home_page
  pages.save
  
  # users
  users = site.admin_list_pages.new
  users.title = 'Users'
  users.parent = admin
  users.record_model = site.users
  name_col = users.columns.new
  name_col.name = 'name'
  name_col.style = 'Text'
  name_col.save
  email_col = users.columns.new
  email_col.name = 'email'
  email_col.style = 'Text'
  email_col.save
   = users.columns.new
  .name = 'created_at'
  .as = 'Signup Date'
  .style = 'Date'
  .default_sort = true
  .save
  users.save
  
  # edit
  edit_page = site.admin_editor_pages.new
  edit_page.title = 'Edit'
  edit_page.parent = admin
  edit_page.save
  
  # settings
  settings_page = site.admin_settings_pages.new
  settings_page.title = 'Settings'
  settings_page.parent = admin
  settings_page.save
  
  # syncing
  sync_page = site.admin_sync_pages.new
  sync_page.title = 'Sync'
  sync_page.parent = admin
  sync_page.save
  
  # login
   = site..new
  .title = 'Login'
  .page_layout = 'admin_login'
  .username_field = 'email'
  .redirect_to = admin
  .parent = admin
  .save
  
  # logout
  logout_page = site.logout_pages.new
  logout_page.title = 'Logout'
  logout_page.redirect_to = admin
  logout_page.parent = admin
  logout_page.save
  
  # nav
  nav = site.menus.new
  nav.root = admin
  nav.name = 'nav'
  edit_exc = nav.exceptions.new
  edit_exc.page = edit_page
  edit_exc.save
  settings_exc = nav.exceptions.new
  settings_exc.page = settings_page
  settings_exc.save
  sync_exc = nav.exceptions.new
  sync_exc.page = sync_page
  sync_exc.save
   = nav.exceptions.new
  .page = 
  .save
  logout_exc = nav.exceptions.new
  logout_exc.page = logout_page
  logout_exc.save
  nav.save
end