mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-04 13:43:48 +00:00
Added my tournaments page
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
class StaticPagesController < ApplicationController
|
class StaticPagesController < ApplicationController
|
||||||
|
|
||||||
|
def my_tournaments
|
||||||
|
@tournaments = current_user.tournaments
|
||||||
|
end
|
||||||
|
|
||||||
def not_allowed
|
def not_allowed
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
<li><%= link_to "About", "/static_pages/about" %></li>
|
<li><%= link_to "About", "/static_pages/about" %></li>
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<li><%=link_to "Log out", destroy_user_session_url ,:method => 'delete' %></li>
|
<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 %>
|
<% else %>
|
||||||
<li><%= link_to "Log In" , new_user_session_path %></li>
|
<li><%= link_to "Log In" , new_user_session_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
38
app/views/static_pages/my_tournaments.html.erb
Normal file
38
app/views/static_pages/my_tournaments.html.erb
Normal 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>
|
||||||
|
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ Wrestling::Application.routes.draw do
|
|||||||
get 'static_pages/control_match'
|
get 'static_pages/control_match'
|
||||||
get 'static_pages/not_allowed'
|
get 'static_pages/not_allowed'
|
||||||
get 'static_pages/about'
|
get 'static_pages/about'
|
||||||
|
get 'static_pages/my_tournaments'
|
||||||
|
|
||||||
get 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
|
get 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
|
||||||
post 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
|
post 'tournaments/:id/weigh_in/:weight' => 'tournaments#weigh_in_weight'
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class StaticPagesControllerTest < ActionController::TestCase
|
|||||||
get :home
|
get :home
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
test "get my_tournaments" do
|
||||||
|
sign_in_owner
|
||||||
|
get :my_tournaments
|
||||||
|
success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user