cms-fortress 1.2.2 → 1.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/.gitignore +66 -0
  2. data/Gemfile +2 -17
  3. data/Gemfile.lock +80 -90
  4. data/README.rdoc +11 -0
  5. data/Rakefile +9 -39
  6. data/app/controllers/cms/fortress/admin_controller.rb +5 -0
  7. data/app/controllers/cms/fortress/roles_controller.rb +11 -21
  8. data/app/controllers/cms/fortress/users_controller.rb +48 -31
  9. data/app/helpers/cms/fortress/application_helper.rb +37 -5
  10. data/app/helpers/comfy/admin/cms/pages_helper.rb +22 -0
  11. data/app/models/cms/fortress/error.rb +17 -0
  12. data/app/models/cms/fortress/role.rb +2 -1
  13. data/app/models/cms/fortress/settings.rb +17 -0
  14. data/app/models/cms/fortress/user.rb +17 -0
  15. data/app/models/cms_ability.rb +29 -22
  16. data/app/views/cms/fortress/admin/dashboard.html.haml +12 -0
  17. data/app/views/cms/fortress/shared/_dashboard_widget.html.haml +29 -0
  18. data/app/views/cms/fortress/shared/_menu.html.haml +26 -26
  19. data/app/views/cms/fortress/shared/_navbar.html.haml +1 -1
  20. data/app/views/cms/fortress/shared/_page_extend.html.haml +3 -5
  21. data/app/views/cms/fortress/shared/_page_extend_js.html.haml +2 -14
  22. data/app/views/cms/fortress/themes/wide/_body.html.haml +9 -8
  23. data/app/views/cms/fortress/themes/wide/_menu.html.haml +70 -37
  24. data/app/views/cms/fortress/users/_form.html.haml +6 -1
  25. data/app/views/cms/fortress/users/edit.html.haml +1 -2
  26. data/app/views/cms/fortress/users/index.html.haml +14 -5
  27. data/app/views/cms/fortress/users/new.html.haml +1 -2
  28. data/app/views/comfy/admin/cms/pages/_form.html.haml +10 -4
  29. data/app/views/comfy/admin/cms/pages/edit.html.haml +25 -0
  30. data/app/views/layouts/comfy/admin/cms/_head.html.haml +1 -1
  31. data/app/views/layouts/comfy/admin/cms/_left.html.haml +15 -12
  32. data/bin/bundle +3 -0
  33. data/bin/rails +4 -0
  34. data/bin/rake +4 -0
  35. data/cms-fortress.gemspec +32 -171
  36. data/config.ru +4 -0
  37. data/config/application.rb +34 -0
  38. data/config/boot.rb +5 -0
  39. data/config/cms/fortress/global_settings.yml +12 -0
  40. data/config/cms_routes.rb +7 -0
  41. data/config/database.yml +11 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +29 -0
  44. data/config/environments/test.rb +36 -0
  45. data/config/initializers/devise.rb +256 -0
  46. data/config/initializers/secret_token.rb +14 -0
  47. data/config/locales/de.yml +28 -1
  48. data/config/locales/devise.en.yml +59 -0
  49. data/config/locales/en.yml +37 -1
  50. data/config/roles.yml +1 -0
  51. data/config/secrets.yml +14 -0
  52. data/db/migrate/06_add_type_to_users.rb +11 -0
  53. data/db/migrate/07_integrate_workflow_into_cms_pages.rb +37 -0
  54. data/db/schema.rb +182 -0
  55. data/lib/assets/.keep +0 -0
  56. data/lib/cms-fortress.rb +10 -1
  57. data/lib/cms/fortress/application_controller_methods.rb +5 -2
  58. data/lib/cms/fortress/page_methods.rb +52 -2
  59. data/lib/cms/fortress/pages_controller_methods.rb +17 -0
  60. data/lib/cms/fortress/rails/engine.rb +12 -3
  61. data/lib/cms/fortress/routes/admin.rb +9 -1
  62. data/lib/cms/fortress/site_methods.rb +29 -0
  63. data/lib/cms/fortress/sites_controller_methods.rb +22 -0
  64. data/lib/generators/cms/comfy/comfy_generator.rb +18 -0
  65. data/lib/generators/cms/fortress/fortress_generator.rb +30 -6
  66. data/lib/generators/cms/fortress/upgrade/USAGE +8 -0
  67. data/lib/generators/cms/fortress/upgrade/upgrade_generator.rb +24 -0
  68. data/lib/tasks/.keep +0 -0
  69. data/test/{functional → controllers}/cms/fortress/roles_controller_test.rb +9 -4
  70. data/test/{functional → controllers}/cms/fortress/users_controller_test.rb +10 -11
  71. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +115 -0
  72. data/test/fixtures/cms/fortress/role_details.yml +89 -8
  73. data/test/fixtures/cms/fortress/roles.yml +17 -0
  74. data/test/fixtures/cms/fortress/users.yml +14 -0
  75. data/test/fixtures/comfy/cms/blocks.yml +12 -0
  76. data/test/fixtures/comfy/cms/categories.yml +4 -0
  77. data/test/fixtures/comfy/cms/categorizations.yml +3 -0
  78. data/test/fixtures/comfy/cms/files.yml +9 -0
  79. data/test/fixtures/comfy/cms/layouts.yml +40 -0
  80. data/test/fixtures/comfy/cms/pages.yml +105 -0
  81. data/test/fixtures/comfy/cms/revisions.yml +21 -0
  82. data/test/fixtures/comfy/cms/sites.yml +6 -0
  83. data/test/fixtures/comfy/cms/snippets.yml +6 -0
  84. data/test/integration/cms/fortress/users_controller_test.rb +16 -0
  85. data/test/models/comfy/cms/page_test.rb +84 -0
  86. data/test/models/comfy/cms/settings_test.rb +16 -0
  87. data/test/test_helper.rb +25 -0
  88. metadata +157 -23
  89. data/app/models/cms/page_workflow.rb +0 -44
  90. data/app/models/error/missing_role_configuration_file.rb +0 -12
  91. data/lib/generators/comfy/cms/cms_generator.rb +0 -60
  92. data/test/fixtures/cms/page_workflows.yml +0 -11
  93. data/test/helper.rb +0 -18
  94. data/test/test_cms-fortress.rb +0 -7
  95. data/test/unit/cms/fortress/role_detail_test.rb +0 -7
  96. data/test/unit/cms/fortress/role_test.rb +0 -7
  97. data/test/unit/cms/fortress/role_user_test.rb +0 -7
  98. data/test/unit/helpers/cms/fortress/roles_helper_test.rb +0 -4
  99. data/test/unit/helpers/cms/fortress/users_helper_test.rb +0 -4
@@ -0,0 +1,59 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your account was successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid email or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account will be locked."
15
+ not_found_in_database: "Invalid email or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your account before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock Instructions"
26
+ omniauth_callbacks:
27
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+ success: "Successfully authenticated from %{kind} account."
29
+ passwords:
30
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
+ updated: "Your password was changed successfully. You are now signed in."
34
+ updated_not_active: "Your password was changed successfully."
35
+ registrations:
36
+ destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
37
+ signed_up: "Welcome! You have signed up successfully."
38
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
41
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
42
+ updated: "You updated your account successfully."
43
+ sessions:
44
+ signed_in: "Signed in successfully."
45
+ signed_out: "Signed out successfully."
46
+ unlocks:
47
+ send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
48
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
49
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
50
+ errors:
51
+ messages:
52
+ already_confirmed: "was already confirmed, please try signing in"
53
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
54
+ expired: "has expired, please request a new one"
55
+ not_found: "not found"
56
+ not_locked: "was not locked"
57
+ not_saved:
58
+ one: "1 error prohibited this %{resource} from being saved:"
59
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -15,13 +15,28 @@ en:
15
15
  are_you_sure: Are you sure?
16
16
  cancel: Cancel
17
17
  published: Published
18
- cached_timeout: Cached Timeout
18
+ published_date: Published At
19
+ schedule_date: Scheduled Publication
20
+ cache_timeout: Cached Timeout
19
21
  toggle_navigation: Toggle Navigation
20
22
  image_selector: Image Selector
21
23
  insert_item: Click the thumbnail to insert item to the selected editor.
22
24
  settings: Settings
23
25
 
24
26
  admin:
27
+
28
+ dashboard:
29
+ title: Dashboard
30
+ draft_widget: Draft Pages
31
+ reviewed_widget: Reviewed Pages
32
+ updated_pages: Recently Updated Pages
33
+
34
+ sites:
35
+ menu_header: "Site/ %{site_name}"
36
+ super_user:
37
+ title: Super Users
38
+ menu_header: Super Users Only
39
+
25
40
  users: Users
26
41
  not_authorized: You are not authorized to access this functionality
27
42
  settings_dashboard: Settings Dashboard
@@ -64,6 +79,7 @@ en:
64
79
  users:
65
80
  title: Users
66
81
  new_link: New User
82
+ new_super_link: New Super User
67
83
  edit_title: Edit User
68
84
  new_title: Create New User
69
85
  last_name: Lastname
@@ -77,6 +93,17 @@ en:
77
93
  password: Password
78
94
  remember_me: Remember me
79
95
 
96
+ comfy:
97
+ admin:
98
+ cms:
99
+ pages:
100
+ form:
101
+ review: Approve
102
+ schedule: Publish Date
103
+ publish: Publish Now
104
+ draft: save as draft
105
+ reset: Reset to Draft
106
+
80
107
  activerecord:
81
108
  attributes:
82
109
  cms/fortress/user:
@@ -86,3 +113,12 @@ en:
86
113
  role_id: Role
87
114
  password: Password
88
115
  password_confirmation: Password Confirmation
116
+ cms/fortress/role:
117
+ name: Name
118
+ description: Description
119
+ cms/fortress/role_detail:
120
+ contents: Contents
121
+ comfy/cms/page:
122
+ full_path: Path
123
+ parent_id: Parent page
124
+ slug: Slug
data/config/roles.yml CHANGED
@@ -3,6 +3,7 @@ contents:
3
3
  - files
4
4
  - page.review
5
5
  - page.publish
6
+ - page.draft
6
7
  designs:
7
8
  - layouts
8
9
  - snippets
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ test:
14
+ secret_key_base: a8fb39f9880722d803b8c64f445123d50e9d408a8a5b9f70072849ff8bafd51b6d615f549b3a5d08a55f66f52384e2aa6fca0d3c24ea19a2340b3c6daa1d590b
@@ -0,0 +1,11 @@
1
+ class AddTypeToUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :cms_fortress_users, :type_id, :integer
4
+ add_column :cms_fortress_users, :site_id, :integer
5
+ add_column :cms_fortress_roles, :site_id, :integer
6
+ add_column :cms_fortress_role_details, :site_id, :integer
7
+ add_column :cms_page_workflows, :site_id, :integer
8
+
9
+ Cms::Fortress::User.update_all(type_id: 1)
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ class IntegrateWorkflowIntoCmsPages < ActiveRecord::Migration
2
+ class Cms::PageWorkflow < ActiveRecord::Base
3
+ self.table_name = 'cms_page_workflows'
4
+ belongs_to :page, :class_name => 'Comfy::Cms::Page', :foreign_key => 'cms_page_id'
5
+ end
6
+
7
+ def change
8
+
9
+ add_column :comfy_cms_pages, :aasm_state, :string, default: 'new'
10
+ add_column :comfy_cms_pages, :published_date, :date
11
+
12
+ Comfy::Cms::Page.reset_column_information
13
+
14
+ Cms::PageWorkflow.all.each do |workflow|
15
+ page = Comfy::Cms::Page.where(id: workflow.cms_page_id).first
16
+ if page
17
+ page.aasm_state = case workflow.status_id.to_i
18
+ when 0
19
+ 'drafted'
20
+ when 1
21
+ 'reviewed'
22
+ when 2
23
+ 'scheduled'
24
+ when 3
25
+ 'published'
26
+ else
27
+ 'drafted'
28
+ end
29
+ page.published_date = workflow.published_date
30
+ page.save!
31
+ end
32
+ end
33
+
34
+ # TODO: Just to make it safe workflow table will be removed on the 5th patch release
35
+ # drop_table :cms_page_workflows
36
+ end
37
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,182 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 7) do
15
+
16
+ create_table "cms_fortress_role_details", force: true do |t|
17
+ t.string "name"
18
+ t.string "command"
19
+ t.boolean "can_create"
20
+ t.boolean "can_update"
21
+ t.boolean "can_delete"
22
+ t.boolean "can_view"
23
+ t.integer "role_id"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
26
+ t.integer "site_id"
27
+ end
28
+
29
+ create_table "cms_fortress_roles", force: true do |t|
30
+ t.string "name"
31
+ t.text "description"
32
+ t.datetime "created_at"
33
+ t.datetime "updated_at"
34
+ t.integer "site_id"
35
+ end
36
+
37
+ create_table "cms_fortress_users", force: true do |t|
38
+ t.string "email", default: "", null: false
39
+ t.string "encrypted_password", default: "", null: false
40
+ t.integer "role_id"
41
+ t.string "reset_password_token"
42
+ t.datetime "reset_password_sent_at"
43
+ t.datetime "remember_created_at"
44
+ t.integer "sign_in_count", default: 0
45
+ t.datetime "current_sign_in_at"
46
+ t.datetime "last_sign_in_at"
47
+ t.string "current_sign_in_ip"
48
+ t.string "last_sign_in_ip"
49
+ t.string "first_name"
50
+ t.string "last_name"
51
+ t.datetime "created_at"
52
+ t.datetime "updated_at"
53
+ t.integer "type_id"
54
+ t.integer "site_id"
55
+ end
56
+
57
+ add_index "cms_fortress_users", ["email"], name: "index_cms_fortress_users_on_email", unique: true
58
+ add_index "cms_fortress_users", ["reset_password_token"], name: "index_cms_fortress_users_on_reset_password_token", unique: true
59
+
60
+ create_table "comfy_cms_blocks", force: true do |t|
61
+ t.string "identifier", null: false
62
+ t.text "content", limit: 16777215
63
+ t.integer "blockable_id"
64
+ t.string "blockable_type"
65
+ t.datetime "created_at"
66
+ t.datetime "updated_at"
67
+ end
68
+
69
+ add_index "comfy_cms_blocks", ["blockable_id", "blockable_type"], name: "index_comfy_cms_blocks_on_blockable_id_and_blockable_type"
70
+ add_index "comfy_cms_blocks", ["identifier"], name: "index_comfy_cms_blocks_on_identifier"
71
+
72
+ create_table "comfy_cms_categories", force: true do |t|
73
+ t.integer "site_id", null: false
74
+ t.string "label", null: false
75
+ t.string "categorized_type", null: false
76
+ end
77
+
78
+ add_index "comfy_cms_categories", ["site_id", "categorized_type", "label"], name: "index_cms_categories_on_site_id_and_cat_type_and_label", unique: true
79
+
80
+ create_table "comfy_cms_categorizations", force: true do |t|
81
+ t.integer "category_id", null: false
82
+ t.string "categorized_type", null: false
83
+ t.integer "categorized_id", null: false
84
+ end
85
+
86
+ add_index "comfy_cms_categorizations", ["category_id", "categorized_type", "categorized_id"], name: "index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id", unique: true
87
+
88
+ create_table "comfy_cms_files", force: true do |t|
89
+ t.integer "site_id", null: false
90
+ t.integer "block_id"
91
+ t.string "label", null: false
92
+ t.string "file_file_name", null: false
93
+ t.string "file_content_type", null: false
94
+ t.integer "file_file_size", null: false
95
+ t.string "description", limit: 2048
96
+ t.integer "position", default: 0, null: false
97
+ t.datetime "created_at"
98
+ t.datetime "updated_at"
99
+ end
100
+
101
+ add_index "comfy_cms_files", ["site_id", "block_id"], name: "index_comfy_cms_files_on_site_id_and_block_id"
102
+ add_index "comfy_cms_files", ["site_id", "file_file_name"], name: "index_comfy_cms_files_on_site_id_and_file_file_name"
103
+ add_index "comfy_cms_files", ["site_id", "label"], name: "index_comfy_cms_files_on_site_id_and_label"
104
+ add_index "comfy_cms_files", ["site_id", "position"], name: "index_comfy_cms_files_on_site_id_and_position"
105
+
106
+ create_table "comfy_cms_layouts", force: true do |t|
107
+ t.integer "site_id", null: false
108
+ t.integer "parent_id"
109
+ t.string "app_layout"
110
+ t.string "label", null: false
111
+ t.string "identifier", null: false
112
+ t.text "content", limit: 16777215
113
+ t.text "css", limit: 16777215
114
+ t.text "js", limit: 16777215
115
+ t.integer "position", default: 0, null: false
116
+ t.boolean "is_shared", default: false, null: false
117
+ t.datetime "created_at"
118
+ t.datetime "updated_at"
119
+ end
120
+
121
+ add_index "comfy_cms_layouts", ["parent_id", "position"], name: "index_comfy_cms_layouts_on_parent_id_and_position"
122
+ add_index "comfy_cms_layouts", ["site_id", "identifier"], name: "index_comfy_cms_layouts_on_site_id_and_identifier", unique: true
123
+
124
+ create_table "comfy_cms_pages", force: true do |t|
125
+ t.integer "site_id", null: false
126
+ t.integer "layout_id"
127
+ t.integer "parent_id"
128
+ t.integer "target_page_id"
129
+ t.string "label", null: false
130
+ t.string "slug"
131
+ t.string "full_path", null: false
132
+ t.text "content_cache", limit: 16777215
133
+ t.integer "position", default: 0, null: false
134
+ t.integer "children_count", default: 0, null: false
135
+ t.boolean "is_published", default: true, null: false
136
+ t.boolean "is_shared", default: false, null: false
137
+ t.datetime "created_at"
138
+ t.datetime "updated_at"
139
+ t.integer "cached_timeout", default: 0
140
+ t.string "aasm_state", default: "new"
141
+ t.date "published_date"
142
+ end
143
+
144
+ add_index "comfy_cms_pages", ["parent_id", "position"], name: "index_comfy_cms_pages_on_parent_id_and_position"
145
+ add_index "comfy_cms_pages", ["site_id", "full_path"], name: "index_comfy_cms_pages_on_site_id_and_full_path"
146
+
147
+ create_table "comfy_cms_revisions", force: true do |t|
148
+ t.string "record_type", null: false
149
+ t.integer "record_id", null: false
150
+ t.text "data", limit: 16777215
151
+ t.datetime "created_at"
152
+ end
153
+
154
+ add_index "comfy_cms_revisions", ["record_type", "record_id", "created_at"], name: "index_cms_revisions_on_rtype_and_rid_and_created_at"
155
+
156
+ create_table "comfy_cms_sites", force: true do |t|
157
+ t.string "label", null: false
158
+ t.string "identifier", null: false
159
+ t.string "hostname", null: false
160
+ t.string "path"
161
+ t.string "locale", default: "en", null: false
162
+ t.boolean "is_mirrored", default: false, null: false
163
+ end
164
+
165
+ add_index "comfy_cms_sites", ["hostname"], name: "index_comfy_cms_sites_on_hostname"
166
+ add_index "comfy_cms_sites", ["is_mirrored"], name: "index_comfy_cms_sites_on_is_mirrored"
167
+
168
+ create_table "comfy_cms_snippets", force: true do |t|
169
+ t.integer "site_id", null: false
170
+ t.string "label", null: false
171
+ t.string "identifier", null: false
172
+ t.text "content", limit: 16777215
173
+ t.integer "position", default: 0, null: false
174
+ t.boolean "is_shared", default: false, null: false
175
+ t.datetime "created_at"
176
+ t.datetime "updated_at"
177
+ end
178
+
179
+ add_index "comfy_cms_snippets", ["site_id", "identifier"], name: "index_comfy_cms_snippets_on_site_id_and_identifier", unique: true
180
+ add_index "comfy_cms_snippets", ["site_id", "position"], name: "index_comfy_cms_snippets_on_site_id_and_position"
181
+
182
+ end
data/lib/assets/.keep ADDED
File without changes
data/lib/cms-fortress.rb CHANGED
@@ -1,13 +1,17 @@
1
1
  require 'comfortable_mexican_sofa'
2
2
  require 'devise'
3
3
  require 'cancan'
4
+ require 'aasm'
4
5
  require 'tinymce-rails'
5
6
 
6
7
  require_relative 'comfortable_mexican_sofa/fixture/page'
7
8
 
8
9
  require_relative 'cms/fortress/application_controller_methods'
10
+ require_relative 'cms/fortress/sites_controller_methods'
11
+ require_relative 'cms/fortress/pages_controller_methods'
9
12
  require_relative 'cms/fortress/page_methods'
10
13
  require_relative 'cms/fortress/file_methods'
14
+ require_relative 'cms/fortress/site_methods'
11
15
  require_relative 'cms/fortress/rails/engine'
12
16
  require_relative 'cms/fortress/auth'
13
17
  require_relative 'cms/fortress/content_renderer'
@@ -46,8 +50,13 @@ module Cms
46
50
  :path => 'comfy_admin_cms_site_snippets_path(@site) if @site && !@site.new_record?'}
47
51
  ]
48
52
  @settings_resources = [
53
+ {name: 'dropdown-header', title: "cms.fortress.admin.super_user.menu_header", super_user: true},
49
54
  {:name => 'sites', :title => 'comfy.admin.cms.base.sites',
50
- :path => 'comfy_admin_cms_sites_path'},
55
+ :path => 'comfy_admin_cms_sites_path', :super_user => true},
56
+ {:name => 'super_users', :title => 'cms.fortress.admin.super_user.title',
57
+ :path => 'super_cms_fortress_users_path', :super_user => true},
58
+ {name: 'divider', super_user: true},
59
+ {name: 'dropdown-header', title: "cms.fortress.admin.sites.menu_header"},
51
60
  {:name => 'roles', :title => 'cms.fortress.roles.title',
52
61
  :path => 'cms_fortress_roles_path'},
53
62
  {:name => 'users', :title => 'cms.fortress.users.title',
@@ -4,7 +4,9 @@ module Cms
4
4
 
5
5
  def after_sign_in_path_for(resource)
6
6
  if resource.class.eql?(Cms::Fortress::User)
7
- comfy_admin_cms_path
7
+ session[:site_id] = resource.site_id
8
+ #comfy_admin_cms_path
9
+ dashboard_site_path
8
10
  else
9
11
  begin
10
12
  stored_location_for(resource) || send("after_sign_in_path_for_#{ resource.class.name.underscore }", resource)
@@ -17,7 +19,8 @@ module Cms
17
19
  def after_sign_out_path_for(resource_or_scope)
18
20
  # request.referrer
19
21
  if resource_or_scope.eql?(:cms_fortress_user)
20
- comfy_admin_cms_path
22
+ # comfy_admin_cms_path
23
+ dashboard_site_path
21
24
  else
22
25
  begin
23
26
  stored_location_for(resource_or_scope) || send("after_sign_out_path_for_#{ resource_or_scope.to_s }", resource_or_scope)
@@ -5,8 +5,58 @@ module Cms
5
5
  def self.included(base)
6
6
 
7
7
  base.class_eval do
8
- has_one :page_workflow, :class_name => "Cms::PageWorkflow", :foreign_key => 'cms_page_id'
9
- accepts_nested_attributes_for :page_workflow
8
+ before_create { self.draft if self.new? }
9
+
10
+ include AASM
11
+
12
+ aasm do
13
+ state :new, initial: true
14
+ state :drafted
15
+ state :reviewed
16
+ state :scheduled
17
+ state :published, before_enter: :check_publish_date
18
+
19
+ event :draft do
20
+ after :publish_page?
21
+ transitions from: :new, to: :drafted
22
+ end
23
+
24
+ event :review do
25
+ after :publish_page?
26
+ transitions from: [:new, :drafted], to: :reviewed
27
+ end
28
+
29
+ event :schedule do
30
+ after :publish_page?
31
+ transitions from: [:new, :drafted, :reviewed], to: :scheduled, guard: :published_date?
32
+ end
33
+
34
+ event :publish do
35
+ after :publish_page?
36
+ transitions from: [:new, :drafted, :reviewed, :scheduled], to: :published
37
+ end
38
+
39
+ event :reset do
40
+ after :publish_page?
41
+ transitions from: [:reviewed, :scheduled, :published], to: :drafted
42
+ end
43
+ end
44
+
45
+ def check_publish_date
46
+ self.published_date = Time.now unless self.published_date
47
+ end
48
+
49
+ def publish_page?
50
+ ret = false
51
+ if self.published?
52
+ ret = true
53
+ else
54
+ if self.scheduled? && self.published_date.present? && self.published_date <= Date.today
55
+ ret = true
56
+ end
57
+ end
58
+ self.is_published = ret
59
+ end
10
60
 
11
61
  end
12
62