Chris's first commit at Fri Jan 28 2011 10:14:32 GMT+0800 (CST)
This commit is contained in:
1 parent
554aa0a95d
commit
19a7d51e60
145 files changed
+12742
-893
No files matched your search
@@ -2,24 +2,24 @@ class Admin::AssetsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def show
|
||||
@asset = Asset.find(params[:id])
|
||||
send_data @asset.data.file.read, :filename => @asset.filename,
|
||||
:type => @asset.data.content_type,
|
||||
:disposition => 'inline' # or 'attachment'
|
||||
end
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@assets = Asset.all
|
||||
@assets = Asset.all.entries
|
||||
end
|
||||
|
||||
def show
|
||||
#TODO
|
||||
end
|
||||
|
||||
def edit
|
||||
@asset = Asset.find(params[:id])
|
||||
session[:last_page] = get_go_back || admin_assets_url
|
||||
end
|
||||
|
||||
def new
|
||||
@asset = Asset.new
|
||||
session[:last_page] = get_go_back || admin_assets_url
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
class Admin::HomesController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def show
|
||||
#TODO
|
||||
end
|
||||
|
||||
def new
|
||||
@home = Home.new
|
||||
@home.is_published = true
|
||||
@home.parent_id = nil
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@home = Home.find(params[:id])
|
||||
@i18n_variable = @home.i18n_variable
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def create
|
||||
@home = Home.new(params[:home])
|
||||
|
||||
if @home.save
|
||||
flash[:notice] = t('admin.create_success_home')
|
||||
redirect_to admin_items_url
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@home = Home.find(params[:id])
|
||||
if @home.update_attributes(params[:home])
|
||||
flash[:notice] = t('admin.update_success_home')
|
||||
redirect_to admin_items_url
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@home = Home.find(params[:id])
|
||||
@home.destroy
|
||||
|
||||
redirect_to admin_items_url
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,31 +3,34 @@ class Admin::ItemsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_filter :authenticate_user!
|
||||
|
||||
before_filter :find_parent_item
|
||||
before_filter :find_snippets, :only => :index
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@items = Item.all( :conditions => { :parent_id => @parent_item.id } )
|
||||
@items.unshift Item.find_by_name("root") if @parent_item.name == 'root'
|
||||
end
|
||||
|
||||
def up
|
||||
@item = Item.find(params[:id])
|
||||
@item.move_higher
|
||||
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||
end
|
||||
|
||||
def down
|
||||
@item = Item.find(params[:id])
|
||||
@item.move_lower
|
||||
redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||
@items = Item.where(:parent_id => @parent_item.id).entries rescue []
|
||||
@items = Item.where(:_type => 'Home').entries unless (!@items.empty? || @parent_item)
|
||||
end
|
||||
|
||||
|
||||
#TODO
|
||||
# Allow to move items down and up different parents
|
||||
# def up
|
||||
# @item = Item.find(params[:id])
|
||||
# @item.move_higher
|
||||
# redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||
# end
|
||||
#
|
||||
# def down
|
||||
# @item = Item.find(params[:id])
|
||||
# @item.move_lower
|
||||
# redirect_to admin_items_url( :parent_name => @item.parent_name )
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
def find_snippets
|
||||
@snippets = Snippet.all( :conditions => { :parent_id => @parent_item.id } )
|
||||
@snippets = Snippet.where( { :parent_id => @parent_item.id } ) rescue nil
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,33 +2,36 @@ class Admin::LayoutsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@layouts = Layout.all
|
||||
@layouts = Layout.all.entries
|
||||
end
|
||||
|
||||
def show
|
||||
@layout = Layout.find(params[:id])
|
||||
|
||||
redirect_to "/#{@layout.name}"
|
||||
#TODO
|
||||
# @layout = Layout.find(params[:id])
|
||||
# redirect_to "/#{@layout.name}"
|
||||
end
|
||||
|
||||
def new
|
||||
@layout = Layout.new
|
||||
session[:last_page] = get_go_back || admin_layouts_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@layout = Layout.find(params[:id])
|
||||
session[:last_page] = get_go_back || admin_layouts_url
|
||||
end
|
||||
|
||||
def create
|
||||
@layout = Layout.new(params[:layout])
|
||||
|
||||
if @layout.save
|
||||
flash[:notice] = 'Layout was successfully created.'
|
||||
flash[:notice] = t('admin.create_success_layout')
|
||||
redirect_to admin_layouts_url
|
||||
else
|
||||
render :action => "new"
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +39,7 @@ class Admin::LayoutsController < ApplicationController
|
||||
@layout = Layout.find(params[:id])
|
||||
|
||||
if @layout.update_attributes(params[:layout])
|
||||
flash[:notice] = 'Layout was successfully updated.'
|
||||
flash[:notice] = t('admin.update_success_layout')
|
||||
redirect_to admin_layouts_url
|
||||
else
|
||||
render :action => "edit"
|
||||
|
||||
@@ -3,6 +3,7 @@ class Admin::LinksController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :is_admin?
|
||||
|
||||
def show
|
||||
#TODO
|
||||
@@ -11,19 +12,22 @@ class Admin::LinksController < ApplicationController
|
||||
def new
|
||||
@link = Link.new
|
||||
@link.is_published = true
|
||||
@link.parent_name = @parent_item.name
|
||||
@link.parent_id = @parent_item.id rescue nil
|
||||
session[:last_page] = get_go_back || admin_links_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@link = Link.find(params[:id])
|
||||
@i18n_variable = @link.i18n_variable
|
||||
session[:last_page] = get_go_back || admin_links_url
|
||||
end
|
||||
|
||||
def create
|
||||
@link = Link.new(params[:link])
|
||||
|
||||
if @link.save
|
||||
flash[:notice] = 'Link was successfully created.'
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
flash[:notice] = t('admin.create_success_link')
|
||||
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -33,8 +37,8 @@ class Admin::LinksController < ApplicationController
|
||||
@link = Link.find(params[:id])
|
||||
|
||||
if @link.update_attributes(params[:link])
|
||||
flash[:notice] = 'Link was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
flash[:notice] = t('admin.update_success_link')
|
||||
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -44,7 +48,7 @@ class Admin::LinksController < ApplicationController
|
||||
@link = Link.find(params[:id])
|
||||
@link.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_name => @link.parent_name )
|
||||
redirect_to admin_items_url( :parent_id => @link.parent_id )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,6 +3,7 @@ class Admin::PagesController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :is_admin?
|
||||
|
||||
def show
|
||||
#TODO
|
||||
@@ -11,19 +12,22 @@ class Admin::PagesController < ApplicationController
|
||||
def new
|
||||
@page = Page.new
|
||||
@page.is_published = true
|
||||
@page.parent_name = @parent_item.name
|
||||
@page.parent_id = @parent_item.id rescue nil
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
@i18n_variable = @page.i18n_variable
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def create
|
||||
@page = Page.new(params[:page])
|
||||
|
||||
if @page.save
|
||||
flash[:notice] = 'Page was successfully created.'
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
flash[:notice] = t('admin.create_success_page')
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -31,10 +35,9 @@ class Admin::PagesController < ApplicationController
|
||||
|
||||
def update
|
||||
@page = Page.find(params[:id])
|
||||
|
||||
if @page.update_attributes(params[:page])
|
||||
flash[:notice] = 'Page was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
flash[:notice] = t('admin.update_success_page')
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -44,7 +47,7 @@ class Admin::PagesController < ApplicationController
|
||||
@page = Page.find(params[:id])
|
||||
@page.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_name => @page.parent_name )
|
||||
redirect_to admin_items_url( :parent_id => @page.parent_id )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,6 +3,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_parent_item
|
||||
before_filter :is_admin?
|
||||
|
||||
def show
|
||||
#TODO
|
||||
@@ -10,19 +11,21 @@ class Admin::SnippetsController < ApplicationController
|
||||
|
||||
def new
|
||||
@snippet = Snippet.new
|
||||
@snippet.parent_name = @parent_item.name
|
||||
@snippet.parent_id = @parent_item.id
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@snippet = Snippet.find(params[:id])
|
||||
session[:last_page] = get_go_back || admin_items_url
|
||||
end
|
||||
|
||||
def create
|
||||
@snippet = Snippet.new(params[:snippet])
|
||||
|
||||
if @snippet.save
|
||||
flash[:notice] = 'Snippet was successfully created.'
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
flash[:notice] = t('admin.create_success_snippet')
|
||||
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
@@ -32,8 +35,8 @@ class Admin::SnippetsController < ApplicationController
|
||||
@snippet = Snippet.find(params[:id])
|
||||
|
||||
if @snippet.update_attributes(params[:snippet])
|
||||
flash[:notice] = 'Snippet was successfully updated.'
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
flash[:notice] = t('admin.update_success_snippet')
|
||||
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
@@ -43,7 +46,7 @@ class Admin::SnippetsController < ApplicationController
|
||||
@snippet = Snippet.find(params[:id])
|
||||
@snippet.destroy
|
||||
|
||||
redirect_to admin_items_url( :parent_name => @snippet.parent_name )
|
||||
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,78 @@
|
||||
class Admin::TranslationsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
set_variables
|
||||
end
|
||||
|
||||
def edit
|
||||
set_variables
|
||||
session[:last_page] = get_go_back || admin_translations_url
|
||||
end
|
||||
|
||||
# Update either the i18n_variables or the languages
|
||||
def update
|
||||
begin
|
||||
case params[:id]
|
||||
# Update the i18n_variables
|
||||
when 'all'
|
||||
params[:i18n_variables].each do |id, var|
|
||||
i18n_variable = I18nVariable.find(id)
|
||||
i18n_variable.update_attributes(var)
|
||||
end
|
||||
# Add a language
|
||||
when 'add'
|
||||
site = Site.find(session[:site])
|
||||
if !site.valid_locales.include?(params[:language])
|
||||
site.valid_locales << params[:language]
|
||||
site.save
|
||||
I18nVariable.create({:key => params[:language], :document_class => 'language'})
|
||||
end
|
||||
# Enable a language
|
||||
when 'enable'
|
||||
site = Site.find(session[:site])
|
||||
if !site.in_use_locales.include?(params[:enable_language])
|
||||
site.in_use_locales << params[:enable_language]
|
||||
site.save
|
||||
end
|
||||
# Disable a language
|
||||
when 'disable'
|
||||
site = Site.find(session[:site])
|
||||
if site.in_use_locales.include?(params[:disable_language])
|
||||
site.in_use_locales.delete(params[:disable_language])
|
||||
site.save
|
||||
end
|
||||
# Delete a language and the corresponding i18n_variables
|
||||
when 'delete'
|
||||
site = Site.find(session[:site])
|
||||
site.in_use_locales.delete(params[:delete_language])
|
||||
site.valid_locales.delete(params[:delete_language])
|
||||
site.save
|
||||
I18nVariable.destroy_all(:conditions => {:document_class => 'language', :key => params[:delete_language]})
|
||||
end
|
||||
redirect_to admin_translations_url
|
||||
rescue
|
||||
set_variables
|
||||
render :action => :edit
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Get the i18n_variables and languages
|
||||
def set_variables
|
||||
@i18n_variables = I18nVariable.all.entries
|
||||
@language_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||
result << var if var.document_class.eql?('language')
|
||||
result
|
||||
end
|
||||
@user_attribute_model_i18n_variables = @i18n_variables.inject([]) do |result, var|
|
||||
result << var if var.document_class.eql?('UserAttributeModel')
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
class Admin::UserAttributeModelsController < ApplicationController
|
||||
|
||||
layout "admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
@user_attribute_models = UserAttributeModel.all.entries
|
||||
end
|
||||
|
||||
def show
|
||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@user_attribute_model = UserAttributeModel.new
|
||||
session[:last_page] = get_go_back || admin_user_attribute_models_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
||||
@i18n_variable = @user_attribute_model.i18n_variable
|
||||
session[:last_page] = get_go_back || admin_user_attribute_models_url
|
||||
end
|
||||
|
||||
def create
|
||||
@user_attribute_model = UserAttributeModel.new(params[:user_attribute_model])
|
||||
@user_attribute_model.save
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def update
|
||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
||||
@user_attribute_model.update_attributes(params[:user_attribute_model])
|
||||
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
def destroy
|
||||
@user_attribute_model = UserAttributeModel.find(params[:id])
|
||||
@user_attribute_model.destroy
|
||||
|
||||
@user_attribute_model.destroy_i18n_variables
|
||||
|
||||
redirect_to :action => :index
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user