Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Dante83/49d94fda6658944ecc1a to your computer and use it in GitHub Desktop.
Save Dante83/49d94fda6658944ecc1a to your computer and use it in GitHub Desktop.
def reject
kanban_card = KanbanCard.find(params[:id])
unless kanban_card.worker_id.nil?
worker = Worker.find(kanban_card.worker_id)
end
if kanban_card.worker_id.nil?
flash[:message] = 'No one likes this card already. What type of jerk rejects an already rejected card?'
redirect_to do_work_on_kanban_board_path(KanbanBoardColumn.find(kanban_card.kanban_board_column_id).kanban_board_id) and return
elsif Worker.find_by_user_id(current_user.id).id == worker.id
#Yay! We've verified that this is actually the person trying to reject this card
if kanban_card.update({:worker_id => nil})
kanban_card = KanbanCard.find(params[:id])
flash[:message] = "#{worker.first_name} #{worker.last_name}, has unassigned themselves from the kanban card #{kanban_card.name}."
redirect_to do_work_on_kanban_board_path(KanbanBoardColumn.find(kanban_card.kanban_board_column_id).kanban_board_id) and return
else
flash[:message] = 'This card rejected your rejection. Imagine that. Maybe we should reject it\'s rejection of our rejection and see how it likes it.'
redirect_to do_work_on_kanban_board_path(KanbanBoardColumn.find(kanban_card.kanban_board_column_id).kanban_board_id) and return
end
else
flash[:message] = 'Who are you and what are you doing here? You can\'t reject someone else\'s card for them.'
redirect_to do_work_on_kanban_board_path(KanbanBoardColumn.find(kanban_card.kanban_board_column_id).kanban_board_id) and return
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment