Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed May 10, 2024
2 parents ed3d7d5 + 2f7823d commit dbd7417
Show file tree
Hide file tree
Showing 21 changed files with 232 additions and 175 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Publish Code Climate
run: |
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
$CCTR sum-coverage coverage/codeclimate.*.json
$CCTR upload-coverage --id "$CC_TEST_REPORTER_ID"
# - name: Publish Code Climate
# run: |
# export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
# $CCTR sum-coverage coverage/codeclimate.*.json
# $CCTR upload-coverage --id "${{ secrets.CC_TEST_REPORTER_ID }}"
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.2.3" # TODO: use file: '.tool-versions' when heroku supports it. (bundler >= 2.5)

gem "rails", "6.1.7.6"
gem "rails", "6.1.7.7"

# Production app server
gem "puma", "~> 5"
Expand Down
114 changes: 57 additions & 57 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,62 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
actioncable (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailbox (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
mail (>= 2.7.1)
actionmailer (6.1.7.6)
actionpack (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailer (6.1.7.7)
actionpack (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activesupport (= 6.1.7.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.7.6)
actionview (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionpack (6.1.7.7)
actionview (= 6.1.7.7)
activesupport (= 6.1.7.7)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.7.6)
actionpack (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actiontext (6.1.7.7)
actionpack (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
nokogiri (>= 1.8.5)
actionview (6.1.7.6)
activesupport (= 6.1.7.6)
actionview (6.1.7.7)
activesupport (= 6.1.7.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.7.6)
activesupport (= 6.1.7.6)
activejob (6.1.7.7)
activesupport (= 6.1.7.7)
globalid (>= 0.3.6)
activemodel (6.1.7.6)
activesupport (= 6.1.7.6)
activerecord (6.1.7.6)
activemodel (= 6.1.7.6)
activesupport (= 6.1.7.6)
activemodel (6.1.7.7)
activesupport (= 6.1.7.7)
activerecord (6.1.7.7)
activemodel (= 6.1.7.7)
activesupport (= 6.1.7.7)
activerecord-import (1.4.0)
activerecord (>= 4.2)
activestorage (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activesupport (= 6.1.7.6)
activestorage (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activesupport (= 6.1.7.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.6)
activesupport (6.1.7.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -374,7 +374,7 @@ GEM
puma (5.6.8)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8)
rack (2.2.8.1)
rack-mini-profiler (2.3.3)
rack (>= 1.2.0)
rack-protection (3.2.0)
Expand All @@ -384,20 +384,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.6)
actioncable (= 6.1.7.6)
actionmailbox (= 6.1.7.6)
actionmailer (= 6.1.7.6)
actionpack (= 6.1.7.6)
actiontext (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activemodel (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
rails (6.1.7.7)
actioncable (= 6.1.7.7)
actionmailbox (= 6.1.7.7)
actionmailer (= 6.1.7.7)
actionpack (= 6.1.7.7)
actiontext (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activemodel (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
bundler (>= 1.15.0)
railties (= 6.1.7.6)
railties (= 6.1.7.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -410,9 +410,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
railties (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand All @@ -421,7 +421,7 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.6.2)
rdoc (6.6.3.1)
psych (>= 4.0.0)
regexp_parser (2.8.2)
reline (0.4.2)
Expand Down Expand Up @@ -528,7 +528,7 @@ GEM
temple (0.8.2)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.0)
thor (1.3.1)
thread_safe (0.3.6)
tilt (2.0.10)
timeout (0.4.1)
Expand Down Expand Up @@ -598,7 +598,7 @@ DEPENDENCIES
pronto-rubocop
puma (~> 5)
rack-mini-profiler (~> 2.0)
rails (= 6.1.7.6)
rails (= 6.1.7.7)
rails-controller-testing
rspec-rails
rubocop
Expand Down
17 changes: 17 additions & 0 deletions app/controllers/concerns/school_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module SchoolParams
private
def unique_school_params
{
name: school_params[:name],
country: school_params[:country],
city: school_params[:city],
state: school_params[:state]
}
end

def school_params
params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type, :country, { tags: [] }, :nces_id)
end
end
4 changes: 2 additions & 2 deletions app/controllers/email_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update
flash[:success] = "Updated #{@email_template.title} template successfully."
redirect_to email_templates_path
else
flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(', ')}"
flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(", ")}"
render "edit"
end
end
Expand All @@ -36,7 +36,7 @@ def create
flash[:success] = "Created #{@email_template.title} successfully."
redirect_to email_templates_path
else
flash[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(', ')}"
flash.now[:alert] = "An error occurred: #{@email_template.errors.full_messages.join(", ")}"
render "new"
end
end
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def index
elsif is_teacher? && !current_user.validated?
message = "Your application is #{mapped_application_status(current_user.application_status)}. You may update your information. Please check your email for more information."
# Both `info_needed` and `not_reviewed` flash message should be flash[:warn] style
# flash[:warn] for yellow warning message in bootstrap style
redirect_to edit_teacher_path(current_user.id), warn: message
# if this user is denied, redirect to new
else
Expand All @@ -35,8 +34,7 @@ def mapped_application_status(status)
status_map = {
"info_needed" => "requested to be updated",
"not_reviewed" => "not reviewed"
}
# Fetch the mapped status if present; otherwise, return the original status
}.with_indifferent_access
status_map.fetch(status, status)
end
end
9 changes: 3 additions & 6 deletions app/controllers/schools_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class SchoolsController < ApplicationController
include SchoolParams
before_action :require_admin

def index
Expand All @@ -12,11 +13,11 @@ def show
end

def search
School.all.collect { |school| ["#{school.name}, #{school.country}, #{school.city}, #{school.state}", school.name] }
School.search_list
end

def create
@school = School.find_by(name: school_params[:name], country: school_params[:country], city: school_params[:city], state: school_params[:state])
@school = School.find_by(**unique_school_params)
if @school
@school.assign_attributes(school_params)
else
Expand Down Expand Up @@ -64,10 +65,6 @@ def destroy
end

private
def school_params
params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type, :country, { tags: [] }, :nces_id)
end

def load_ordered_schools
@ordered_schools ||= School.all.order(:name)
end
Expand Down
13 changes: 5 additions & 8 deletions app/controllers/teachers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "activerecord-import"

class TeachersController < ApplicationController
include SchoolParams
include CsvProcess

before_action :load_pages, only: [:new, :create, :edit, :update]
Expand Down Expand Up @@ -57,9 +58,10 @@ def create

load_school
if @school.new_record?
return unless params[:school]
@school = School.new(school_params)
unless @school.save
flash[:alert] = "An error occurred! #{@school.errors.full_messages.join(', ')}"
flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}"
render "new" && return
end
end
Expand Down Expand Up @@ -103,7 +105,7 @@ def update
@school.update(school_params) if school_params
unless @school.save
flash[:alert] = "An error occurred: #{@school.errors.full_messages.join(', ')}"
render "new" && return
render "edit" && return
end
@teacher.school = @school
end
Expand Down Expand Up @@ -247,7 +249,7 @@ def load_school
if teacher_params[:school_id].present?
@school ||= School.find(teacher_params[:school_id])
end
@school ||= School.find_or_create_by(name: school_params[:name], city: school_params[:city], country: school_params[:country], state: school_params[:state])
@school ||= School.find_or_create_by(**unique_school_params)
end

def teacher_params
Expand All @@ -259,11 +261,6 @@ def teacher_params
params.require(:teacher).permit(*teacher_attributes)
end

def school_params
return unless params[:school]
params.require(:school).permit(:name, :country, :city, :state, :website, :grade_level, :school_type)
end

def omniauth_data
@omniauth_data ||= session[:auth_data]&.slice("first_name", "last_name", "email")
end
Expand Down
1 change: 0 additions & 1 deletion app/mailers/teacher_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def liquid_assigns
base_rules = {
bjc_password: Rails.application.secrets[:bjc_password],
piazza_password: Rails.application.secrets[:piazza_password],
# TODO: Review if below two are needed, or can they be refractored?
denial_reason: @denial_reason,
request_reason: @request_reason
}
Expand Down
Loading

0 comments on commit dbd7417

Please sign in to comment.