Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Extract custom style functionality to separate method

Henriette Dinger7d32ad7cef21
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index 32028a78763..c996aac0c9b 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/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