From 2bab1d00d08a425c1857cd9fc7f5c62be536563c Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati Date: Sat, 17 Feb 2024 17:25:02 -0800 Subject: [PATCH 01/10] migration adds 'to' feld to email template database --- .../20240218005604_add_to_field_to_email_template.rb | 8 ++++++++ db/schema.rb | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240218005604_add_to_field_to_email_template.rb diff --git a/db/migrate/20240218005604_add_to_field_to_email_template.rb b/db/migrate/20240218005604_add_to_field_to_email_template.rb new file mode 100644 index 00000000..1aa60400 --- /dev/null +++ b/db/migrate/20240218005604_add_to_field_to_email_template.rb @@ -0,0 +1,8 @@ +class AddToFieldToEmailTemplate < ActiveRecord::Migration[6.1] + def change + add_column :email_templates, :to, :string + #below is the default prepopulated 'to' field value, + to_field = "{{teacher_email}}, {{teacher_personal_email}}" + EmailTemplate.update_all(to: to_field) + end +end diff --git a/db/schema.rb b/db/schema.rb index 5bd75815..d2dabf7e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_09_05_181019) do +ActiveRecord::Schema.define(version: 2024_02_18_005604) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -65,6 +65,7 @@ t.string "title" t.string "subject" t.boolean "required", default: false + t.string "to" end create_table "pages", force: :cascade do |t| From b1173d2f3176610d7fff33c37a2e94e841d23e18 Mon Sep 17 00:00:00 2001 From: Arush Chhatrapati Date: Sat, 17 Feb 2024 17:30:54 -0800 Subject: [PATCH 02/10] added to field to view and added a file I forgot to add from prev migration --- app/models/email_template.rb | 1 + app/views/email_templates/_form.html.erb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/email_template.rb b/app/models/email_template.rb index a8042c03..b94f0df0 100644 --- a/app/models/email_template.rb +++ b/app/models/email_template.rb @@ -14,6 +14,7 @@ # required :boolean default(FALSE) # subject :string # title :string +# to :string # created_at :datetime not null # updated_at :datetime not null # diff --git a/app/views/email_templates/_form.html.erb b/app/views/email_templates/_form.html.erb index 5a7a6e12..ce6df5f3 100644 --- a/app/views/email_templates/_form.html.erb +++ b/app/views/email_templates/_form.html.erb @@ -1,7 +1,10 @@ +<%# This part of the page is the email template form %> <%= form_with(model: email_template, local: true) do |form| %>
<%= form.text_field :title, class: "form-control", readonly: email_template.required? %> + + <%= form.text_field :to, class: "form-control" %> <%= form.text_field :subject, class: "form-control" %> @@ -12,7 +15,7 @@ <%= form.submit "Submit", class: "btn btn-primary" %>
<% end %> - +<%# This renders the section on "Allowed Tags" %> <%= render 'liquid_fields' %>