invitation requests: allow moderators to delete confirmed requests

This commit is contained in:
joshua stein 2014-02-19 13:13:10 -06:00
parent 78d9734c26
commit c90486b813
3 changed files with 31 additions and 8 deletions

View file

@ -81,9 +81,20 @@ class InvitationsController < ApplicationController
return redirect_to "/invitations"
end
def delete_request
if !@user.is_moderator?
return redirect_to "/invitations"
else
render :action => :build
end
if !(ir = InvitationRequest.where(:code => params[:code].to_s).first)
flash[:error] = "Invalid or expired invitation request"
return redirect_to "/invitations"
end
ir.destroy!
flash[:success] = "Successfully deleted invitation request from " <<
ir.name.to_s << "."
return redirect_to "/invitations"
end
end

View file

@ -13,8 +13,11 @@
<tr>
<th width="15%">Date/Time</th>
<th width="20%">Name</th>
<th width="50%">Memo</th>
<th width="40%">Memo</th>
<th width="15%"></th>
<% if @user.is_moderator? %>
<th></th>
<% end %>
</tr>
<% bit = 0 %>
<% @invitation_requests.each do |ir| %>
@ -22,18 +25,25 @@
<td><%= ir.created_at.strftime("%Y-%m-%d %H:%M:%S") %></td>
<td><%= ir.name %></td>
<td><%= raw ir.markeddown_memo %></td>
<td><%= form_tag send_invitation_for_request_url, :confirm => "Are " <<
"you sure you want to invite this person and remove this request?" do %>
<td><%= form_tag send_invitation_for_request_url do %>
<%= hidden_field_tag "code", ir.code %>
<%= submit_tag "Send Invitiation" %>
<%= submit_tag "Send Invitiation", :data => { :confirm => "Are " <<
"you sure you want to invite this person and remove this request?" } %>
<% end %></td>
<% if @user.is_moderator? %>
<td><%= form_tag delete_invitation_request_url do %>
<%= hidden_field_tag "code", ir.code %>
<%= submit_tag "Delete", :data => { :confirm => "Are you sure " <<
"you want to delete this request?" } %>
<% end %></td>
<% end %>
</tr>
<% bit = (bit == 1 ? 0 : 1) %>
<% end %>
<% if @invitation_requests.count == 0 %>
<tr>
<td colspan=4 align="center"><span class="na">No invitation
requests</span></td>
<td colspan=<%= @user.is_moderator?? 5 : 4 %> align="center"><span
class="na">No invitation requests</span></td>
</tr>
<% end %>
</table>

View file

@ -88,6 +88,8 @@ Lobsters::Application.routes.draw do
post "/invitations/send_for_request" => "invitations#send_for_request",
:as => "send_invitation_for_request"
get "/invitations/:invitation_code" => "signup#invited"
post "/invitations/delete_request" => "invitations#delete_request",
:as => "delete_invitation_request"
get "/moderations" => "moderations#index"
get "/moderations/page/:page" => "moderations#index"