+ Name |
Title |
Enabled |
@@ -17,6 +18,7 @@
<% @contests.each do |contest| %>
<% @contest = contest %>
+ <%= in_place_editor_field :contest, :name, {}, :rows => 1 %> |
<%= in_place_editor_field :contest, :title, {}, :rows => 1 %> |
<%= in_place_editor_field :contest, :enabled, {}, :rows => 1 %> |
<%= link_to 'Show', contest %> |
diff --git a/app/views/contests/new.html.erb b/app/views/contests/new.html.erb
--- a/app/views/contests/new.html.erb
+++ b/app/views/contests/new.html.erb
@@ -4,6 +4,10 @@
<%= f.error_messages %>
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
<%= f.label :title %>
<%= f.text_field :title %>
@@ -16,4 +20,4 @@
<% end %>
-<%= link_to 'Back', contests_path %>
\ No newline at end of file
+<%= link_to 'Back', contests_path %>
diff --git a/app/views/problems/list.rhtml b/app/views/problems/list.rhtml
--- a/app/views/problems/list.rhtml
+++ b/app/views/problems/list.rhtml
@@ -32,6 +32,9 @@
Date added |
Avail? |
Test? |
+ <% if Configuration.multicontests? %>
+ Contests |
+ <% end %>
<% for problem in @problems %>
@@ -44,6 +47,12 @@
<%= problem.available %> |
<%= problem.test_allowed %> |
+ <% if Configuration.multicontests? %>
+
+ <%= problem.contests.collect { |c| c.name }.join(', ') %>
+ |
+ <% end %>
+
<%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %> |
<%= link_to '[Stat]', :action => 'stat', :id => problem.id %> |
<%= link_to '[Show]', :action => 'show', :id => problem %> |
diff --git a/app/views/problems/manage.html.haml b/app/views/problems/manage.html.haml
--- a/app/views/problems/manage.html.haml
+++ b/app/views/problems/manage.html.haml
@@ -16,12 +16,21 @@
= select_date Date.current, :prefix => 'date_added'
= submit_tag 'Change', :name => 'change_date_added'
+
+ - if Configuration.multicontests?
+ %li
+ Add to
+ = select("contest","id",Contest.all.collect {|c| [c.title, c.id]})
+ = submit_tag 'Add', :name => 'add_to_contest'
+
%table
%tr
%th/
%th Name
%th Full name
%th Date added
+ - if Configuration.multicontests?
+ %th Contests
- for problem in @problems
%tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"}
@@ -29,4 +38,7 @@
%td= problem.name
%td= problem.full_name
%td= problem.date_added
-
+ - if Configuration.multicontests?
+ %td
+ - problem.contests.each do |contest|
+ = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
diff --git a/db/migrate/20100303095700_add_name_to_contests.rb b/db/migrate/20100303095700_add_name_to_contests.rb
new file mode 100644
--- /dev/null
+++ b/db/migrate/20100303095700_add_name_to_contests.rb
@@ -0,0 +1,9 @@
+class AddNameToContests < ActiveRecord::Migration
+ def self.up
+ add_column :contests, :name, :string
+ end
+
+ def self.down
+ remove_column :contests, :name
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100219014840) do
+ActiveRecord::Schema.define(:version => 20100303095700) do
create_table "announcements", :force => true do |t|
t.string "author"
@@ -36,6 +36,7 @@
t.boolean "enabled"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "name"
end
create_table "contests_problems", :id => false, :force => true do |t|
diff --git a/db/seeds.rb b/db/seeds.rb
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -95,6 +95,12 @@
:key => 'contest.test_request.early_timeout',
:value_type => 'boolean',
:default_value => 'false'
+ },
+
+ {
+ :key => 'system.multicontests',
+ :value_type => 'boolean',
+ :default_value => 'false'
}
]
diff --git a/test/fixtures/contests.yml b/test/fixtures/contests.yml
--- a/test/fixtures/contests.yml
+++ b/test/fixtures/contests.yml
@@ -1,13 +1,16 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
contest_a:
+ name: contest_a
title: Contest A
enabled: true
contest_b:
+ name: contest_b
title: Contest B
enabled: true
contest_c:
+ name: contest_c
title: Contest C
enabled: false