diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb
index f1663c95..8a0ffdbc 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 ffdec04a..b44ef25e 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 d6de4a75..6e7a9aff 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 992ef9a7..a639bdd0 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 3f579844..82a37c1a 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 48d2f364..de11dc78 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 2fb84f60..c1410201 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 d01388c3..003cbf30 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 1f895614..13544e84 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 77e034ee..8dea5eb3 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 341be345..c8075b24 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 b59496cd..cae07963 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