Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
1.1 KiB
Ruby
30 lines
1.1 KiB
Ruby
class SettingsController < ApplicationController
|
|
def show
|
|
@page_title = "Impostazioni"
|
|
@goal = SalesGoal.current(current_project).order(created_at: :desc).first || SalesGoal.new(project: current_project)
|
|
@goals = SalesGoal.for_project(current_project).order(start_date: :desc)
|
|
@products = Product.ordered
|
|
@projects = Project.ordered
|
|
end
|
|
|
|
def update_goal
|
|
@goal = params[:id].present? ? SalesGoal.find(params[:id]) : SalesGoal.new
|
|
attrs = goal_params.merge(active: true)
|
|
attrs[:project_id] ||= current_project&.id
|
|
if @goal.update(attrs)
|
|
if params[:make_current] == "1" && @goal.project_id.present?
|
|
SalesGoal.where(project_id: @goal.project_id).where.not(id: @goal.id).update_all(active: false)
|
|
end
|
|
redirect_to settings_path, notice: "Obiettivo aggiornato."
|
|
else
|
|
redirect_to settings_path, alert: @goal.errors.full_messages.to_sentence
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def goal_params
|
|
params.require(:sales_goal).permit(:name, :metric, :target_value, :start_date, :end_date, :active, :project_id)
|
|
end
|
|
end
|