1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added my tournaments page

This commit is contained in:
2015-12-15 15:24:13 -05:00
parent ec1c7c7fd4
commit 41ca12c5d1
5 changed files with 49 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
class StaticPagesController < ApplicationController
def my_tournaments
@tournaments = current_user.tournaments
end
def not_allowed
end

View File

@@ -8,7 +8,8 @@
<li><%= link_to "About", "/static_pages/about" %></li>
<% if user_signed_in? %>
<li><%=link_to "Log out", destroy_user_session_url ,:method => 'delete' %></li>
<li><%=link_to "Edit user", edit_user_registration_path %></li>
<li><%=link_to "Edit user", edit_user_registration_path %></li>
<li><%=link_to "My tournaments","/static_pages/my_tournaments" %></li>
<% else %>
<li><%= link_to "Log In" , new_user_session_path %></li>
<% end %>

View File

@@ -0,0 +1,38 @@
<h1>My Tournaments</h1>
<script>
$(document).ready(function() {
$('#tournamentList').dataTable();
pagingType: "bootstrap";
} );
</script>
<% if user_signed_in? %>
<%= link_to 'New Tournament', new_tournament_path, :class=>"btn btn-success" %>
<% end %>
</br>
</br>
<table class="display compact cell-border" id="tournamentList">
<thead>
<tr>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<% @tournaments.each do |tournament| %>
<tr>
<td><%= tournament.name %></td>
<td><%= link_to 'Show', tournament, :class=>"btn btn-default" %>
<% if tournament_permissions(tournament) %>
<%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn btn-primary" %>
<%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br>

View File

@@ -26,6 +26,7 @@ Wrestling::Application.routes.draw do
get 'static_pages/control_match'
get 'static_pages/not_allowed'
get 'static_pages/about'
get 'static_pages/my_tournaments'
get 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
post 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'

View File

@@ -29,6 +29,10 @@ class StaticPagesControllerTest < ActionController::TestCase
get :home
success
end
test "get my_tournaments" do
sign_in_owner
get :my_tournaments
success
end
end