Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS169L SP24: Iter 2-4 Changes #314

Merged
merged 108 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
4af15e7
added languages dropdown without selectize
ArushC Mar 14, 2024
db87716
added selectize thingie
ArushC Mar 14, 2024
59eb515
fix migration to accept array typefor languages
ArushC Mar 14, 2024
0124653
link selectize to backend
ArushC Mar 14, 2024
b39901f
display languages on edit page and prevent creating new languages
ArushC Mar 14, 2024
9210f08
Add starter code for pd frontend
perryzjc Mar 17, 2024
a194ed6
Backup work for frontend
perryzjc Mar 18, 2024
292e245
Backup frontend work
perryzjc Mar 18, 2024
4ee54b6
Back temporary work for frontend
perryzjc Mar 18, 2024
c0e5634
Rename workshop to professional developments
perryzjc Mar 20, 2024
12b28ac
Add new fields to mock model for pd
perryzjc Mar 20, 2024
21e8587
Implemented frontend for pd registrations
perryzjc Mar 20, 2024
669e1a2
Refract and clean up current frontend code
perryzjc Mar 20, 2024
8a34159
minor delete unnecessary comment
ArushC Mar 21, 2024
ce2c40a
minor comment change
ArushC Mar 22, 2024
291715c
added relevant cucumber step and reverted back to older version of code
ArushC Mar 22, 2024
ddce701
finished testing for languages feature and added backend validations
ArushC Mar 22, 2024
8117d90
Merge pull request #44 from cs169/187242903/features/pd-frontend
JacksonXu33 Mar 22, 2024
edfedf5
crud, but no schema yet
JacksonXu33 Mar 23, 2024
1a6c703
add comments
JacksonXu33 Mar 30, 2024
08273f2
link registrations and pd and teacher
JacksonXu33 Mar 30, 2024
c9f448a
Merge pull request #46 from cs169/187227079/features/pd-backend
perryzjc Apr 2, 2024
99623ba
uncommented out procfile
ArushC Apr 2, 2024
6f33d63
ok actually uncommented out this time
ArushC Apr 2, 2024
5853ab1
clean up comment
ArushC Apr 2, 2024
227842a
Add test for teacher edit teacher without mandatory field
perryzjc Apr 2, 2024
b1a128a
Remove debuger from production code
perryzjc Apr 2, 2024
6f6f7b5
Remove redundant comment
perryzjc Apr 2, 2024
8a049fe
fix merge conflict
ArushC Apr 2, 2024
4e2b40c
make comment more formal
ArushC Apr 4, 2024
3b1625f
Implement backend model & migration
perryzjc Apr 4, 2024
67dfaf5
Adjust frontend view to align with backend implementation
perryzjc Apr 4, 2024
abd5e9f
Implement backend controller
perryzjc Apr 4, 2024
fe605ba
Fix rubocop check
perryzjc Apr 4, 2024
3484fb1
add equivalent of presence validation
ArushC Apr 5, 2024
0480057
Merge pull request #47 from cs169/187227068-languages-feature
ArushC Apr 5, 2024
809ce23
Merge remote-tracking branch 'origin' into cleanup-schools-bug-fix
ArushC Apr 5, 2024
e2785ed
Merge pull request #45 from cs169/cleanup-schools-bug-fix
ArushC Apr 5, 2024
12479b7
Fix title issue
perryzjc Apr 5, 2024
66ac823
Shorthand PD name on navbar
perryzjc Apr 5, 2024
d26123d
Remove past event validation
perryzjc Apr 5, 2024
788c1f5
Fix minor details on views
perryzjc Apr 5, 2024
27351f1
Add cucumber tests
perryzjc Apr 5, 2024
a6a1c01
Remove debugging msg
perryzjc Apr 6, 2024
9e122ed
Fix indexing & uniqueness check for pd
perryzjc Apr 6, 2024
700c87e
Add rspec tests
perryzjc Apr 6, 2024
dbeb705
Add admin check for pd registrations
perryzjc Apr 6, 2024
afe77cc
Backup model updates
perryzjc Apr 7, 2024
47f2799
Finish model updates
perryzjc Apr 8, 2024
8f7d9ec
Update seed data
perryzjc Apr 8, 2024
b0b20cd
Update controllers
perryzjc Apr 8, 2024
a2bf8dc
Update frontend
perryzjc Apr 8, 2024
e7e88b4
Update fixtures
perryzjc Apr 8, 2024
9e2d47e
Update cucumber tests
perryzjc Apr 8, 2024
96ba6e5
Update rspec tests
perryzjc Apr 8, 2024
9de1f36
Fix code for email usage in the session
perryzjc Apr 8, 2024
a486c25
Change email regex to the rail default email regex
perryzjc Apr 8, 2024
d62937c
Remove email validation due to original email format problem
perryzjc Apr 8, 2024
2c15429
fix update path bug for admins, and some refactor
JacksonXu33 Apr 9, 2024
6d4a956
Revert back the email validation
perryzjc Apr 9, 2024
81b15db
Adjust personal email handling for this PR
perryzjc Apr 9, 2024
358140a
Kept original email column in teacher for this PR
perryzjc Apr 10, 2024
a1fc144
Change order to improve readability
perryzjc Apr 11, 2024
a825a5f
Clean up naming & data handling
perryzjc Apr 11, 2024
63dd1ab
Shorten code finding teacher
perryzjc Apr 11, 2024
793733b
Clarify and shorten primary email update logic
perryzjc Apr 11, 2024
74b8b83
Fix typo
perryzjc Apr 11, 2024
ee559cc
Refract param handling
perryzjc Apr 11, 2024
9099abd
add more helper methods to update and create
JacksonXu33 Apr 11, 2024
54eebc6
fix school bug in create method
JacksonXu33 Apr 12, 2024
30294f6
Add email data migration script
perryzjc Apr 13, 2024
6eae9a5
Merge pull request #49 from cs169/187384622/new-email-model
perryzjc Apr 13, 2024
3788f17
Improve edge case handling
perryzjc Apr 13, 2024
0748edd
Merge branch 'main' of github.com:cs169/BJC-Teacher-Tracker-App into …
perryzjc Apr 13, 2024
122c23e
Remove email deletion
perryzjc Apr 15, 2024
26a8b6a
Add migration to drop teacher email relevant column
perryzjc Apr 15, 2024
41dacda
Add migration to drop teacher email relevant column
perryzjc Apr 15, 2024
02f32bb
Remove other dependencies on old teacher email column
perryzjc Apr 15, 2024
119fb61
Backup some frontend change for multi personal emails
perryzjc Apr 15, 2024
60cd4d9
Merge pull request #50 from cs169/187384622/new-email-model-pr2
perryzjc Apr 15, 2024
a01775d
handle merge conflicts
JacksonXu33 Apr 16, 2024
4a330dc
Merge pull request #53 from cs169/187375265/fix-teachers-controller
ArushC Apr 17, 2024
565307d
Merge pull request #52 from cs169/187384622/new-email-model-pr3
ArushC Apr 17, 2024
b4b2f75
Update backend
perryzjc Apr 19, 2024
82f4c4c
Update frontend
perryzjc Apr 19, 2024
5cc4676
Add cucumber tests
perryzjc Apr 19, 2024
7f31e97
Fix rubocop
perryzjc Apr 19, 2024
9b318f9
Add rspec for email validation
perryzjc Apr 19, 2024
5e098f4
Merge branch 'main' into 187384622/new-email-model-pr4
perryzjc Apr 19, 2024
096f456
Merge pull request #54 from cs169/187384622/new-email-model-pr4
ArushC Apr 19, 2024
d6bb607
Merge branch '187384622/new-email-model' into pd-frontend+backend
perryzjc Apr 19, 2024
c909c95
Merge branch '187384622/new-email-model-pr2' into pd-frontend+backend
perryzjc Apr 19, 2024
45bc536
Merge branch '187384622/new-email-model-pr3' into pd-frontend+backend
perryzjc Apr 19, 2024
b0fa3d5
Fix cucumber tests to adapt new schema from new email address model
perryzjc Apr 19, 2024
436485f
Remove unused variable
perryzjc Apr 19, 2024
417adea
Add more rspec tests
perryzjc Apr 19, 2024
a1fda8e
Merge pull request #48 from cs169/pd-frontend+backend
perryzjc Apr 19, 2024
ed3d7d5
finish tooltip bug fix
realmichaeltao Apr 26, 2024
dbd7417
merge main
cycomachead May 10, 2024
9efdd79
Little cleanup CS169L work
cycomachead May 10, 2024
b77845a
Update db/seed_data.rb
cycomachead May 10, 2024
d1d0ed5
Update app/models/teacher.rb
cycomachead May 10, 2024
74c67d6
trying to fix datatables
cycomachead May 10, 2024
e18b91d
Merge branch '187460464/bugfix/tooltip' of github.com:cs169/BJC-Teach…
cycomachead May 10, 2024
710e6d6
fix typos/specs from code cleanup
cycomachead May 10, 2024
e7b5f07
Fix some datatables bugs, add school data cleanup script
cycomachead May 10, 2024
e977d68
Remove the education level from the teacher datatable
cycomachead May 10, 2024
34208a6
OK, I think the cucumber specs are good now...
cycomachead May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ group :test do
# Accessibility Testing
gem "axe-core-rspec"
gem "axe-core-cucumber"

# Test suite speedup
gem "rails-controller-testing"
end
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ GEM
bundler (>= 1.15.0)
railties (= 6.1.7.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand Down Expand Up @@ -595,6 +599,7 @@ DEPENDENCIES
puma (~> 5)
rack-mini-profiler (~> 2.0)
rails (= 6.1.7.7)
rails-controller-testing
rspec-rails
rubocop
rubocop-faker
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def check_teacher_admin
end

def set_sentry_user
Sentry.set_user(id: session[:user_id], email: current_user&.email)
Sentry.set_user(id: session[:user_id], email: current_user&.primary_email)
end
end
46 changes: 46 additions & 0 deletions app/controllers/email_addresses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

class EmailAddressesController < ApplicationController
before_action :require_login
before_action :require_admin
before_action :set_teacher

def edit
end

def update
if update_personal_emails
redirect_to teacher_path(@teacher), notice: "Personal email addresses updated successfully."
else
flash.now[:alert] = "An error occurred: " + (@error_messages || "Unknown error")
render :edit
end
end

private
def set_teacher
@teacher = Teacher.find(params[:teacher_id])
end

def update_personal_emails
EmailAddress.transaction do
params[:teacher][:email_addresses_attributes].each do |_, email_attr|
if email_attr[:id].present?
email = EmailAddress.find(email_attr[:id])
if email_attr[:_destroy] == "1"
email.destroy!
else
email.update!(email: email_attr[:email])
end
else
@teacher.email_addresses.create!(email: email_attr[:email]) unless email_attr[:email].blank?
end
end
end
true
rescue ActiveRecord::RecordInvalid => e
@error_messages = e.record&.errors&.full_messages&.join(", ")
@error_messages ||= "A validation error occurred, but no specific error details are available."
false
end
end
72 changes: 72 additions & 0 deletions app/controllers/pd_registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# frozen_string_literal: true

class PdRegistrationsController < ApplicationController
before_action :require_login
before_action :require_admin
before_action :set_pd_registration, only: [:show, :edit, :update, :destroy]
before_action :set_professional_development, only: [:new, :create, :edit, :update, :destroy]

def index
end

def show
end

def new
@pd_registration = PdRegistration.new
end

def edit
end

def create
@pd_registration = PdRegistration.new(pd_registration_params.merge(
professional_development_id: @professional_development.id))

if @pd_registration.save
redirect_to professional_development_path(@professional_development),
notice: "Registration for professional development was successfully created."
else
flash.now[:alert] = @pd_registration.errors.full_messages.to_sentence
render "professional_developments/show"
end
end

def update
if @pd_registration.update(pd_registration_params)
redirect_to professional_development_path(@professional_development),
notice: "Registration was successfully updated."
else
flash.now[:alert] = @pd_registration.errors.full_messages.to_sentence
render "professional_developments/show"
end
end

def destroy
if @pd_registration.destroy
redirect_to professional_development_path(@professional_development),
notice: "Registration was successfully cancelled."
else
flash.now[:alert] = @pd_registration.errors.full_messages.to_sentence
render "professional_developments/show"
end
end

private
def set_pd_registration
@pd_registration = PdRegistration.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to professional_development_path, alert: "Registration not found."
end

def set_professional_development
@professional_development = ProfessionalDevelopment.find_by(id: params[:professional_development_id])
unless @professional_development
redirect_to professional_developments_path, alert: "Professional Development not found."
end
end

def pd_registration_params
params.require(:pd_registration).permit(:teacher_id, :attended, :role, :professional_development_id)
end
end
61 changes: 61 additions & 0 deletions app/controllers/professional_developments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

class ProfessionalDevelopmentsController < ApplicationController
before_action :set_professional_development, only: [:show, :edit, :update, :destroy]
before_action :require_login
before_action :require_admin

def index
@professional_developments = ProfessionalDevelopment.all
end

def show
end

def new
@professional_development = ProfessionalDevelopment.new
end

def edit
end

def create
@professional_development = ProfessionalDevelopment.new(professional_development_params)

if @professional_development.save
redirect_to @professional_development, notice: "Professional development created successfully."
else
flash.now[:alert] = @professional_development.errors.full_messages.to_sentence
render :new
end
end

def update
if @professional_development.update(professional_development_params)
redirect_to @professional_development, notice: "Professional development updated successfully."
else
flash.now[:alert] = @professional_development.errors.full_messages.to_sentence
render :edit
end
end

def destroy
if @professional_development.destroy
redirect_to professional_developments_url, notice: "Professional development deleted successfully."
else
redirect_to professional_developments_url, alert: "Failed to delete professional development."
end
end

private
def set_professional_development
@professional_development = ProfessionalDevelopment.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to professional_developments_url, alert: "Professional development not found."
end

def professional_development_params
params.require(:professional_development).permit(:name, :city, :state, :country, :start_date, :end_date,
:grade_level)
end
end
Loading
Loading