prefs model added

This commit is contained in:
Wojciech Todryk 2011-07-24 15:56:47 +02:00
parent da03add37b
commit 86e1817e29
12 changed files with 88 additions and 10 deletions

View file

@ -8,22 +8,22 @@ class ApplicationController < ActionController::Base
protected
def load_defaults
@defaults = YAML::load(File.open(Rails.root.join('config','defaults.yml')))
$defaults ||= YAML::load(File.open(Rails.root.join('config','defaults.yml')))
end
def theme_resolver
if @current_user.nil?
@defaults['theme']
$defaults['theme']
else
@current_user.theme
@current_user.prefs.theme
end
end
def set_locale
if @current_user.nil?
I18n.locale = @defaults['locale'] || I18n.default_locale
I18n.locale = $defaults['locale'] || I18n.default_locale
else
I18n.locale = @current_user.locale || I18n.default_locale
I18n.locale = @current_user.prefs.locale || I18n.default_locale
end
end

View file

@ -4,6 +4,7 @@ class MessagesController < ApplicationController
theme :theme_resolver
def index
end
end

View file

@ -17,9 +17,15 @@ class UserController < ApplicationController
if user.nil?
redirect_to :action => 'unknown'
else
auten = false
auten = true
if auten == true
session[:user_id] = user.id
if session["return_to"]
redirect_to(session["return_to"])
session["return_to"] = nil
else
redirect_to :controller=> "messages",:action=>"index"
end
else
flash[:error] = t(:login_failure)
redirect_to :action => 'login'
@ -49,6 +55,7 @@ class UserController < ApplicationController
@user.save
@server.user_id = @user.id
@server.save
Prefs.create_default(@user.id)
flash[:notice] = t(:setup_done)
redirect_to :action => 'login'
else