Permalink
Browse files

configuration moved into initializers, Radiant.config method, ui comp…

…leted, internationalized
  • Loading branch information...
1 parent 333c065 commit 0a4463daa71688b27adaa175de3dfd339d0081b4 @will-r will-r committed Oct 13, 2010
@@ -7,26 +7,21 @@ class Admin::ConfigurationController < ApplicationController
:denied_message => 'You must have admin privileges to edit site configuration.'
def show
-
+ render
end
def edit
-
+ render
end
def update
if params[:config]
begin
- Radiant::Config.transaction do
+ Radiant.config.transaction do
params["config"].each_pair do |key, value|
- Rails.logger.warn "!! config key: #{key} -> #{value}"
-
@config[key] = Radiant::Config.find_or_create_by_key(key)
- @config[key].value = value # sets errors on @config['key'] that the helper methods will pick up
+ @config[key].value = value # validation sets errors on @config['key'] that the helper methods will pick up
end
-
- Rails.logger.warn "@config is #{@config.inspect}"
-
redirect_to :action => :show
end
rescue ActiveRecord::RecordInvalid => e
@@ -18,7 +18,7 @@ def edit
def update
if valid_params?
if @user.update_attributes(params[:user])
- redirect_to :action => 'show'
+ redirect_to admin_configuration_path
else
flash[:error] = t('preferences_controller.error_updating')
render :edit
@@ -1,51 +0,0 @@
-class Admin::SettingsController < ApplicationController
- # before_filter :get_setting, :except => [:index]
-
- only_allow_access_to :show, :edit, :update,
- :when => [:admin],
- :denied_url => { :controller => 'admin/settings', :action => 'index' },
- :denied_message => 'You must have admin privileges to edit settings.'
-
- def index
- redirect_to admin_configuration_url
- end
-
- def show
- respond_to do |format|
- format.html { }
- format.js { render :layout => false }
- end
- end
-
- def edit
- respond_to do |format|
- format.html { }
- format.js { render :layout => false }
- end
- end
-
- def update
- @setting.value = params[:config][:value]
- respond_to do |format|
- format.html { render :action => 'show' }
- format.js { render :layout => false, :action => 'show' }
- end
- end
-
-private
-
- def get_setting
- @setting = Radiant::Config.find(params[:id])
- unless @setting.settable?
- respond_to do |format|
- format.html {
- flash['error'] = "#{@setting.key} is not settable"
- redirect_to :action => 'index'
- }
- format.js { render :status => 403, :text => "#{@setting.key} is not settable" }
- end
- return false
- end
- end
-
-end
@@ -6,13 +6,13 @@ module Admin::ConfigurationHelper
# show_setting("admin.title")
# => <label for="admin_title">Admin title<label><span id="admin_title">Radiant CMS</span>
#
- def show_setting(key, options={})
+ def show_config(key, options={})
setting = setting_for(key)
domkey = key.gsub(/\W/, '_')
html = ""
- html << content_tag(:label, (options[:label] || setting.label || key), :for => domkey)
+ html << content_tag(:label, t("config.#{key}").titlecase, :for => domkey)
if setting.boolean?
- html << content_tag(:span, setting.value.to_s, :class => setting.checked?, :id => domkey)
+ html << content_tag(:span, setting.value.to_s, :class => options[:class] || setting.checked?.to_s, :id => domkey)
else
html << content_tag(:span, (setting.selected_value || setting.value), :id => domkey)
end
@@ -34,11 +34,11 @@ def show_setting(key, options={})
# edit_setting("user.allow_password_reset?")
# => <label for="user_allow_password_reset_">Admin title<label><input type="checkbox" name="config['user.allow_password_reset?']" id="user_allow_password_reset_" value="1" checked="checked" />
#
- def edit_setting(key, options={})
+ def edit_config(key, options={})
setting = setting_for(key)
domkey = key.gsub(/\W/, '_')
name = "config[#{key}]"
- title = options[:label] || setting.label || key
+ title = t("config.#{key}").titlecase
value = params[key.to_sym].nil? ? setting.value : params[key.to_sym]
html = ""
if setting.boolean?
@@ -57,7 +57,7 @@ def edit_setting(key, options={})
def setting_for(key)
@config ||= {} # normally initialized in Admin::ConfigurationController
- @config[key] ||= Radiant::Config.find_or_create_by_key(key)
+ @config[key] ||= Radiant.config.find_or_create_by_key(key)
end
def definition_for(key)
Oops, something went wrong.

0 comments on commit 0a4463d

Please sign in to comment.