Files
ubicloud/routes/project/usage_alert.rb
2025-02-25 17:56:25 +01:00

30 lines
810 B
Ruby

# frozen_string_literal: true
class Clover
hash_branch(:project_prefix, "usage-alert") do |r|
r.web do
authorize("Project:billing", @project.id)
r.post true do
name = r.params["alert_name"]
Validation.validate_short_text(name, "name")
limit = Validation.validate_usage_limit(r.params["limit"])
UsageAlert.create_with_id(project_id: @project.id, user_id: current_account_id, name: name, limit: limit)
r.redirect "#{@project.path}/billing"
end
r.is String do |usage_alert_ubid|
next unless (usage_alert = UsageAlert.from_ubid(usage_alert_ubid))
r.delete true do
usage_alert.destroy
flash["notice"] = "Usage alert #{usage_alert.name} is deleted."
204
end
end
end
end
end