Class: SecurityAndHomePageMigration
- Inherits:
-
Migration
- Object
- Migration
- SecurityAndHomePageMigration
- Defined in:
- lib/migrations/site/03_security_and_home_page.rb
Class Method Summary collapse
Class Method Details
.down(site) ⇒ Object
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 95 96 97 98 99 100 101 102 |
# File 'lib/migrations/site/03_security_and_home_page.rb', line 63 def self.down(site) # remove the login nav menu exception nav = site..first(name: 'nav') login_ex = nav.exceptions.select {|ex| ex.page.path == '/login'} login_ex.destroy nav.save # login/logout pages site.pages.where(path: '/login').destroy site.pages.where(path: '/logout').destroy # reset homepage to a redirect page home = site.pages.where(path: '/').first home.model = site.redirect_pages home.url = '/users' home.save # remove auth site.sites_pages.modify do |sites_pages| sites_pages.view_group = site.groups['Guests'] sites_pages.create_group = site.groups['Guests'] sites_pages.update_group = site.groups['Guests'] sites_pages.delete_group = site.groups['Guests'] end site.users.modify do |users| sites_pages.view_group = site.groups['Guests'] sites_pages.create_group = site.groups['Guests'] sites_pages.update_group = site.groups['Guests'] sites_pages.delete_group = site.groups['Guests'] end users_page = site.pages.where(path: '/users').first users_page.model.modify do |users_page| sites_pages.view_group = site.groups['Guests'] sites_pages.create_group = site.groups['Guests'] sites_pages.update_group = site.groups['Guests'] sites_pages.delete_group = site.groups['Guests'] end 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 |
# File 'lib/migrations/site/03_security_and_home_page.rb', line 2 def self.up(site) # existing pages home = site.pages.where(path: '/').first sites_page = site.pages.where(path: '/sites').first # change home page to a normal page until editable production sites are ready home.model = site.pages home.page_layout = 'home' home.save # login page site.login_pages.create_model :production_login_page do |production_login_pages| production_login_pages.record_class_name = 'ProductionLoginPage' end login_page = site.production_login_pages.new login_page.title = 'Login' login_page.redirect_to = sites_page login_page.parent = home login_page.save # remove login from the nav menu nav = site..first(name: 'nav') login_ex = nav.exceptions.new login_ex.page = login_page login_ex.show = false login_ex.save nav.save # logout page logout_page = site.logout_pages.new logout_page.title = 'Logout' logout_page.redirect_to = home logout_page.parent = home logout_page.save # prevent guest html requests; the sites and git pages implement their # own auth for json requests site.sites_pages.modify do |sites_pages| sites_pages.view_group = site.groups['Administrators'] sites_pages.create_group = site.groups['Administrators'] sites_pages.update_group = site.groups['Administrators'] sites_pages.delete_group = site.groups['No One'] end site.users.modify do |users| users.view_group = site.groups['Administrators'] users.create_group = site.groups['Administrators'] users.update_group = site.groups['Administrators'] users.delete_group = site.groups['Administrators'] end users_page = site.pages.where(path: '/users').first users_page.model.modify do |users_page| users_page.view_group = site.groups['Administrators'] users_page.create_group = site.groups['Administrators'] users_page.update_group = site.groups['Administrators'] users_page.delete_group = site.groups['No One'] end end |