2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-22 14:49:16 -05:00
|
|
|
class Admin::AppearancesController < Admin::ApplicationController
|
|
|
|
before_action :set_appearance, except: :create
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def preview_sign_in
|
|
|
|
render 'preview_sign_in', layout: 'devise'
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@appearance = Appearance.new(appearance_params)
|
|
|
|
|
|
|
|
if @appearance.save
|
2019-03-21 09:31:05 -04:00
|
|
|
redirect_to admin_appearances_path, notice: _('Appearance was successfully created.')
|
2016-02-22 14:49:16 -05:00
|
|
|
else
|
|
|
|
render action: 'show'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @appearance.update(appearance_params)
|
2019-03-21 09:31:05 -04:00
|
|
|
redirect_to admin_appearances_path, notice: _('Appearance was successfully updated.')
|
2016-02-22 14:49:16 -05:00
|
|
|
else
|
|
|
|
render action: 'show'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def logo
|
|
|
|
@appearance.remove_logo!
|
|
|
|
|
|
|
|
@appearance.save
|
|
|
|
|
2019-03-21 09:31:05 -04:00
|
|
|
redirect_to admin_appearances_path, notice: _('Logo was successfully removed.')
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def header_logos
|
|
|
|
@appearance.remove_header_logo!
|
|
|
|
@appearance.save
|
|
|
|
|
2019-03-21 09:31:05 -04:00
|
|
|
redirect_to admin_appearances_path, notice: _('Header logo was successfully removed.')
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
|
2017-09-26 03:54:32 -04:00
|
|
|
def favicon
|
|
|
|
@appearance.remove_favicon!
|
|
|
|
@appearance.save
|
|
|
|
|
2019-03-21 09:31:05 -04:00
|
|
|
redirect_to admin_appearances_path, notice: _('Favicon was successfully removed.')
|
2017-09-26 03:54:32 -04:00
|
|
|
end
|
|
|
|
|
2016-02-22 14:49:16 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
def set_appearance
|
2017-08-09 10:41:51 -04:00
|
|
|
@appearance = Appearance.current || Appearance.new
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
|
|
def appearance_params
|
2018-04-02 10:27:12 -04:00
|
|
|
params.require(:appearance).permit(allowed_appearance_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def allowed_appearance_params
|
|
|
|
%i[
|
|
|
|
title
|
|
|
|
description
|
|
|
|
logo
|
|
|
|
logo_cache
|
|
|
|
header_logo
|
|
|
|
header_logo_cache
|
2017-09-26 03:54:32 -04:00
|
|
|
favicon
|
|
|
|
favicon_cache
|
2018-04-02 10:27:12 -04:00
|
|
|
new_project_guidelines
|
|
|
|
updated_by
|
2018-04-02 10:26:59 -04:00
|
|
|
header_message
|
|
|
|
footer_message
|
|
|
|
message_background_color
|
|
|
|
message_font_color
|
2019-02-20 10:18:15 -05:00
|
|
|
email_header_and_footer_enabled
|
2018-04-02 10:27:12 -04:00
|
|
|
]
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
end
|