2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-10-03 16:20:13 +02:00
|
|
|
class SuperAdmins::ReleaseNotesController < ApplicationController
|
|
|
|
before_action :authenticate_super_admin!
|
2023-10-26 14:36:03 +02:00
|
|
|
before_action :set_note, only: [:edit, :update, :destroy]
|
2023-10-03 16:20:13 +02:00
|
|
|
|
2023-10-30 15:37:04 +01:00
|
|
|
def nav_bar_profile
|
|
|
|
:superadmin
|
|
|
|
end
|
|
|
|
|
2023-10-03 16:20:13 +02:00
|
|
|
def index
|
|
|
|
@release_notes = ReleaseNote
|
|
|
|
.order(released_on: :desc, id: :asc)
|
|
|
|
.with_rich_text_body
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
# allows refreshing a submitted page in error
|
|
|
|
redirect_to edit_super_admins_release_note_path(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2023-10-26 14:36:03 +02:00
|
|
|
@release_note = ReleaseNote.new(released_on: params[:date].presence || Date.current, published: true)
|
2023-10-03 16:20:13 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@release_note = ReleaseNote.new(release_note_params)
|
|
|
|
if @release_note.save
|
|
|
|
redirect_to edit_super_admins_release_note_path(@release_note), notice: t('.success')
|
|
|
|
else
|
|
|
|
flash.now[:alert] = [t('.error'), @release_note.errors.full_messages].flatten
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@release_note = ReleaseNote.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @release_note.update(release_note_params)
|
|
|
|
redirect_to edit_super_admins_release_note_path(@release_note), notice: t('.success')
|
|
|
|
else
|
|
|
|
flash.now[:alert] = [t('.error'), @release_note.errors.full_messages].flatten
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-26 14:36:03 +02:00
|
|
|
def destroy
|
|
|
|
@release_note.destroy!
|
|
|
|
|
|
|
|
redirect_to super_admins_release_notes_path, notice: t('.success')
|
|
|
|
end
|
|
|
|
|
2023-10-03 16:20:13 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def release_note_params
|
|
|
|
params.require(:release_note).permit(:released_on, :published, :body, categories: [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_note
|
|
|
|
@release_note = ReleaseNote.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|