mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Fixes updating contests
This commit is contained in:
parent
f41e6e0d5a
commit
028fe33941
3 changed files with 12 additions and 3 deletions
|
@ -66,17 +66,17 @@ class ContestsController < ApplicationController
|
|||
|
||||
def update
|
||||
raise AccessError unless @contest.can_update? cuser
|
||||
if params[:commit] == "Save"
|
||||
if update_type == "contest"
|
||||
if @contest.update_attributes(params[:contest])
|
||||
flash[:notice] = t(:contests_update)
|
||||
redirect_to @contest
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
elsif params[:commit] == "Add map"
|
||||
elsif update_type == "map"
|
||||
@contest.maps << Map.find(params[:map])
|
||||
render :edit
|
||||
elsif params[:commit] == "Add team"
|
||||
elsif update_type == "team"
|
||||
contester = Contester.new
|
||||
contester.team = Team.find params[:team]
|
||||
contester.contest = @contest
|
||||
|
@ -107,4 +107,8 @@ class ContestsController < ApplicationController
|
|||
def get_contest
|
||||
@contest = Contest.find params[:id]
|
||||
end
|
||||
|
||||
def update_type
|
||||
params[:type]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<div class="tab" id="general">
|
||||
<%= form_for @contest, html: { class: 'square' } do |f| %>
|
||||
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
|
||||
<%= hidden_field_tag :type, 'contest' %>
|
||||
|
||||
<div class="fields horizontal">
|
||||
<%= f.label :name %>
|
||||
|
@ -106,6 +107,7 @@
|
|||
|
||||
<%= form_for @contest.brackets.build, html: { class: 'square' } do |f| %>
|
||||
<%= render 'shared/errors', messages: @contest.brackets.last.errors.full_messages %>
|
||||
<%= hidden_field_tag :type, 'contest' %>
|
||||
|
||||
<%= f.hidden_field :contest_id %>
|
||||
|
||||
|
@ -142,6 +144,7 @@
|
|||
|
||||
<%= form_for @contest do |f| %>
|
||||
<%= render 'shared/errors', messages: @contest.errors.full_messages %>
|
||||
<%= hidden_field_tag :type, 'map' %>
|
||||
|
||||
<div class="fields">
|
||||
<%= select_tag :map, options_from_collection_for_select(Map.basic, :id, :name) %>
|
||||
|
@ -184,6 +187,7 @@
|
|||
|
||||
<%= form_for @contest.contesters.build do |f| %>
|
||||
<%= render 'shared/errors', messages: @contest.contesters.last.errors.full_messages %>
|
||||
<%= hidden_field_tag :type, 'team' %>
|
||||
|
||||
<%= f.hidden_field :contest_id %>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ en:
|
|||
articles_article_views: "Views"
|
||||
bans_create: "Ban was successfully created."
|
||||
bans_update: "Ban was successfully updated."
|
||||
brackets_create: "Bracket was successfully created."
|
||||
brackets_update: "Bracket was successfully updated."
|
||||
articles_create: "Article was successfully created."
|
||||
articles_update: "Article was successfully updated."
|
||||
|
|
Loading…
Reference in a new issue