Class: Spree::Admin::ThemesController
- Inherits:
-
BaseController
- Object
- BaseController
- Spree::Admin::ThemesController
- Defined in:
- app/controllers/spree/admin/themes_controller.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 49 def destroy if @theme.destroy flash[:notice] = Spree.t('flash.admin.themes.destroy.success', name: @theme.name) redirect_to admin_themes_path else flash[:error] = Spree.t('flash.admin.themes.destroy.failure', name: @theme.name, errors: @theme.errors..join(', ')) render :index end end |
#download ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 38 def download begin zipfile = ZipFileBuilder.new(@theme) zipfile.archive send_file(zipfile.output_path, disposition: 'attachment', filename: zipfile.name) rescue Exception => e flash[:error] = Spree.t('flash.admin.themes.download.failure', name: @theme.name, errors: e.) render :index end end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 8 def index @theme = Spree::Theme.new end |
#state_change ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 23 def state_change state = case params[:state] when 'compiled' then @theme.compile when 'published' then @theme.publish else false end if state flash[:notice] = Spree.t('flash.admin.themes.state_change.success', state: params[:state], name: @theme.name) redirect_to admin_themes_path else flash[:error] = Spree.t('flash.admin.themes.state_change.failure', state: params[:state], name: @theme.name, errors: @theme.errors..join(', ')) render :index end end |
#upload ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spree/admin/themes_controller.rb', line 12 def upload @theme = Spree::Theme.new(theme_params) if @theme.save flash[:notice] = Spree.t('flash.admin.themes.upload.success', name: @theme.name) redirect_to admin_themes_path else flash[:error] = Spree.t('flash.admin.themes.upload.failure', name: @theme.name) render :index end end |