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