diff --git a/app/views/configurations/index.html.haml b/app/views/configurations/index.html.haml
--- a/app/views/configurations/index.html.haml
+++ b/app/views/configurations/index.html.haml
@@ -8,16 +8,17 @@
%th Key
%th Type
%th Value
-
+ %th Description
- @configurations.each do |conf|
- @configuration = conf
- %tr
+ %tr{:class => cycle("info-odd", "info-even")}
%td
= in_place_editor_field :configuration, :key, {}, :rows=>1
%td
= in_place_editor_field :configuration, :value_type, {}, :rows=>1
%td
= in_place_editor_field :configuration, :value, {}, :rows=>1
+ %td= conf.description
- if Configuration.cache?
%br/
diff --git a/db/migrate/022_create_configurations.rb b/db/migrate/022_create_configurations.rb
--- a/db/migrate/022_create_configurations.rb
+++ b/db/migrate/022_create_configurations.rb
@@ -6,29 +6,6 @@
t.column :value, :string
t.timestamps
end
-
- Configuration.reset_column_information
-
- Configuration.create(:key => 'system.single_user_mode',
- :value_type => 'boolean',
- :value => 'false')
-
- Configuration.create(:key => 'ui.front.title',
- :value_type => 'string',
- :value => 'Grader')
-
- Configuration.create(:key => 'ui.front.welcome_message',
- :value_type => 'string',
- :value => 'Welcome!')
-
- Configuration.create(:key => 'ui.show_score',
- :value_type => 'boolean',
- :value => 'true')
-
- Configuration.create(:key => 'contest.time_limit',
- :value_type => 'string',
- :value => 'unlimited')
-
end
def self.down
diff --git a/db/migrate/036_add_mode_to_configurations.rb b/db/migrate/036_add_mode_to_configurations.rb
deleted file mode 100644
--- a/db/migrate/036_add_mode_to_configurations.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class AddModeToConfigurations < ActiveRecord::Migration
- def self.up
-
- # Configuration['system.mode']:
- # * 'standard' mode
- # * 'contest' mode (check site start time/stop time)
- # * 'analysis' mode (show results, no new submissions)
-
- Configuration.create(:key => 'system.mode',
- :value_type => 'string',
- :value => 'standard')
- end
-
- def self.down
- Configuration.find_by_key('system.mode').destroy
- end
-end
diff --git a/db/migrate/20081012050458_add_contest_name_to_configuration.rb b/db/migrate/20081012050458_add_contest_name_to_configuration.rb
deleted file mode 100644
--- a/db/migrate/20081012050458_add_contest_name_to_configuration.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class AddContestNameToConfiguration < ActiveRecord::Migration
- def self.up
- # Configuration['contest.name']:
- # it will be shown on the user header bar
-
- Configuration.create(:key => 'contest.name',
- :value_type => 'string',
- :value => 'Grader')
- end
-
- def self.down
- Configuration.find_by_key('contest.name').destroy
- end
-end
diff --git a/db/migrate/20081204081043_add_more_options_to_configurations.rb b/db/migrate/20081204081043_add_more_options_to_configurations.rb
deleted file mode 100644
--- a/db/migrate/20081204081043_add_more_options_to_configurations.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-class AddMoreOptionsToConfigurations < ActiveRecord::Migration
- def self.up
- # If the server is in contest mode and
- # Configuration['contest.multisites'] is true
- # the menu for site administrator is shown.
-
- Configuration.create(:key => 'contest.multisites',
- :value_type => 'boolean',
- :value => 'false')
-
- # If Configuration['system.online_registration'] is true,
- # the registration menu would appear
-
- Configuration.create(:key => 'system.online_registration',
- :value_type => 'boolean',
- :value => 'false')
-
- # If Configuration['system.user_setting_enabled'] is true,
- # users can change their settings
-
- Configuration.create(:key => 'system.user_setting_enabled',
- :value_type => 'boolean',
- :value => 'true')
- end
-
- def self.down
- Configuration.find_by_key('contest.multisites').destroy
- Configuration.find_by_key('system.online_registration').destroy
- Configuration.find_by_key('system.user_setting_enabled').destroy
- end
-end
diff --git a/db/migrate/20081205172258_add_emailing_info_on_config_option.rb b/db/migrate/20081205172258_add_emailing_info_on_config_option.rb
deleted file mode 100644
--- a/db/migrate/20081205172258_add_emailing_info_on_config_option.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class AddEmailingInfoOnConfigOption < ActiveRecord::Migration
- def self.up
- # If Configuration['system.online_registration'] is true, the
- # system allows online registration, and will use these
- # information for sending confirmation emails.
- Configuration.create(:key => 'system.online_registration.smtp',
- :value_type => 'string',
- :value => 'smtp.somehost.com')
- Configuration.create(:key => 'system.online_registration.from',
- :value_type => 'string',
- :value => 'your.email@address')
- end
-
- def self.down
- Configuration.find_by_key("system.online_registration.smtp").destroy
- Configuration.find_by_key("system.online_registration.from").destroy
- end
-end
diff --git a/db/migrate/20081214185157_add_admin_email_to_config.rb b/db/migrate/20081214185157_add_admin_email_to_config.rb
deleted file mode 100644
--- a/db/migrate/20081214185157_add_admin_email_to_config.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class AddAdminEmailToConfig < ActiveRecord::Migration
- def self.up
- Configuration.create(:key => 'system.admin_email',
- :value_type => 'string',
- :value => 'admin@admin.email')
- end
-
- def self.down
- Configuration.find_by_key('system.admin_email').destroy
- end
-end
diff --git a/db/migrate/20090202101806_add_test_request_early_timeout_to_config.rb b/db/migrate/20090202101806_add_test_request_early_timeout_to_config.rb
deleted file mode 100644
--- a/db/migrate/20090202101806_add_test_request_early_timeout_to_config.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class AddTestRequestEarlyTimeoutToConfig < ActiveRecord::Migration
- def self.up
- # If Configuration['contest.test_request.early_timeout'] is true
- # the user will not be able to use test request at 30 minutes
- # before the contest ends.
-
- Configuration.create(:key => 'contest.test_request.early_timeout',
- :value_type => 'boolean',
- :value => 'false')
- end
-
- def self.down
- Configuration.find_by_key('contest.test_request.early_timeout').destroy
- end
-end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,124 @@
+
+def create_configuration_key(key,
+ value_type,
+ default_value,
+ description='')
+ conf = (Configuration.find_by_key(key) ||
+ Configuration.new(:key => key,
+ :value_type => value_type,
+ :value => default_value))
+ conf.description = description
+ conf.save
+end
+
+CONFIGURATIONS =
+ [
+ {
+ :key => 'system.single_user_mode',
+ :value_type => 'boolean',
+ :value => 'false',
+ :description => 'Only admins can log in to the system when running under single user mode.'
+ },
+
+ {
+ :key => 'ui.front.title',
+ :value_type => 'string',
+ :value => 'Grader'
+ },
+
+ {
+ :key => 'ui.front.welcome_message',
+ :value_type => 'string',
+ :value => 'Welcome!'
+ },
+
+ {
+ :key => 'ui.show_score',
+ :value_type => 'boolean',
+ :value => 'true'
+ },
+
+ {
+ :key => 'contest.time_limit',
+ :value_type => 'string',
+ :value => 'unlimited',
+ :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits.'
+ },
+
+ {
+ :key => 'system.mode',
+ :value_type => 'string',
+ :value => 'standard',
+ :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".'
+ },
+
+ {
+ :key => 'contest.name',
+ :value_type => 'string',
+ :value => 'Grader',
+ :description => 'This name will be shown on the user header bar.'
+ },
+
+ {
+ :key => 'contest.multisites',
+ :value_type => 'boolean',
+ :value => 'false',
+ :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.'
+ },
+
+ {
+ :key => 'system.online_registration',
+ :value_type => 'boolean',
+ :value => 'false',
+ :description => 'This option enables online registration.'
+ },
+
+ # If Configuration['system.online_registration'] is true, the
+ # system allows online registration, and will use these
+ # information for sending confirmation emails.
+ {
+ :key => 'system.online_registration.smtp',
+ :value_type => 'string',
+ :value => 'smtp.somehost.com'
+ },
+
+ {
+ :key => 'system.online_registration.from',
+ :value_type => 'string',
+ :value => 'your.email@address'
+ },
+
+ {
+ :key => 'system.admin_email',
+ :value_type => 'string',
+ :value => 'admin@admin.email'
+ },
+
+ {
+ :key => 'system.user_setting_enabled',
+ :value_type => 'boolean',
+ :value => 'true',
+ :description => 'If this option is true, users can change their settings'
+ },
+
+ # If Configuration['contest.test_request.early_timeout'] is true
+ # the user will not be able to use test request at 30 minutes
+ # before the contest ends.
+ {
+ :key => 'contest.test_request.early_timeout',
+ :value_type => 'boolean',
+ :value => 'false'
+ }
+ ]
+
+CONFIGURATIONS.each do |conf|
+ if conf.has_key? :description
+ desc = conf[:description]
+ else
+ desc = ''
+ end
+ create_configuration_key(conf[:key],
+ conf[:value_type],
+ conf[:default_value],
+ desc)
+end