appearances_controller.rb 1.67 KB
Newer Older
1
2
# frozen_string_literal: true

3
4
5
6
7
8
class Admin::AppearancesController < Admin::ApplicationController
  before_action :set_appearance, except: :create

  def show
  end

9
10
  def preview_sign_in
    render 'preview_sign_in', layout: 'devise'
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  end

  def create
    @appearance = Appearance.new(appearance_params)

    if @appearance.save
      redirect_to admin_appearances_path, notice: 'Appearance was successfully created.'
    else
      render action: 'show'
    end
  end

  def update
    if @appearance.update(appearance_params)
      redirect_to admin_appearances_path, notice: 'Appearance was successfully updated.'
    else
      render action: 'show'
    end
  end

  def logo
    @appearance.remove_logo!

    @appearance.save

36
    redirect_to admin_appearances_path, notice: 'Logo was successfully removed.'
37
38
39
40
41
42
  end

  def header_logos
    @appearance.remove_header_logo!
    @appearance.save

43
    redirect_to admin_appearances_path, notice: 'Header logo was successfully removed.'
44
45
  end

46
47
48
49
  def favicon
    @appearance.remove_favicon!
    @appearance.save

50
    redirect_to admin_appearances_path, notice: 'Favicon was successfully removed.'
51
52
  end

53
54
55
56
  private

  # Use callbacks to share common setup or constraints between actions.
  def set_appearance
57
    @appearance = Appearance.current || Appearance.new
58
59
60
61
  end

  # Only allow a trusted parameter "white list" through.
  def appearance_params
62
63
64
65
66
67
68
69
70
71
72
    params.require(:appearance).permit(allowed_appearance_params)
  end

  def allowed_appearance_params
    %i[
      title
      description
      logo
      logo_cache
      header_logo
      header_logo_cache
73
74
      favicon
      favicon_cache
75
76
77
      new_project_guidelines
      updated_by
    ]
78
79
  end
end