Skip to content
Snippets Groups Projects
Commit 7ff701c9 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

refactor

parent bcb3229d
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,10 @@ class Api::Osuny::Server::WebsitesController < Api::ApplicationController
end
def theme_released
render_forbidden unless params[:secret_key].present? && params[:secret_key] == ENV['OSUNY_API_AUTOUPDATE_THEME_KEY']
Communication::Website.with_automatic_update.find_each do |website|
website.update_theme_version
if params[:secret_key].present? && params[:secret_key] == ENV['OSUNY_API_AUTOUPDATE_THEME_KEY']
Communication::Website.autoupdate_websites
else
render_forbidden
end
end
end
......@@ -4,8 +4,15 @@ module Communication::Website::WithTheme
included do
scope :with_automatic_update, -> { where(autoupdate_theme: true) }
scope :with_manual_update, -> { where(autoupdate_theme: false) }
def self.autoupdate_websites
Communication::Website.with_automatic_update.find_each do |website|
website.update_theme_version
end
end
end
def get_current_theme_version!
self.update_column :theme_version, current_theme_version
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment