diff --git a/app/models/pd_registration.rb b/app/models/pd_registration.rb index fdd0d292..5ecf2d55 100644 --- a/app/models/pd_registration.rb +++ b/app/models/pd_registration.rb @@ -30,11 +30,5 @@ class PdRegistration < ApplicationRecord validates :attended, inclusion: { in: [true, false] } def teacher_name - teacher = Teacher.find_by(id: teacher_id) - if teacher.present? - "#{teacher.first_name} #{teacher.last_name}" - else - "Teacher not found" - end - end + self.teacher.full_name end diff --git a/app/models/professional_development.rb b/app/models/professional_development.rb index 9467b217..8f37d5d2 100644 --- a/app/models/professional_development.rb +++ b/app/models/professional_development.rb @@ -16,12 +16,9 @@ # updated_at :datetime not null # class ProfessionalDevelopment < ApplicationRecord - VALID_STATES = %w[AL AK AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MT NE NV - NH NJ NM NY NC ND MP OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV WI WY].freeze - validates :name, :city, :country, :start_date, :end_date, presence: true validates :state, presence: true, if: -> { country == "US" } - validates :state, inclusion: { in: VALID_STATES, message: "%{value} is not a valid state" }, + validates :state, inclusion: { in: School::VALID_STATES, message: "%{value} is not a valid state" }, if: -> { country == "US" } validate :end_date_after_start_date diff --git a/app/models/teacher.rb b/app/models/teacher.rb index 265a48cf..a46a502e 100644 --- a/app/models/teacher.rb +++ b/app/models/teacher.rb @@ -218,8 +218,7 @@ def short_application_status end def self.user_from_omniauth(omniauth) - teacher = EmailAddress.find_by(email: omniauth.email.downcase)&.teacher - teacher + EmailAddress.find_by(email: omniauth.email.downcase)&.teacher end def try_append_ip(ip) @@ -292,8 +291,6 @@ def email end def primary_email - # ||:email this code is temporary for this PR: https://github.com/cs169/BJC-Teacher-Tracker-App/pull/49 - # to make sure at least original data in db still work and passed the existing tests email_addresses.find_by(primary: true)&.email end diff --git a/app/views/professional_developments/edit.html.erb b/app/views/professional_developments/edit.html.erb index 64f4f467..a5371faf 100644 --- a/app/views/professional_developments/edit.html.erb +++ b/app/views/professional_developments/edit.html.erb @@ -1,12 +1,8 @@ <%= provide(:h1, "Update #{@professional_development.name}") %> -<% if @professional_development.nil? %> -

Professional Development not found.

-<% else %> - <%= form_for @professional_development do |f| %> - <%= render 'professional_developments/form', f: f, professional_development: @professional_development %> -
- <%= f.submit 'Submit', {class: 'btn btn-primary', id: 'submit_button'} %> -
- <% end %> +<%= form_for @professional_development do |f| %> + <%= render 'professional_developments/form', f: f, professional_development: @professional_development %> +
+ <%= f.submit 'Submit', {class: 'btn btn-primary', id: 'submit_button'} %> +
<% end %> diff --git a/app/views/professional_developments/index.html.erb b/app/views/professional_developments/index.html.erb index ed1bb5b4..c5f45451 100644 --- a/app/views/professional_developments/index.html.erb +++ b/app/views/professional_developments/index.html.erb @@ -1,4 +1,4 @@ -<%= provide(:title, "BJC Schools") %> +<%= provide(:title, "BJC PD") %> <%= provide(:header_button, "New Professional Development") %> @@ -9,8 +9,6 @@ - - diff --git a/app/views/professional_developments/show.html.erb b/app/views/professional_developments/show.html.erb index 2ab41ba4..28f17cca 100644 --- a/app/views/professional_developments/show.html.erb +++ b/app/views/professional_developments/show.html.erb @@ -162,7 +162,6 @@ function setFormActionForUpdate(pdId, registrationId) { form.action = `/professional_developments/${pdId}/pd_registrations/${registrationId}`; - console.debug("Setting form action to:", form.action); form.method = 'post'; ensureMethodInput('patch'); } diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb index 6cb701aa..7bfe25d5 100644 --- a/app/views/schools/_form.html.erb +++ b/app/views/schools/_form.html.erb @@ -119,7 +119,7 @@ } else { stateTextfieldContainer.show(); - stateSelect.removeAttr('required') //else make state select not required + stateSelect.removeAttr('required'); stateSelectContainer.hide(); diff --git a/app/views/teachers/_form.html.erb b/app/views/teachers/_form.html.erb index 7c3cf65e..9f5098f9 100644 --- a/app/views/teachers/_form.html.erb +++ b/app/views/teachers/_form.html.erb @@ -80,7 +80,6 @@ status ONLY IF the person viewing this page is an admin. %> - <%# For now... only admins can enter/edit personal emails. %>
@@ -111,13 +110,13 @@ status ONLY IF the person viewing this page is an admin. %> <%= f.label :languages, "What language(s) are spoken in the classroom?", class: "label-required" %> <%= f.select( - :languages, - options_for_select(Teacher.language_options, @teacher.languages), - {}, - multiple: true, - include_blank: "Select an option", - class: 'selectize', required: true -) %> + :languages, + options_for_select(Teacher.language_options, @teacher.languages), + {}, + multiple: true, + include_blank: "Select an option", + class: 'selectize', required: true + ) %>
Start Date End Date Grade Level Actions