diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb
index f1663c95e..8a0ffdbcc 100644
--- a/app/controllers/admin/purchases_controller.rb
+++ b/app/controllers/admin/purchases_controller.rb
@@ -18,6 +18,7 @@ class Admin::PurchasesController < ApplicationController
unzip_design(temp_file, zip_name)
temp_file.close
temp_file.unlink
+ redirect_to admin_designs_url
end
def download
diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb
index ffdec04af..b44ef25ef 100644
--- a/app/controllers/admin/sites_controller.rb
+++ b/app/controllers/admin/sites_controller.rb
@@ -57,6 +57,24 @@ class Admin::SitesController < ApplicationController
end
+ def change_design
+ design = Design.find(params[:site_id]) rescue nil
+ update_design(design) if design
+ render :nothing => true
+ end
+
+ protected
+
+ def update_design(design)
+ @site.design = design
+ if @site.save
+ theme_id = design.themes.first.id
+ Page.all.each do |page|
+ page.update_attributes({design_id: design.id, theme_id: (theme_id unless page.root?)})
+ end
+ end
+ end
+
private
def get_site
diff --git a/app/models/design/design.rb b/app/models/design/design.rb
index d6de4a75b..6e7a9aff7 100644
--- a/app/models/design/design.rb
+++ b/app/models/design/design.rb
@@ -10,6 +10,7 @@ class Design
mount_uploader :zip_file, AssetUploader
+ has_one :site
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy
diff --git a/app/models/site.rb b/app/models/site.rb
index 992ef9a7c..a639bdd0e 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -26,6 +26,7 @@ class Site
field :footer, localize: true
field :sub_menu, localize: true
+ belongs_to :design
has_many :site_metas, :autosave => true, :dependent => :destroy
def generate_keys
diff --git a/app/views/admin/designs/_design.html.erb b/app/views/admin/designs/_design.html.erb
index 3f5798448..82a37c1a6 100644
--- a/app/views/admin/designs/_design.html.erb
+++ b/app/views/admin/designs/_design.html.erb
@@ -9,6 +9,7 @@
+
<%= radio_button_tag 'design_default', design.id, (@site.design.id.to_s.eql?(design.id.to_s) ? true : false), :class => 'design_default', :rel => admin_sites_path %> |
<%= design.intro %> |
<%= design.author %> |
\ No newline at end of file
diff --git a/app/views/admin/designs/_designs.html.erb b/app/views/admin/designs/_designs.html.erb
index 48d2f3644..de11dc784 100644
--- a/app/views/admin/designs/_designs.html.erb
+++ b/app/views/admin/designs/_designs.html.erb
@@ -2,6 +2,7 @@
|
|
+ |
|
|
@@ -9,4 +10,15 @@
<%= render :partial => 'design', :collection => @designs %>
-
\ No newline at end of file
+
+
+<% content_for :page_specific_javascript do %>
+
+<% end %>
diff --git a/app/views/admin/designs/_sort_headers.html.erb b/app/views/admin/designs/_sort_headers.html.erb
index 2fb84f60d..c14102016 100644
--- a/app/views/admin/designs/_sort_headers.html.erb
+++ b/app/views/admin/designs/_sort_headers.html.erb
@@ -1,4 +1,5 @@
<%= render_sort_bar(true, delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]),
['title', 'title','span2', :title],
+ ['', '', 'span1', :default],
['intro', 'intro', 'span7', :intro],
['author', 'author', 'span2', :author]).html_safe %>
diff --git a/app/views/admin/module_store/show.html.erb b/app/views/admin/module_store/show.html.erb
index d01388c33..003cbf302 100644
--- a/app/views/admin/module_store/show.html.erb
+++ b/app/views/admin/module_store/show.html.erb
@@ -25,7 +25,7 @@
Module Name
free download
who use it?
diff --git a/app/views/admin/template_store/show.html.erb b/app/views/admin/template_store/show.html.erb
index 1f895614f..13544e84a 100644
--- a/app/views/admin/template_store/show.html.erb
+++ b/app/views/admin/template_store/show.html.erb
@@ -25,8 +25,8 @@
<%= @template['title'] %>
<%= link_to 'free download', buy_template_admin_purchase_path(@template['id']), :id => "download" %>
@@ -56,8 +56,8 @@
Template Name
free download
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 77e034eec..8dea5eb3b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -148,6 +148,7 @@ en:
web_link: Link
dashboard_: Dashboard
deadline: Deadline
+ default: Default
default_css: Default CSS
delete:
file: Delete file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 341be3451..c8075b24d 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -148,6 +148,7 @@ zh_tw:
web_link: 鏈接
dashboard_: 儀表版
deadline: 最後期限
+ default: Default
default_css: 預設樣式表
delete:
file: 刪除檔案
diff --git a/config/routes.rb b/config/routes.rb
index b59496cdf..cae079633 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -128,6 +128,7 @@ Orbit::Application.routes.draw do
get 'sitemap_toggle', :on => :member
get 'system_info'
get 'ui_theme'
+ get 'change_design'
end
resources :tags
resources :users