mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Added submit function and processing
This commit is contained in:
parent
c4fa4bd188
commit
29a6a83887
2 changed files with 22 additions and 3 deletions
|
@ -16,15 +16,32 @@ class MatchProposalsController < ApplicationController
|
|||
@proposal.team = cuser.team
|
||||
@proposal.status = MatchProposal::STATUS_PENDING
|
||||
|
||||
if @proposal.save!
|
||||
if @proposal.save
|
||||
flash[:notice] = 'Created new proposal'
|
||||
redirect_to(@match)
|
||||
redirect_to(match_proposals_path(@match))
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
raise AccessError unless @match.can_make_proposal?(cuser)
|
||||
@proposal = MatchProposal.find(params[:id])
|
||||
@proposal.status = params[:match_proposal][:status]
|
||||
if @proposal.save
|
||||
action = case @proposal.status
|
||||
when MatchProposal::STATUS_CONFIRMED
|
||||
"Confirmed Proposal for #{Time.use_zone(view_context.timezone_offset) { @proposal.proposed_time.strftime('%d %B %y %H:%M %Z') }}"
|
||||
when MatchProposal::STATUS_REJECTED
|
||||
"Rejected Proposal for #{Time.use_zone(view_context.timezone_offset) { @proposal.proposed_time.strftime('%d %B %y %H:%M %Z') }}"
|
||||
else
|
||||
"Smthn went wrong"
|
||||
end
|
||||
flash[:notice] = action
|
||||
else
|
||||
flash[:notice] = "Error"
|
||||
end
|
||||
redirect_to(match_proposals_path(@match))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
</table>
|
||||
<script type="text/javascript">
|
||||
function proposalStateSubmit(newState, formID) {
|
||||
|
||||
var form = $('#edit_match_proposal_' + formID);
|
||||
form.children("input[type='hidden']").val(newState);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue