Extract custom style functionality to separate method

pull/8069/head
Henriette Dinger 5 years ago
parent de02cc2df2
commit 7d32ad7cef
  1. 10
      app/controllers/custom_styles_controller.rb

@ -54,7 +54,7 @@ class CustomStylesController < ApplicationController
end
def update
@custom_style = CustomStyle.current || CustomStyle.create!
@custom_style = get_or_create_custom_style
if @custom_style.update(custom_style_params)
redirect_to custom_style_path
else
@ -121,7 +121,7 @@ class CustomStylesController < ApplicationController
end
def set_logo(logo)
(CustomStyle.current || CustomStyle.create!).update(theme_logo: logo)
get_or_create_custom_style.update(theme_logo: logo)
end
def set_colors(variable_params)
@ -144,10 +144,14 @@ class CustomStylesController < ApplicationController
def set_theme(params)
theme = ActionController::Parameters.new(theme: params[:theme] || '').permit(:theme)
@custom_style = (CustomStyle.current || CustomStyle.create!)
@custom_style = get_or_create_custom_style
@custom_style.update(theme)
end
def get_or_create_custom_style
CustomStyle.current || CustomStyle.create!
end
def require_ee_token
unless EnterpriseToken.allows_to?(:define_custom_style)
redirect_to custom_style_upsale_path

Loading…
Cancel
Save