add endpoint destroy votes for room
This commit is contained in:
parent
e1537e996a
commit
217c76d0e4
|
@ -2,7 +2,8 @@ class VotesController < ApplicationController
|
|||
http_basic_authenticate_with name: Rails.application.config.admin_name,
|
||||
password: Rails.application.config.admin_password
|
||||
|
||||
before_action :set_room, only: [:bulk]
|
||||
before_action :set_room, only: [:bulk, :destroy_for_room]
|
||||
before_action :set_votes, only: [:bulk, :destroy_for_room]
|
||||
|
||||
# GET /rooms/:room_id/votes/bulk
|
||||
def bulk
|
||||
|
@ -37,6 +38,19 @@ class VotesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# DELETE /rooms/:room_id/votes
|
||||
# DELETE /rooms/:room_id/votes.json
|
||||
def destroy_for_room
|
||||
@votes.each do |vote|
|
||||
vote.destroy
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to room_users_url(@room.id), notice: 'Votes were successfully destroyed.' }
|
||||
format.json { render :show, status: :created, location: @room }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
||||
|
@ -44,5 +58,8 @@ class VotesController < ApplicationController
|
|||
@room = Room.find(params[:room_id])
|
||||
end
|
||||
|
||||
def set_votes
|
||||
@votes = Vote.where(room_id: @room.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -51,4 +51,5 @@
|
|||
<%= link_to 'Absent Users', room_present_users_path(id: params[:room_id], v: 0) %> |
|
||||
<%= link_to 'Destroy all', destroy_room_users_path(params[:room_id]), method: :delete %> |
|
||||
<%= link_to 'Import Votes', bulk_new_room_votes_path(params[:room_id]), method: :get %> |
|
||||
<%= link_to 'Destroy Votes', room_votes_path(params[:room_id]), method: :delete %> |
|
||||
<%= link_to 'Back', room_path(params[:room_id]) %>
|
||||
|
|
|
@ -9,6 +9,7 @@ Rails.application.routes.draw do
|
|||
post 'rooms/:room_id/users/:id/test_invite', to: 'users#test_invite', as: 'test_invite_user'
|
||||
post 'rooms/:room_id/users/invite', to: 'users#invite', as: 'invite_room_users'
|
||||
delete 'rooms/:room_id/users', to: 'users#destroy_all', as: 'destroy_room_users'
|
||||
delete 'rooms/:room_id/votes', to: 'votes#destroy_for_room', as: 'room_votes'
|
||||
delete 'rooms/:room_id/users/invite', to: 'users#uninvite', as: 'uninvite_room_users'
|
||||
post 'rooms/:room_id/users/mark_invited', to: 'users#mark_invited', as: 'mark_invited_room_users'
|
||||
post 'rooms/:room_id/users/mark_presence', to: 'users#mark_presence', as: 'mark_presence_room_users'
|
||||
|
|
Loading…
Reference in New Issue