mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Fixed Syntax Error and error in Access Control
This commit is contained in:
parent
04f2fd77ff
commit
ca9cdeb200
5 changed files with 20 additions and 15 deletions
|
@ -1,26 +1,24 @@
|
|||
class MatchProposalsController < ApplicationController
|
||||
|
||||
before_filter :get_match
|
||||
def index
|
||||
@match = Match.find(params[:match_id])
|
||||
end
|
||||
|
||||
def new
|
||||
match = Match.find(params[:match_id])
|
||||
@proposal = MatchProposal.new(match: match)
|
||||
@proposal = MatchProposal.new
|
||||
@proposal.match = @match
|
||||
raise AccessError unless @proposal.can_create? cuser
|
||||
end
|
||||
|
||||
def create
|
||||
match = Match.find(params[:match_id])
|
||||
@proposal = MatchProposal.new(match: match)
|
||||
raise AccessError unless @ban.can_create? cuser
|
||||
@proposal = MatchProposal.new(params[:match_proposal])
|
||||
@proposal.match = @match
|
||||
raise AccessError unless @proposal.can_create? cuser
|
||||
@proposal.team = cuser.team
|
||||
@proposal.status = MatchProposal::STATUS_PENDING
|
||||
@proposal.proposed_time = params[:match_proposal][:proposed_time]
|
||||
|
||||
if @proposal.save
|
||||
if @proposal.save!
|
||||
flash[:notice] = 'Created new proposal'
|
||||
redirect_to(match)
|
||||
redirect_to(@match)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
@ -29,4 +27,8 @@ class MatchProposalsController < ApplicationController
|
|||
def update
|
||||
end
|
||||
|
||||
private
|
||||
def get_match
|
||||
@match = Match.find params[:match_id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -358,4 +358,8 @@ class Match < ActiveRecord::Base
|
|||
def can_destroy?(cuser)
|
||||
cuser && cuser.admin?
|
||||
end
|
||||
|
||||
def can_make_proposal?(cuser)
|
||||
cuser && (contester1.team.is_leader?(cuser) || contester2.team.is_leader?(cuser))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,11 +19,11 @@ class MatchProposal < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def can_create? cuser
|
||||
cuser && cuser.team.is_leader?(cuser) && match.of_team(cuser.team)
|
||||
cuser && match && match.can_make_proposal?(cuser)
|
||||
end
|
||||
|
||||
def can_update? cuser
|
||||
cuser && cuser.team.is_leader?(cuser) && match.of_team (cuser.team)
|
||||
cuser && match && match.can_make_proposal?(cuser)
|
||||
end
|
||||
|
||||
def can_destroy?
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<% if @match.match_proposals.empty? %>
|
||||
<h4>There are no proposals yet</h4>
|
||||
<% else %>
|
||||
|
||||
<table id="proposals" class="striped">
|
||||
<tr>
|
||||
<th>Team</th>
|
||||
|
@ -20,5 +19,5 @@
|
|||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to 'Back', match_path(@match), class: 'button' %><%= link_to 'Propose match time', new_match_proposal_path(@match), class: 'button' %>
|
|
@ -3,7 +3,7 @@
|
|||
<%= render 'shared/errors', messages: @proposal.errors.full_messages %>
|
||||
<div class="fields horizontal">
|
||||
<%= f.label :proposed_time %>
|
||||
<%= f.datetime_select :proposed_time, minute_step: 15 %>
|
||||
<%= f.datetime_select :proposed_time, datetime_separator: '', time_separator: '', minute_step: 15 %>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<%= f.submit 'Propose' %>
|
||||
|
|
Loading…
Reference in a new issue