Current User: <%= current_user.name %> (<%= current_user.role %>)
+
+
From 0ca7372c69f0b571582a1f506585e6fdf1368259 Mon Sep 17 00:00:00 2001
From: Anusha_Akkireddy
Date: Wed, 23 Oct 2024 17:43:37 -0400
Subject: [PATCH 28/44] Implemented CRUD operations and added notifications for
mentor meetings
---
app/controllers/mentor_meeting_controller.rb | 34 ++++++++++++++++----
app/models/mentor_meeting_notifications.rb | 11 +++++++
2 files changed, 39 insertions(+), 6 deletions(-)
create mode 100644 app/models/mentor_meeting_notifications.rb
diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb
index 330cf49a66c..101083d6f08 100644
--- a/app/controllers/mentor_meeting_controller.rb
+++ b/app/controllers/mentor_meeting_controller.rb
@@ -12,30 +12,52 @@ def add_date
team_id = params[:team_id]
meeting_date = params[:meeting_date]
@mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
- @mentor_meeting.save
- render :json => { :status => 'success', :message => "Ok"}
+
+ if @mentor_meeting.save
+ MentorMeetingNotifications.send_notification(team_id, meeting_date)
+ render json: { status: 'success', message: "Meeting date added" }
+ else
+ render json: { status: 'error', message: "Unable to add meeting date" }
+ end
end
+
+
def edit_date
team_id = params[:team_id]
old_meeting_date = params[:old_date]
new_meeting_date = params[:new_date]
-
+
@meeting = MentorMeeting.where(team_id: team_id.to_i, meeting_date: old_meeting_date).first
if @meeting
@meeting.meeting_date = new_meeting_date
if @meeting.save
- render :json => { :status => 'success', :message => "Ok"}
+ # Trigger notification after editing
+ ActiveSupport::Notifications.instrument('mentor_meeting.updated', team_id: team_id, old_meeting_date: old_meeting_date, new_meeting_date: new_meeting_date)
+ render json: { status: 'success', message: 'Meeting updated successfully' }
+ else
+ render json: { status: 'error', message: 'Failed to update meeting' }
end
+ else
+ render json: { status: 'error', message: 'Meeting not found' }
end
end
+
def delete_date
team_id = params[:team_id]
meeting_date = params[:meeting_date]
@meeting = MentorMeeting.where(team_id: team_id.to_i, meeting_date: meeting_date).first
- @meeting.destroy
- render :json => { :status => 'success', :message => "Ok"}
+
+ if @meeting
+ @meeting.destroy
+ # Trigger notification after deletion
+ ActiveSupport::Notifications.instrument('mentor_meeting.deleted', team_id: team_id, meeting_date: meeting_date)
+ render json: { status: 'success', message: 'Meeting deleted successfully' }
+ else
+ render json: { status: 'error', message: 'Meeting not found' }
+ end
end
+
end
diff --git a/app/models/mentor_meeting_notifications.rb b/app/models/mentor_meeting_notifications.rb
new file mode 100644
index 00000000000..afcebed2e01
--- /dev/null
+++ b/app/models/mentor_meeting_notifications.rb
@@ -0,0 +1,11 @@
+class MentorMeetingNotifications
+ def self.send_notification(team_id, meeting_date)
+ ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date)
+ end
+end
+
+# Subscribe to the notification and define what action to take
+ActiveSupport::Notifications.subscribe('mentor_meeting.created') do |name, start, finish, id, payload|
+ puts "New meeting created for team #{payload[:team_id]} on #{payload[:meeting_date]}"
+ # Here, you can replace the notification logic to send an email, SMS, etc.
+end
From c8f4bd4baae2b9e898aa6639e5e97616dbefd6c0 Mon Sep 17 00:00:00 2001
From: Anusha_Akkireddy
Date: Thu, 24 Oct 2024 17:36:55 -0400
Subject: [PATCH 29/44] Removed submodule, added CRUD operations for mentor
meetings
---
E2460-MentorMeetingManagement | 1 +
1 file changed, 1 insertion(+)
create mode 160000 E2460-MentorMeetingManagement
diff --git a/E2460-MentorMeetingManagement b/E2460-MentorMeetingManagement
new file mode 160000
index 00000000000..c1e6c750acc
--- /dev/null
+++ b/E2460-MentorMeetingManagement
@@ -0,0 +1 @@
+Subproject commit c1e6c750acc39255283558f7b97c869f644f09a3
From 7d188d33ba68246d0f7d81aeef68a9f62bc8f1c5 Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Thu, 24 Oct 2024 19:04:24 -0400
Subject: [PATCH 30/44] added parameter handling and meeting record info
---
app/controllers/mentor_meeting_controller.rb | 23 +++++++++++++++-----
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb
index 101083d6f08..77d29f99eea 100644
--- a/app/controllers/mentor_meeting_controller.rb
+++ b/app/controllers/mentor_meeting_controller.rb
@@ -1,16 +1,19 @@
class MentorMeetingController < ApplicationController
include MentorMeetingsHelper
+ before_action :set_team_and_meeting, only: [:edit_date, :delete_date]
+
# Method to get meeting dates for a particular assignment
def get_dates
@mentor_meetings = MentorMeeting.all
- render json: @mentor_meetings
+ render json: @mentor_meetings, status::ok
end
# Method to add meetings dates to the mentor_meetings table.
def add_date
- team_id = params[:team_id]
- meeting_date = params[:meeting_date]
+ meeting_dates_params.each do |team_id, dates|
+ dates.each do |date|
+ next if date.blank?
@mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
if @mentor_meeting.save
@@ -21,8 +24,6 @@ def add_date
end
end
-
-
def edit_date
team_id = params[:team_id]
old_meeting_date = params[:old_date]
@@ -58,6 +59,16 @@ def delete_date
render json: { status: 'error', message: 'Meeting not found' }
end
end
-
+ private
+
+ def meeting_dates_params #permitting parameters through the model
+ params.require(:meeting_dates).permit(:team_id, :date)
+ end
+
+ def set_team_and_meeting #means by which a specific team meeting can be found based on its parameters
+ @meeting = MentorMeeting.find_by(team_id: params[:team_id].to_i, meeting_date: params[:meeting_date])
+ render json: { status: 'error', message: 'Meeting not found' }, status: :not_found unless @meeting
+ end
end
+
From cae33ff59fdfd59d5162b04d05cf6443910bcb4d Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Mon, 28 Oct 2024 21:14:03 -0400
Subject: [PATCH 31/44] Update _team.html.erb
---
app/views/teams/_team.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb
index 123526fbdfe..e109e484d68 100644
--- a/app/views/teams/_team.html.erb
+++ b/app/views/teams/_team.html.erb
@@ -31,7 +31,7 @@
|<%= link_to 'Bequeath All Teams', :action=>'bequeath_all', :id => @root_node.node_object_id, :model => @model %>
-// additional functionality to include meeting dates and add the + button to add more meetings. LLM assisted in developing this coede.
+// additional functionality to include meeting dates and add the + button to add more meetings.
Mentor Meeting Dates
From ba3f4e899e9aba55e9cef0207300d18ae2a51846 Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Mon, 28 Oct 2024 22:48:07 -0400
Subject: [PATCH 32/44] added current team mentor functionality to allow them
to remove meetings for only the teams that they mentor.
---
app/views/teams/_team.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/teams/_team.html.erb b/app/views/teams/_team.html.erb
index e109e484d68..c2936e9ceb9 100644
--- a/app/views/teams/_team.html.erb
+++ b/app/views/teams/_team.html.erb
@@ -47,12 +47,12 @@
/>
- <% if current_user.instructor? %>
+ <% if current_user.instructor? || current_user == team.mentor %> //current team mentor and instructor can remove
<% end %>
<% end %>
-
+
<% end %>
From c3813e98ffabfc5b951aa64717bed7e46b2fc62f Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Mon, 28 Oct 2024 23:50:56 -0400
Subject: [PATCH 33/44] created meeting_date factory for testing
---
spec/factories/factories.rb | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb
index c359e784672..2765ebf380c 100644
--- a/spec/factories/factories.rb
+++ b/spec/factories/factories.rb
@@ -761,4 +761,10 @@
ta_id 1
course_id 1
end
+
+factory :meeting_date, class: MeetingDate do
+ date { Date.today } # Default to today's date
+ team # Assumes you have a team association set up
+ end
+
end
From 23c412f82edb9a94609d41127d5379ffa396fd81 Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Tue, 29 Oct 2024 00:07:45 -0400
Subject: [PATCH 34/44] Create mentor_meeting_management_spec.rb
---
spec/models/mentor_meeting_management_spec.rb | 83 +++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 spec/models/mentor_meeting_management_spec.rb
diff --git a/spec/models/mentor_meeting_management_spec.rb b/spec/models/mentor_meeting_management_spec.rb
new file mode 100644
index 00000000000..a7a45c186eb
--- /dev/null
+++ b/spec/models/mentor_meeting_management_spec.rb
@@ -0,0 +1,83 @@
+require 'rails_helper'
+
+#created with help from LLM
+
+RSpec.describe 'Mentor Meetings Management', type: :system do
+ before do
+ driven_by(:rack_test) # or :selenium_chrome if you're using a browser
+ @mentor = create(:mentor)
+ @instructor = create(:instructor)
+ @team = create(:team, capacity: 5) # example capacity
+ @under_capacity_team = create(:team, capacity: 2, members_count: 1)
+ @meeting_date = create(:meeting_date, team: @team)
+ end
+
+ context 'when viewing teams and mentors' do
+ it 'displays all teams, members, and mentors' do
+ visit teams_path
+ expect(page).to have_content(@team.name)
+ expect(page).to have_content(@mentor.name)
+ expect(page).to have_content(@instructor.name)
+ end
+ end
+
+ context 'when a mentor adds/edit meeting dates for their team' do
+ it 'allows mentors to add a meeting date' do
+ sign_in(@mentor) # Assuming you have a method for signing in
+ visit team_path(@team)
+ click_button 'Add Meeting Date'
+ fill_in 'Meeting Date', with: '2024-11-01'
+ click_button 'Save'
+
+ expect(page).to have_content('Meeting Date added successfully')
+ expect(page).to have_content('2024-11-01')
+ end
+
+ it 'allows mentors to edit a meeting date' do
+ sign_in(@mentor)
+ visit team_path(@team)
+ click_link 'Edit Meeting Date'
+ fill_in 'Meeting Date', with: '2024-11-15'
+ click_button 'Save'
+
+ expect(page).to have_content('Meeting Date updated successfully')
+ expect(page).to have_content('2024-11-15')
+ end
+ end
+
+ context 'when an instructor edits meeting dates for all teams' do
+ it 'allows instructors to edit meeting dates' do
+ sign_in(@instructor)
+ visit team_path(@team)
+ click_link 'Edit Meeting Date'
+ fill_in 'Meeting Date', with: '2024-11-20'
+ click_button 'Save'
+
+ expect(page).to have_content('Meeting Date updated successfully')
+ expect(page).to have_content('2024-11-20')
+ end
+ end
+
+ context 'when inputting multiple meeting dates' do
+ it 'allows input of multiple meeting dates' do
+ sign_in(@mentor)
+ visit team_path(@team)
+ click_button 'Add Multiple Meeting Dates'
+ fill_in 'Meeting Dates', with: '2024-11-01, 2024-11-08'
+ click_button 'Save'
+
+ expect(page).to have_content('Meeting Dates added successfully')
+ expect(page).to have_content('2024-11-01')
+ expect(page).to have_content('2024-11-08')
+ end
+ end
+
+ context 'when handling under-capacity teams' do
+ it 'disables date fields for under-capacity teams' do
+ sign_in(@mentor)
+ visit team_path(@under_capacity_team)
+
+ expect(page).to have_selector('input[disabled]', id: 'meeting_date')
+ end
+ end
+end
From 255080b05cf3584342351cc17afb0eb068d814af Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Tue, 29 Oct 2024 00:10:28 -0400
Subject: [PATCH 35/44] Delete spec/models/mentor_meeting_management_spec.rb -
did not need as there was an existing spec test to work off of
---
spec/models/mentor_meeting_management_spec.rb | 83 -------------------
1 file changed, 83 deletions(-)
delete mode 100644 spec/models/mentor_meeting_management_spec.rb
diff --git a/spec/models/mentor_meeting_management_spec.rb b/spec/models/mentor_meeting_management_spec.rb
deleted file mode 100644
index a7a45c186eb..00000000000
--- a/spec/models/mentor_meeting_management_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require 'rails_helper'
-
-#created with help from LLM
-
-RSpec.describe 'Mentor Meetings Management', type: :system do
- before do
- driven_by(:rack_test) # or :selenium_chrome if you're using a browser
- @mentor = create(:mentor)
- @instructor = create(:instructor)
- @team = create(:team, capacity: 5) # example capacity
- @under_capacity_team = create(:team, capacity: 2, members_count: 1)
- @meeting_date = create(:meeting_date, team: @team)
- end
-
- context 'when viewing teams and mentors' do
- it 'displays all teams, members, and mentors' do
- visit teams_path
- expect(page).to have_content(@team.name)
- expect(page).to have_content(@mentor.name)
- expect(page).to have_content(@instructor.name)
- end
- end
-
- context 'when a mentor adds/edit meeting dates for their team' do
- it 'allows mentors to add a meeting date' do
- sign_in(@mentor) # Assuming you have a method for signing in
- visit team_path(@team)
- click_button 'Add Meeting Date'
- fill_in 'Meeting Date', with: '2024-11-01'
- click_button 'Save'
-
- expect(page).to have_content('Meeting Date added successfully')
- expect(page).to have_content('2024-11-01')
- end
-
- it 'allows mentors to edit a meeting date' do
- sign_in(@mentor)
- visit team_path(@team)
- click_link 'Edit Meeting Date'
- fill_in 'Meeting Date', with: '2024-11-15'
- click_button 'Save'
-
- expect(page).to have_content('Meeting Date updated successfully')
- expect(page).to have_content('2024-11-15')
- end
- end
-
- context 'when an instructor edits meeting dates for all teams' do
- it 'allows instructors to edit meeting dates' do
- sign_in(@instructor)
- visit team_path(@team)
- click_link 'Edit Meeting Date'
- fill_in 'Meeting Date', with: '2024-11-20'
- click_button 'Save'
-
- expect(page).to have_content('Meeting Date updated successfully')
- expect(page).to have_content('2024-11-20')
- end
- end
-
- context 'when inputting multiple meeting dates' do
- it 'allows input of multiple meeting dates' do
- sign_in(@mentor)
- visit team_path(@team)
- click_button 'Add Multiple Meeting Dates'
- fill_in 'Meeting Dates', with: '2024-11-01, 2024-11-08'
- click_button 'Save'
-
- expect(page).to have_content('Meeting Dates added successfully')
- expect(page).to have_content('2024-11-01')
- expect(page).to have_content('2024-11-08')
- end
- end
-
- context 'when handling under-capacity teams' do
- it 'disables date fields for under-capacity teams' do
- sign_in(@mentor)
- visit team_path(@under_capacity_team)
-
- expect(page).to have_selector('input[disabled]', id: 'meeting_date')
- end
- end
-end
From 3fdc72cfd322008f75e5f77781f12ead79d0d6f6 Mon Sep 17 00:00:00 2001
From: gavint7 <33268509+gavint7@users.noreply.github.com>
Date: Tue, 29 Oct 2024 00:42:26 -0400
Subject: [PATCH 36/44] add test for auto assign mentor false
---
spec/models/mentor_management_spec.rb | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/spec/models/mentor_management_spec.rb b/spec/models/mentor_management_spec.rb
index 1a818eafdb4..2df9240b480 100644
--- a/spec/models/mentor_management_spec.rb
+++ b/spec/models/mentor_management_spec.rb
@@ -1,3 +1,5 @@
+#require 'rails_helper'
+
describe MentorManagement do
# using let! so that state is automatically set up before each example group
# this could also be accomplished with before(:each) and instance methods
@@ -165,6 +167,14 @@
# There should be no assigning of mentors
expect(Team).to receive(:add_member).exactly(0).times
end
+
+ describe '#update_mentor_state' do
+ it 'does not assign if `auto_assign_mentor` is false' do
+ no_mentor_assignment = create(:assignment, auto_assign_mentor: false)
+
+ expect(Team).not_to receive(:add_member)
+ MentorManagement.assign_mentor(no_mentor_assignment.id, team.id)
+ end
end
context 'when the assignment or team already have a topic' do
From cdc54af866e351f07d514b407e72dcaaf63e0cc0 Mon Sep 17 00:00:00 2001
From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:30:43 -0400
Subject: [PATCH 37/44] Update mentor_meeting_controller.rb
---
app/controllers/mentor_meeting_controller.rb | 25 ++++++++++----------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb
index 77d29f99eea..845184a6eec 100644
--- a/app/controllers/mentor_meeting_controller.rb
+++ b/app/controllers/mentor_meeting_controller.rb
@@ -10,19 +10,20 @@ def get_dates
end
# Method to add meetings dates to the mentor_meetings table.
- def add_date
- meeting_dates_params.each do |team_id, dates|
- dates.each do |date|
- next if date.blank?
- @mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
-
- if @mentor_meeting.save
- MentorMeetingNotifications.send_notification(team_id, meeting_date)
- render json: { status: 'success', message: "Meeting date added" }
- else
- render json: { status: 'error', message: "Unable to add meeting date" }
- end
+def add_date
+ team_id = params[:team_id]
+ meeting_date = params[:meeting_date]
+ @mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
+
+ if @mentor_meeting.save
+ # Trigger notification after saving
+ ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date)
+ render json: { status: 'success', message: 'Meeting created successfully' }
+ else
+ render json: { status: 'error', message: 'Failed to create meeting' }
end
+end
+
def edit_date
team_id = params[:team_id]
From 6cdab8daa248e65da925df90af6e93e9e7a1ae1b Mon Sep 17 00:00:00 2001
From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:48:59 -0400
Subject: [PATCH 38/44] Update mentor_meeting_notifications.rb
---
app/models/mentor_meeting_notifications.rb | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/models/mentor_meeting_notifications.rb b/app/models/mentor_meeting_notifications.rb
index afcebed2e01..4ee02f08588 100644
--- a/app/models/mentor_meeting_notifications.rb
+++ b/app/models/mentor_meeting_notifications.rb
@@ -4,8 +4,6 @@ def self.send_notification(team_id, meeting_date)
end
end
-# Subscribe to the notification and define what action to take
ActiveSupport::Notifications.subscribe('mentor_meeting.created') do |name, start, finish, id, payload|
puts "New meeting created for team #{payload[:team_id]} on #{payload[:meeting_date]}"
- # Here, you can replace the notification logic to send an email, SMS, etc.
end
From eb9b75baaaaa94d4c203a5ccfc751f30d61c10a8 Mon Sep 17 00:00:00 2001
From: Anusha Akkireddy <41582420+akkireddyanusha@users.noreply.github.com>
Date: Tue, 29 Oct 2024 17:51:11 -0400
Subject: [PATCH 39/44] Update mentor_meeting_controller.rb
---
app/controllers/mentor_meeting_controller.rb | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/controllers/mentor_meeting_controller.rb b/app/controllers/mentor_meeting_controller.rb
index 845184a6eec..c4ec017870f 100644
--- a/app/controllers/mentor_meeting_controller.rb
+++ b/app/controllers/mentor_meeting_controller.rb
@@ -16,11 +16,10 @@ def add_date
@mentor_meeting = MentorMeeting.create(team_id: team_id, meeting_date: meeting_date)
if @mentor_meeting.save
- # Trigger notification after saving
- ActiveSupport::Notifications.instrument('mentor_meeting.created', team_id: team_id, meeting_date: meeting_date)
- render json: { status: 'success', message: 'Meeting created successfully' }
+ MentorMeetingNotifications.send_notification(team_id, meeting_date)
+ render json: { status: 'success', message: "Meeting date added" }
else
- render json: { status: 'error', message: 'Failed to create meeting' }
+ render json: { status: 'error', message: "Unable to add meeting date" }
end
end
From 25fc960c93ae074ea68d1fb60379fabe28792cfe Mon Sep 17 00:00:00 2001
From: Anusha_Akkireddy
Date: Tue, 29 Oct 2024 18:22:10 -0400
Subject: [PATCH 40/44] Implement mentor meeting controller with CRUD and
notification features
---
.../mentor_meeting_controller_spec.rb | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 spec/controllers/mentor_meeting_controller_spec.rb
diff --git a/spec/controllers/mentor_meeting_controller_spec.rb b/spec/controllers/mentor_meeting_controller_spec.rb
new file mode 100644
index 00000000000..ce346c536e9
--- /dev/null
+++ b/spec/controllers/mentor_meeting_controller_spec.rb
@@ -0,0 +1,37 @@
+require 'rails_helper'
+
+RSpec.describe MentorMeetingController, type: :controller do
+ describe 'POST #add_date' do
+ it 'creates a new meeting date and triggers a notification' do
+ expect {
+ post :add_date, params: { team_id: 1, meeting_date: '2024-11-01' }
+ }.to change(MentorMeeting, :count).by(1)
+
+ expect(response.status).to eq(200)
+ expect(JSON.parse(response.body)['status']).to eq('success')
+ end
+ end
+
+ describe 'PATCH #edit_date' do
+ it 'updates the meeting date' do
+ mentor_meeting = MentorMeeting.create!(team_id: 1, meeting_date: '2024-11-01')
+ patch :edit_date, params: { team_id: 1, old_date: '2024-11-01', new_date: '2024-11-02' }
+
+ expect(response.status).to eq(200)
+ expect(JSON.parse(response.body)['status']).to eq('success')
+ expect(mentor_meeting.reload.meeting_date).to eq('2024-11-02')
+ end
+ end
+
+ describe 'DELETE #delete_date' do
+ it 'deletes the meeting date' do
+ mentor_meeting = MentorMeeting.create!(team_id: 1, meeting_date: '2024-11-01')
+ expect {
+ delete :delete_date, params: { team_id: 1, meeting_date: '2024-11-01' }
+ }.to change(MentorMeeting, :count).by(-1)
+
+ expect(response.status).to eq(200)
+ expect(JSON.parse(response.body)['status']).to eq('success')
+ end
+ end
+end
From 34042b8a7c33f9e24a4fd17a70511507ab52a5ab Mon Sep 17 00:00:00 2001
From: Anusha_Akkireddy
Date: Tue, 29 Oct 2024 19:18:07 -0400
Subject: [PATCH 41/44] Add Dockerfile for Docker setup
---
Dockerfile | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 Dockerfile
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000000..2f1d69f05e1
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,27 @@
+# Use an official Ruby runtime as a parent image
+FROM ruby:2.7
+
+# Install dependencies
+RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
+
+# Set up the working directory
+WORKDIR /app
+
+# Copy the Gemfile and Gemfile.lock into the container
+COPY Gemfile /app/Gemfile
+COPY Gemfile.lock /app/Gemfile.lock
+
+# Install gems
+RUN bundle install
+
+# Copy the rest of the application files into the container
+COPY . /app
+
+# Precompile assets (if your app has assets)
+RUN bundle exec rake assets:precompile || true
+
+# Expose the port that the app runs on
+EXPOSE 3000
+
+# Start the server by default
+CMD ["rails", "server", "-b", "0.0.0.0"]
From 7d890ee39b85b15641cf38e7a45f047c178f0148 Mon Sep 17 00:00:00 2001
From: Simon Getahun
Date: Tue, 29 Oct 2024 21:35:16 -0400
Subject: [PATCH 42/44] modification to email
---
app/models/team.rb | 19 +++++++++++++------
.../_dual_role_added_to_team_html.html.erb | 11 +++++++++++
2 files changed, 24 insertions(+), 6 deletions(-)
create mode 100644 app/views/mailer/partials/_dual_role_added_to_team_html.html.erb
diff --git a/app/models/team.rb b/app/models/team.rb
index 9298e1b32d7..f2d4a06e210 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -91,14 +91,21 @@ def add_member(user, _assignment_id = nil)
# if assignment_id is nil, then don't send an assignment name
assignment_name = _assignment_id ? Assignment.find(_assignment_id).name.to_s : ""
- # Now that a new team member has been added to a team, send an email to them letting them know
- if MentorManagement.user_a_mentor?(user)
+
+ # addressing efg's comment in previous PR
+ # if just mentor
+ if MentorManagement.user_a_mentor?(user) && !user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver
- elsif !user.is_a?(Participant)
- # If the user is a participant, then we don't went to send them emails since that class is something
- # completely out of the scope of this project
+
+ # only a participant
+ elsif !MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver
- end
+
+ # both mentor and participant
+ elsif MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
+ MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{name}", assignment_name).deliver
+
+ end
end
can_add_member
diff --git a/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb b/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb
new file mode 100644
index 00000000000..e28a835e1c1
--- /dev/null
+++ b/app/views/mailer/partials/_dual_role_added_to_team_html.html.erb
@@ -0,0 +1,11 @@
+Hi <%= @first_name %>,
+
+
+ You have been added to Team '<%= @team %>' for the Assignment '<%= @assignment %>' on Expertiza.
+
+
+ Please note that you are assigned both as a mentor and a participant for this team.
+
+
+ Expertiza Team
+
From 2db26cf638a8b5b4403490bb2313de34780f6074 Mon Sep 17 00:00:00 2001
From: Simon Getahun
Date: Tue, 29 Oct 2024 21:43:50 -0400
Subject: [PATCH 43/44] added test for new feature
---
spec/models/team_spec.rb | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
index 51d5af72776..c7adab57cc6 100644
--- a/spec/models/team_spec.rb
+++ b/spec/models/team_spec.rb
@@ -115,7 +115,7 @@
expect(team.add_member(user)).to be true
end
- it 'sends mail to user if user is a user' do
+ it 'sends mail to user if the user is a participant only' do
allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(false)
allow(Assignment).to receive(:find).with(1).and_return(assignment)
allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true))
@@ -124,6 +124,18 @@
expect(team.add_member(user)).to be true
end
+
+ it 'sends dual-role mail if the user is both a mentor and a participant' do
+ allow(MentorManagement).to receive(:user_a_mentor?).with(user).and_return(true)
+ allow(user).to receive(:is_a?).with(Participant).and_return(true)
+ allow(Assignment).to receive(:find).with(1).and_return(assignment)
+ allow(MailerHelper).to receive(:send_team_confirmation_mail_to_user).and_return(double('Mail', deliver: true))
+
+ expect(MailerHelper).to receive(:send_team_confirmation_mail_to_user).with(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{team.name}", "").and_return(double('Mail', deliver: true))
+
+ expect(team.add_member(user)).to be true
+ end
+
end
end
end
From a93285cbd5426c49b00e7b0167505f8eab24476f Mon Sep 17 00:00:00 2001
From: Simon Getahun
Date: Tue, 29 Oct 2024 21:57:56 -0400
Subject: [PATCH 44/44] changed model to handle dual case
---
app/models/mentored_team.rb | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/app/models/mentored_team.rb b/app/models/mentored_team.rb
index e009d8948e2..a43feca21e7 100644
--- a/app/models/mentored_team.rb
+++ b/app/models/mentored_team.rb
@@ -14,12 +14,18 @@ def add_member(user, _assignment_id = nil)
ExpertizaLogger.info LoggerMessage.new('Model:Team', user.name, "Added member to the team #{id}")
assignment_name = _assignment_id ? Assignment.find(_assignment_id).name.to_s : ""
- if MentorManagement.user_a_mentor?(user)
- MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver
- elsif !user.is_a?(Participant)
- MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver
- end
+ # mentor only
+ if MentorManagement.user_a_mentor?(user) && !user.is_a?(Participant)
+ MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "mentor_added_to_team", "#{name}", assignment_name).deliver
+ # participant only
+ elsif !MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
+ MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "user_added_to_team", "#{name}", assignment_name).deliver
+ # dual case
+ elsif MentorManagement.user_a_mentor?(user) && user.is_a?(Participant)
+ MailerHelper.send_team_confirmation_mail_to_user(user, "[Expertiza] Added to a Team", "dual_role_added_to_team", "#{name}", assignment_name).deliver
+ end
end
+
if can_add_member
MentorManagement.assign_mentor(_assignment_id, id)
end