alembic 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 864fe17dcf35957dabe499ff889f3f44fc098598173050c29534ac3ad762abb5
4
- data.tar.gz: a1879e6b6a296e2a15a3a3dc101911cf39c6c2c8fc970b0f15ccd8ae556805e3
3
+ metadata.gz: 9ca021353e957d6825f69057128a3a92f154f048b89a2e26d94ff285f8b8a372
4
+ data.tar.gz: b6767fc9d270afb8de1ddb605e7f099904c64ab77af5da56f39591d82da62151
5
5
  SHA512:
6
- metadata.gz: abe6f2bf1e70df421b4f0b84f242ec2571c7783b025aa3f9667fe3ac708afa6760b1dc9e41e70916dc7f9624f12619ba0b49deb7d001a7e54f819cc6bc41efaa
7
- data.tar.gz: 4f9f163ee278fd30b93bb79b5bd3414e57595362d9fef0ff92e694fc2e1ed59dce8fdaf44a4cc4928d87055ef0afcc797fa33cea498b474f25f85f9f353e3e89
6
+ metadata.gz: 6f676f812331f3cd69ab8e8ff8c38cbabcfe66d4527ac7f8a1d18f81b7d9fa24803421ca57d3948cd8a0bbf2fd2e3de44ba7faa07484991d9975179ba31fbb9d
7
+ data.tar.gz: '009c8f96d9a90ca499cb9537a2e134a30290b21610b3ceeda23c57a115dcdd60db81773818cd9357a5ca8ccb00be31478efa1327e6baa83ca808d2b4b880b439'
@@ -5,6 +5,7 @@ module Alembic
5
5
  module Manage
6
6
  class BaseController < Alembic.base_controller.constantize
7
7
  include AuthenticatesAdmin
8
+ include OwnedPages
8
9
 
9
10
  layout -> { Alembic.admin_layout }
10
11
 
@@ -2,6 +2,7 @@ module Alembic
2
2
  module Manage
3
3
  class FlowsController < EasyFlow::Manage::FlowsController
4
4
  hosted_by FLOW_HOST
5
+ include OwnedPages
5
6
  helper Alembic::ApplicationHelper
6
7
  def edit
7
8
  super
@@ -15,15 +16,15 @@ module Alembic
15
16
  @shows_answer_values = summaries.shows_answer_values?
16
17
  @asks_on_one_page = summaries.asks_on_one_page?
17
18
  @branches = summaries.branches?
18
- @published_pages = Page.where(id: Page::Version.live.select(:page_id)).order(:name)
19
+ @published_pages = owned_pages.where(id: Page::Version.live.select(:page_id)).order(:name)
19
20
  end
20
21
 
21
22
  def update
22
23
  details = params.require(:flow)
23
24
  summaries = Flow::Summaries.new(flow_host.flows.find(params[:id]))
24
25
  summaries.describe(details[:summary]) unless details[:summary].nil?
25
- summaries.start_on(Page.find_by(id: details[:intro_page_id])) unless details[:intro_page_id].nil?
26
- summaries.finish_on(Page.find_by(id: details[:summary_page_id])) unless details[:summary_page_id].nil?
26
+ summaries.start_on(owned_pages.find_by(id: details[:intro_page_id])) unless details[:intro_page_id].nil?
27
+ summaries.finish_on(owned_pages.find_by(id: details[:summary_page_id])) unless details[:summary_page_id].nil?
27
28
  summaries.show_answer_values(details[:shows_answer_values] == "1") unless details[:shows_answer_values].nil?
28
29
  summaries.ask_on_one_page(details[:asks_on_one_page] == "1") unless details[:asks_on_one_page].nil?
29
30
  record_outputs(summaries, details[:outputs]) if details[:outputs]
@@ -8,7 +8,7 @@ module Alembic
8
8
  private
9
9
 
10
10
  def block_layout_record
11
- Page.find(params[:page_id])
11
+ owned_pages.find(params[:page_id])
12
12
  end
13
13
 
14
14
  def block_content(block)
@@ -2,11 +2,11 @@ module Alembic
2
2
  module Manage
3
3
  class PagesController < BaseController
4
4
  def index
5
- @pages = Page.order(:name)
5
+ @pages = owned_pages.order(:name)
6
6
  end
7
7
 
8
8
  def show
9
- @page = Page.find(params[:id])
9
+ @page = owned_pages.find(params[:id])
10
10
  @payload = payload(@page)
11
11
 
12
12
  respond_to do |format|
@@ -16,19 +16,19 @@ module Alembic
16
16
  end
17
17
 
18
18
  def create
19
- page = Page.create!(page_params)
19
+ page = owned_pages.create!(page_params)
20
20
  redirect_to manage_page_path(page)
21
21
  end
22
22
 
23
23
  def publish
24
- page = Page.find(params[:id])
24
+ page = owned_pages.find(params[:id])
25
25
  page.publish
26
26
 
27
27
  redirect_to manage_page_path(page)
28
28
  end
29
29
 
30
30
  def preview
31
- page = Page.find(params[:id])
31
+ page = owned_pages.find(params[:id])
32
32
  session[:alembic_preview] = session.fetch(:alembic_preview, {}).merge(page.id.to_s => params[:choice].presence)
33
33
 
34
34
  redirect_to manage_page_path(page)
@@ -1,5 +1,6 @@
1
1
  module Alembic
2
2
  class PagesController < ApplicationController
3
+ include OwnedPages
3
4
  helper PagesHelper
4
5
  helper KsBlocks::LayoutHelper
5
6
 
@@ -10,7 +11,7 @@ module Alembic
10
11
  private
11
12
 
12
13
  def shown_page
13
- page = Page.find_by(slug: params[:slug])
14
+ page = owned_pages.find_by(slug: params[:slug])
14
15
  raise NotPublished if page.nil? || page.live_version.nil?
15
16
 
16
17
  page
@@ -0,0 +1,11 @@
1
+ module Alembic
2
+ module OwnedPages
3
+ private
4
+
5
+ def owned_pages
6
+ return Page.all unless Alembic.owner_method
7
+
8
+ Page.where(owner: send(Alembic.owner_method))
9
+ end
10
+ end
11
+ end
@@ -9,7 +9,9 @@ module Alembic
9
9
  has_many :versions, class_name: "Alembic::Page::Version", dependent: :destroy, inverse_of: :page
10
10
 
11
11
  validates :name, presence: true
12
- validates :slug, uniqueness: true, allow_nil: true
12
+ belongs_to :owner, polymorphic: true, optional: true
13
+
14
+ validates :slug, uniqueness: { scope: [ :owner_type, :owner_id ] }, allow_nil: true
13
15
 
14
16
  def publish
15
17
  transaction do
@@ -0,0 +1,9 @@
1
+ class AddOwnerToAlembicPages < ActiveRecord::Migration[8.1]
2
+ def change
3
+ add_reference :alembic_pages, :owner, polymorphic: true, index: false
4
+ remove_index :alembic_pages, :slug, unique: true
5
+ add_index :alembic_pages, :slug, unique: true, where: "owner_id IS NULL", name: "index_alembic_pages_on_slug"
6
+ add_index :alembic_pages, [ :owner_type, :owner_id, :slug ], unique: true, where: "owner_id IS NOT NULL",
7
+ name: "index_alembic_pages_on_owner_and_slug"
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Alembic
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/alembic.rb CHANGED
@@ -10,11 +10,11 @@ module Alembic
10
10
 
11
11
  FLOW_HOST = :alembic
12
12
  FLOW_HOST_SETTINGS = %i[layout admin_layout admin_authentication_method
13
- visitor_authorization_method refusal_method].freeze
13
+ visitor_authorization_method refusal_method owner_method].freeze
14
14
 
15
15
  class << self
16
16
  attr_accessor :lead_address, :lead_fields_partial, :lead_note
17
- attr_reader :admin_authentication_method, :visitor_authorization_method, :refusal_method
17
+ attr_reader :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method
18
18
 
19
19
  FLOW_HOST_SETTINGS.each do |name|
20
20
  define_method(:"#{name}=") do |value|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alembic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.6'
60
+ version: '0.8'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.6'
67
+ version: '0.8'
68
68
  description: Alembic builds and runs data-driven interactive diagnostics — scored
69
69
  assessments and branching guides — that place a visitor on an outcome and capture
70
70
  the result. A runtime engine plus a UI builder.
@@ -90,6 +90,7 @@ files:
90
90
  - app/controllers/alembic/manage/previews_controller.rb
91
91
  - app/controllers/alembic/pages_controller.rb
92
92
  - app/controllers/concerns/alembic/manage/authenticates_admin.rb
93
+ - app/controllers/concerns/alembic/owned_pages.rb
93
94
  - app/controllers/concerns/alembic/summarizes.rb
94
95
  - app/helpers/alembic/application_helper.rb
95
96
  - app/helpers/alembic/content_blocks_helper.rb
@@ -208,7 +209,8 @@ files:
208
209
  - db/migrate/20260930120000_add_summary_page_to_alembic_flow_definition_summaries.rb
209
210
  - db/migrate/20260930230000_add_shows_answer_values_to_alembic_flow_definition_summaries.rb
210
211
  - db/migrate/20260930233000_add_asks_on_one_page_to_alembic_flow_definition_summaries.rb
211
- - db/migrate/20261001120000_add_intro_page_to_alembic_flow_definition_summaries.rb
212
+ - db/migrate/20261001120002_add_intro_page_to_alembic_flow_definition_summaries.rb
213
+ - db/migrate/20261001170001_add_owner_to_alembic_pages.rb
212
214
  - lib/alembic.rb
213
215
  - lib/alembic/engine.rb
214
216
  - lib/alembic/leftover_stylesheet.rb