Skip to content

Commit

Permalink
Documented and cleaned up config variables a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
augustf committed May 5, 2012
1 parent 3c54025 commit 0beace6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
24 changes: 17 additions & 7 deletions app/models/concerto_config.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#Current configuration keys:
#:public_concerto
#:default_upload_type
#:content_default_start_time
#:content_default_end_time
#:content_default_duration
#:setup_complete
#public_concerto
#default_upload_type
#content_default_start_time
#content_default_end_time
#setup_complete
#default_content_run_time
#start_date_offset

#Adding a new configuration variable:
#Either in your plugin, or in the seeds file, add a row as such:
# ConcertoConfig.find_or_create_by_key(:key => "default_upload_type", :value => "graphic", :value_default => "graphic", :value_type => "string")
#The value type and default will allow the Dashboard to properly create the form for editing the variable
#Also ensure to provide a translation in an appropriate YAML file:
# default_upload_type: "Default content upload type"

#The variable can then be accessed like this: ConcertoConfig[:public_concerto]
#and modified by calling ConcertoConfig.set(public_concerto,true)

class ConcertoConfig < ActiveRecord::Base

Expand All @@ -16,7 +27,6 @@ class ConcertoConfig < ActiveRecord::Base

# Enable hash-like access to table for ease of use
# Returns false if key isn't found
# Example: ConcertoConfig[:public_concerto] => "true"
def self.[](key)
rec = self.find_by_key(key.to_s)
if rec.nil?
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form_tag "/dashboard/update" do %>
<% @configs = ConcertoConfig.all %>
<% for c in @configs %>
<% if c.value_type == "string" || "integer" %>
<% if c.value_type == "string" || c.value_type == "integer" %>
<%= t(c.key.to_sym) %>:
<%= text_field_tag "concerto_config[#{c.key}]", ConcertoConfig[c.key.to_sym] %><br />
<% elsif c.value_type == "boolean" %>
Expand Down
4 changes: 3 additions & 1 deletion config/locales/views/dashboard/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ en:
default_upload_type: "Default content upload type"
content_default_start_time: "Default start time for content"
content_default_end_time: "Default end time for content"
content_default_duration: "Default duration for content (in days)"
content_default_duration: "Default duration for content (in days)"
start_date_offset: "Time between submission and content start"
default_content_run_time: "Default content run time (in days)"

0 comments on commit 0beace6

Please sign in to comment.