Skip to content

Commit b7c0c68

Browse files
committed
Add custom seed data config for BetterTogether::Wizard
1 parent ea3b6df commit b7c0c68

File tree

4 files changed

+208
-9
lines changed

4 files changed

+208
-9
lines changed

app/models/better_together/wizard.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# app/models/better_together/wizard.rb
44
module BetterTogether
5-
# Ordered step defintions that the user must complete
5+
# Ordered step definitions that the user must complete
66
class Wizard < ApplicationRecord
77
include Identifier
88
include Protected
@@ -19,14 +19,10 @@ class Wizard < ApplicationRecord
1919
validates :max_completions, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
2020
validates :current_completions, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
2121

22-
# Additional logic and methods as needed
23-
2422
def completed?
25-
# TODO: Adjust for wizards with multiple possible completions
2623
completed = wizard_steps.size == wizard_step_definitions.size &&
2724
wizard_steps.ordered.all?(&:completed)
28-
29-
mark_completed
25+
mark_completed if completed
3026
completed
3127
end
3228

@@ -39,9 +35,26 @@ def mark_completed
3935

4036
self.current_completions += 1
4137
self.last_completed_at = DateTime.now
42-
self.first_completed_at = DateTime.now if first_completed_at.nil?
43-
38+
self.first_completed_at ||= DateTime.now
4439
save
4540
end
41+
42+
# -------------------------------------
43+
# Overriding #plant for the Seedable concern
44+
# -------------------------------------
45+
def plant
46+
# Pull in the default fields from the base Seedable (model_class, record_id, etc.)
47+
super.merge(
48+
name: name,
49+
identifier: identifier,
50+
description: description,
51+
max_completions: max_completions,
52+
current_completions: current_completions,
53+
last_completed_at: last_completed_at,
54+
first_completed_at: first_completed_at,
55+
# Optionally embed your wizard_step_definitions so they're all in one seed
56+
step_definitions: wizard_step_definitions.map(&:plant)
57+
)
58+
end
4659
end
4760
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
defaults: { format: :html, locale: I18n.locale }
3232

3333
get 'search', to: 'search#search'
34+
3435
authenticated :user do # rubocop:todo Metrics/BlockLength
3536
resources :communities, only: %i[index show edit update]
3637
resources :conversations, only: %i[index new create show] do
@@ -135,7 +136,6 @@
135136
# Custom route for wizard steps
136137
get ':wizard_step_definition_id', to: 'wizard_steps#show', as: :step
137138
patch ':wizard_step_definition_id', to: 'wizard_steps#update'
138-
# Add other HTTP methbetter-together/community-engine-rails/app/controllers/better_together/bt
139139
end
140140

141141
scope path: :w do
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
better_together:
2+
version: "1.0"
3+
seed:
4+
type: "wizard"
5+
identifier: "host_setup"
6+
created_by: "Better Together Solutions"
7+
created_at: "2025-03-04T12:00:00Z"
8+
description: >
9+
This is The Seed file for the Host Setup Wizard. It guides the creation
10+
of a new community platform using the Community Engine.
11+
12+
origin:
13+
platforms:
14+
- name: "Community Engine"
15+
version: "1.0"
16+
url: "https://bebettertogether.ca"
17+
contributors:
18+
- name: "Robert Smith"
19+
role: "Creator"
20+
contact: "[email protected]"
21+
organization: "Better Together Solutions"
22+
license: "LGPLv3"
23+
usage_notes: >
24+
Created as part of the foundational work on Better Together's platform onboarding process.
25+
This seed may be reused, adapted, and redistributed with appropriate attribution under the terms of LGPLv3.
26+
27+
wizard:
28+
name: "Host Setup Wizard"
29+
identifier: "host_setup"
30+
description: "Initial setup wizard for configuring the host platform."
31+
max_completions: 1
32+
success_message: >
33+
Thank you! You have finished setting up your Better Together platform!
34+
Your platform manager account has been created successfully. Please check your
35+
email to confirm your address before signing in.
36+
success_path: "/"
37+
38+
steps:
39+
- identifier: "welcome"
40+
name: "Language, Welcome, Land & Data Sovereignty"
41+
description: >
42+
Set your language, understand data sovereignty, and read the land acknowledgment.
43+
form_class: "::BetterTogether::HostSetup::WelcomeForm"
44+
step_number: 1
45+
message: "Welcome! Let’s begin your journey."
46+
fields:
47+
- identifier: "locale"
48+
type: "locale_select"
49+
required: true
50+
label: "Select Your Language"
51+
52+
- identifier: "community_identity"
53+
name: "Community Identity"
54+
description: "Name your community and describe its purpose."
55+
form_class: "::BetterTogether::HostSetup::CommunityIdentityForm"
56+
step_number: 2
57+
message: "Let’s name your community and describe its purpose."
58+
fields:
59+
- identifier: "name"
60+
type: "string"
61+
required: true
62+
label: "Community Name"
63+
- identifier: "description"
64+
type: "text"
65+
required: true
66+
label: "Short Description"
67+
- identifier: "logo"
68+
type: "file"
69+
required: false
70+
label: "Upload a Logo"
71+
72+
- identifier: "privacy_settings"
73+
name: "Platform Access & Privacy"
74+
description: "Choose the platform URL and privacy settings."
75+
form_class: "::BetterTogether::HostSetup::PrivacySettingsForm"
76+
step_number: 3
77+
message: "Set your platform’s web address and decide who can visit."
78+
fields:
79+
- identifier: "url"
80+
type: "string"
81+
required: true
82+
label: "Platform URL"
83+
- identifier: "privacy"
84+
type: "select"
85+
required: true
86+
label: "Privacy Level"
87+
options: ["public", "private"]
88+
89+
- identifier: "admin_creation"
90+
name: "Platform Host Account"
91+
description: "Create the first administrator account."
92+
form_class: "::BetterTogether::HostSetup::AdministratorForm"
93+
step_number: 4
94+
message: "Create your first platform administrator account."
95+
fields:
96+
- identifier: "admin_name"
97+
type: "string"
98+
required: true
99+
label: "Administrator Name"
100+
- identifier: "email"
101+
type: "email"
102+
required: true
103+
label: "Administrator Email"
104+
- identifier: "password"
105+
type: "password"
106+
required: true
107+
label: "Password"
108+
- identifier: "password_confirmation"
109+
type: "password"
110+
required: true
111+
label: "Confirm Password"
112+
113+
- identifier: "time_zone"
114+
name: "Time Zone"
115+
description: "Set your platform’s time zone."
116+
form_class: "::BetterTogether::HostSetup::TimeZoneForm"
117+
step_number: 5
118+
message: "Set your platform’s time zone for accurate scheduling."
119+
fields:
120+
- identifier: "time_zone"
121+
type: "timezone_select"
122+
required: true
123+
label: "Select Your Time Zone"
124+
125+
- identifier: "purpose_and_features"
126+
name: "Purpose & Features"
127+
description: "Choose the initial purpose and features for your platform."
128+
form_class: "::BetterTogether::HostSetup::PurposeAndFeaturesForm"
129+
step_number: 6
130+
message: "What will your platform be used for? Choose features to match your needs."
131+
fields:
132+
- identifier: "purpose"
133+
type: "multi_select"
134+
required: true
135+
label: "Primary Purpose(s)"
136+
options: ["storytelling", "organizing", "resource_sharing", "mutual_aid", "other"]
137+
138+
- identifier: "first_welcome_page"
139+
name: "First Welcome Page"
140+
description: "Draft your first welcome message for visitors."
141+
form_class: "::BetterTogether::HostSetup::WelcomePageForm"
142+
step_number: 7
143+
message: "Write a welcoming message for your community’s front page."
144+
fields:
145+
- identifier: "welcome_message"
146+
type: "rich_text"
147+
required: true
148+
label: "Welcome Message"
149+
150+
- identifier: "review_and_launch"
151+
name: "Review & Launch"
152+
description: "Review your choices and launch your platform."
153+
form_class: "::BetterTogether::HostSetup::ReviewForm"
154+
step_number: 8
155+
message: "Review your choices and launch your platform when ready."
156+
fields: []

config/seeds/seed_example.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
better_together:
2+
version: "1.0"
3+
seed:
4+
type: "wizard"
5+
identifier: ""
6+
created_by: ""
7+
created_at: ""
8+
description: ""
9+
10+
origin:
11+
platforms: []
12+
contributors: []
13+
license: ""
14+
usage_notes: ""
15+
16+
wizard:
17+
name: ""
18+
identifier: ""
19+
description: ""
20+
max_completions: 1
21+
success_message: ""
22+
success_path: ""
23+
24+
steps: []
25+
translatable_attributes: [] # New list of attributes that expect translations (names, messages, etc.)
26+
27+
translations:
28+
en: {}
29+
fr: {}
30+
es: {}

0 commit comments

Comments
 (0)