demarches-normaliennes/app/models/label.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2024-09-25 15:05:09 +02:00
# frozen_string_literal: true
2024-10-29 14:52:14 +01:00
class Label < ApplicationRecord
2024-09-25 15:05:09 +02:00
belongs_to :procedure
2024-09-25 16:03:58 +02:00
has_many :dossier_labels, dependent: :destroy
2024-09-25 15:05:09 +02:00
2024-10-16 14:31:08 +02:00
NAME_MAX_LENGTH = 30
GENERIC_LABELS = [
2024-10-16 14:31:08 +02:00
{ name: 'à relancer', color: 'brown_caramel' },
{ name: 'complet', color: 'green_bourgeon' },
{ name: 'prêt pour validation', color: 'green_archipel' }
]
2024-10-16 14:31:08 +02:00
enum color: {
green_tilleul_verveine: "green-tilleul-verveine",
green_bourgeon: "green-bourgeon",
green_emeraude: "green-emeraude",
green_menthe: "green-menthe",
green_archipel: "green-archipel",
blue_ecume: "blue-ecume",
blue_cumulus: "blue-cumulus",
purple_glycine: "purple-glycine",
pink_macaron: "pink-macaron",
pink_tuile: "pink-tuile",
yellow_tournesol: "yellow-tournesol",
yellow_moutarde: "yellow-moutarde",
orange_terre_battue: "orange-terre-battue",
brown_cafe_creme: "brown-cafe-creme",
brown_caramel: "brown-caramel",
brown_opera: "brown-opera",
beige_gris_galet: "beige-gris-galet"
}
2024-09-25 15:05:09 +02:00
validates :name, :color, presence: true
2024-10-16 14:31:08 +02:00
validates :name, length: { maximum: NAME_MAX_LENGTH }
2024-09-25 15:05:09 +02:00
end