started to shape out the controllers

This commit is contained in:
Absurdon 2017-05-05 17:17:00 +02:00
parent 160fccd118
commit 0f05829bcc
4 changed files with 32 additions and 3 deletions

View file

@ -1,6 +1,6 @@
class MatchProposalsController < ApplicationController
def index
@match = Match.find(params[:match_id])
end
def new

View file

@ -42,6 +42,7 @@ class Match < ActiveRecord::Base
has_many :users, through: :matchers
has_many :predictions, dependent: :destroy
has_many :comments, as: :commentable, order: "created_at", dependent: :destroy
has_many :match_proposals, inverse_of: :match, dependent: :destroy
belongs_to :challenge
belongs_to :contest
belongs_to :contester1, class_name: "Contester", include: "team"

View file

@ -1,2 +1,24 @@
<h1>MatchProposals#show</h1>
<p>Find me in app/views/match_proposals/show.html.erb</p>
<h1>Proposals</h1>
<%= link_to 'Back', match_path(@match), class: 'button' %>
<% if @match.match_proposals.empty? %>
<h4>There are no proposals yet</h4>
<% else %>
<table id="proposals" class="striped">
<tr>
<th>Team</th>
<th>Time</th>
<th>Status</th>
<th>Actions</th>
</tr>
<% @match.match_proposals.each do |proposal| %>
<tr class="<%=cycle('even', 'odd') %>">
<td><%= proposal.team.name %></td>
<td><%= longtime proposal.proposed_time %> </td>
<td><%= proposal.status %></td>
<td>test</td>
</tr>
<% end %>
</table>
<% end %>
<%= link_to 'Back', match_path(@match), class: 'button' %><%= link_to 'Propose match time', new_match_proposal_path(@match), class: 'button' %>

View file

@ -116,6 +116,11 @@
<p><%= @match.report.html_safe %></p>
</div>
<% end %>
<% if cuser and (cuser.admin? or @match.of_user cuser) %>
<div class="referee">
<%= link_to 'Proposals', match_proposals_path(@match), class: 'button' %>
</div>
<% end %>
<% if cuser and @match.can_update? cuser, [:report] %>
<div class="referee">
@ -130,6 +135,7 @@
<% end %>
</div>
<% end %>
</div>
<%= add_comments @match %>