Skip to content

Commit

Permalink
Revert "Remove add_signup_topics_staggered()"
Browse files Browse the repository at this point in the history
This reverts commit 14059f8.
  • Loading branch information
Wei-Chi Chen committed Dec 1, 2022
1 parent 6853860 commit 6dd51b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
13 changes: 10 additions & 3 deletions app/controllers/signup_sheet_controller.rb
Expand Up @@ -139,6 +139,10 @@ def add_signup_topics
SignUpSheet.add_signup_topic(params[:id])
end

def add_signup_topics_staggered
add_signup_topics
end

# Separated from setup_new_topic
# Only used to setup the parameters of new topic
def set_values_for_new_topic
Expand All @@ -151,12 +155,15 @@ def set_values_for_new_topic
@assignment = Assignment.find(params[:id])
end

# simple function that redirects ti the /add_signup_topics page
# simple function that redirects ti the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type
# staggered means that different topics can have different deadlines.
def redirect_to_sign_up(assignment_id)
redirect_to action: 'add_signup_topics', id: assignment_id
assignment = Assignment.find(assignment_id)
assignment.staggered_deadline == true ? (redirect_to action: 'add_signup_topics_staggered', id: assignment_id) : (redirect_to action: 'add_signup_topics', id: assignment_id)
end

# simple function that redirects to assignment->edit->topic panel to display /add_signup_topics page
# simple function that redirects to assignment->edit->topic panel to display /add_signup_topics or the /add_signup_topics_staggered page
# staggered means that different topics can have different deadlines.
def redirect_to_assignment_edit(assignment_id)
redirect_to controller: 'assignments', action: 'edit', id: assignment_id
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/assignments/edit/_topics.html.erb
Expand Up @@ -44,7 +44,7 @@

<br><br>
<% if @assignment_form.assignment.staggered_deadline == true %>
<%= render partial: '/signup_sheet/add_signup_topics', locals: {review_rounds: @review_rounds, assignment_submission_due_dates: @assignment_submission_due_dates, assignment_review_due_dates: @assignment_review_due_dates} %>
<%= render partial: '/signup_sheet/add_signup_topics_staggered', locals: {review_rounds: @review_rounds, assignment_submission_due_dates: @assignment_submission_due_dates, assignment_review_due_dates: @assignment_review_due_dates} %>
<% else %>
<%= render '/signup_sheet/add_signup_topics' %>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -402,6 +402,7 @@
get :signup
get :delete_signup
get :add_signup_topics
get :add_signup_topics_staggered
get :delete_signup
get :list
get :signup_topics
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/signup_sheet_controller_spec.rb
Expand Up @@ -93,7 +93,7 @@

context 'when topic can be found' do
context 'when assignment.staggered_deadline is True' do
it 'updates the existing topic and redirects to signup_sheet#add_signup_topics page' do
it 'updates the existing topic and redirects to signup_sheet#add_signup_topics_staggered page' do
allow(SignedUpTeam).to receive(:find_by).with(topic_id: 1).and_return(signed_up_team)
allow(SignedUpTeam).to receive(:where).with(topic_id: 1, is_waitlisted: true).and_return([signed_up_team2])
allow(Team).to receive(:find).with(2).and_return(team)
Expand All @@ -110,7 +110,7 @@
}
post :create, params: request_params
expect(SignedUpTeam.first.is_waitlisted).to be false
expect(response).to redirect_to('/signup_sheet/add_signup_topics?id=1')
expect(response).to redirect_to('/signup_sheet/add_signup_topics_staggered?id=1')
end
end

Expand Down

0 comments on commit 6dd51b6

Please sign in to comment.