Class: Spree::Admin::ThemesController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::ThemesController
- Includes:
- StorefrontBreadcrumbConcern
- Defined in:
- app/controllers/spree/admin/themes_controller.rb
Instance Method Summary collapse
Instance Method Details
#clone ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 48 def clone @new = @theme.duplicate if @new.persisted? flash[:success] = Spree.t('theme_copied') else flash[:error] = Spree.t('theme_not_copied', error: @new.errors..to_sentence) end redirect_to spree.admin_themes_path end |
#edit ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 10 def edit @theme_preview = params[:theme_preview_id].present? ? @theme.previews.find(params[:theme_preview_id]) : @theme.create_preview @page = if params[:page_id].present? @theme.pages.find_by(id: params[:page_id]) || current_store.pages.find(params[:page_id]) else @theme.pages.find_by(type: 'Spree::Pages::Homepage') end @page_preview = params[:page_preview_id].present? ? @page.previews.find(params[:page_preview_id]) : @page.create_preview session[:theme_preview_id] = @theme_preview.id session[:page_preview_id] = @page_preview.id end |
#publish ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 37 def publish @theme = current_store.themes.find(params[:id]) if @theme.update(default: true) flash[:success] = Spree.t('theme_is_now_live') else flash[:error] = "#{Spree.t('something_went_wrong')}: #{@theme.errors..to_sentence}" end redirect_to spree.admin_themes_path end |
#update_with_page ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 23 def update_with_page @theme_preview = @theme.previews.find(params[:theme_preview_id]) @page_preview = @theme.page_previews.find_by(id: params[:page_preview_id]) || current_store.page_previews.find(params[:page_preview_id]) ApplicationRecord.transaction do @page_preview.promote && @theme_preview.promote end flash[:success] = Spree.t('changes_published') redirect_to spree.edit_admin_theme_path(@theme_preview, page_id: @page_preview.id), status: :see_other rescue ActiveRecord::RecordInvalid redirect_to spree.edit_admin_theme_path(@theme_preview, page_id: @page_preview.id), alert: Spree.t('something_went_wrong') end |