diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 0c260cc..1b6731b 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -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 diff --git a/app/views/contests/edit.html.erb b/app/views/contests/edit.html.erb index a3af0fb..ea4e40c 100644 --- a/app/views/contests/edit.html.erb +++ b/app/views/contests/edit.html.erb @@ -16,6 +16,7 @@
<%= form_for @contest, html: { class: 'square' } do |f| %> <%= render 'shared/errors', messages: @contest.errors.full_messages %> + <%= hidden_field_tag :type, 'contest' %>
<%= 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' %>
<%= 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 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e8bf55c..5120c82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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."