diff --git a/app/controllers/match_proposals_controller.rb b/app/controllers/match_proposals_controller.rb index 6e8f9cf..bcce797 100644 --- a/app/controllers/match_proposals_controller.rb +++ b/app/controllers/match_proposals_controller.rb @@ -5,10 +5,13 @@ class MatchProposalsController < ApplicationController end def new - mp = MatchProposal.confirmed_for_match(@match).first - if mp - flash[:danger] = 'Cannot create a new proposal aslong as there already is a confirmed one' - redirect_to(match_proposals_path(@match)) && return + # Don't allow creation of new proposals if there is a confirmed one already + if MatchProposal.exists?( + match_id: @match.id, + status: MatchProposal::STATUS_CONFIRMED + ) + flash[:error] = 'Cannot create a new proposal if there is already a confirmed one' + redirect_to(match_proposals_path(@match)) && return end @proposal = MatchProposal.new @proposal.match = @match diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb index 106bd3b..77c432d 100644 --- a/app/views/contests/show.html.erb +++ b/app/views/contests/show.html.erb @@ -20,6 +20,8 @@
Sunday: <%= Time.use_zone(timezone_offset) { @contest.default_time.strftime("%H:%M %Z") } %>
+ <%= link_to 'Scheduled Matches', confirmed_matches_path(@contest), class: 'button' %> + <% if cuser and cuser.admin? %> <%= link_to 'Edit Contest', edit_contest_path(@contest), class: 'button' %> <% end %> diff --git a/app/views/match_proposals/index.html.erb b/app/views/match_proposals/index.html.erb index 6adadad..adf2829 100644 --- a/app/views/match_proposals/index.html.erb +++ b/app/views/match_proposals/index.html.erb @@ -23,9 +23,15 @@ <% unless proposal.state_immutable? %> <%= form_for proposal, url: match_proposal_path(@match, proposal) do |f| %> <%= f.hidden_field :status, value: 0 %> - <%= link_to_function icon('check'), "proposalStateSubmit(#{MatchProposal::STATUS_CONFIRMED},#{proposal.id})", title: 'Confirm' %> - <%= link_to_function icon('times'), "proposalStateSubmit(#{MatchProposal::STATUS_REJECTED},#{proposal.id})", title: 'Reject' %> - <%= link_to_function icon('undo'), "proposalStateSubmit(#{MatchProposal::STATUS_REVOKED},#{proposal.id})", title: 'Revoke' %> + <% if proposal.status_change_allowed?(cuser, MatchProposal::STATUS_CONFIRMED) %> + <%= link_to_function icon('check'), "proposalStateSubmit(#{MatchProposal::STATUS_CONFIRMED},#{proposal.id})", title: 'Confirm' %> + <% end %> + <% if proposal.status_change_allowed?(cuser, MatchProposal::STATUS_REJECTED) %> + <%= link_to_function icon('times'), "proposalStateSubmit(#{MatchProposal::STATUS_REJECTED},#{proposal.id})", title: 'Reject' %> + <% end %> + <% if proposal.status_change_allowed?(cuser, MatchProposal::STATUS_REVOKED) %> + <%= link_to_function icon('undo'), "proposalStateSubmit(#{MatchProposal::STATUS_REVOKED},#{proposal.id})", title: 'Revoke' %> + <% end %> <% if proposal.status_change_allowed?(cuser, MatchProposal::STATUS_DELAYED) %> <%= link_to_function icon('hourglass'), "proposalStateSubmit(#{MatchProposal::STATUS_DELAYED},#{proposal.id})", title: 'Delay' %> <% end %>