# Foobar - a sport competition management software
# Copyright (c) 2026 Felipe Cuqueto Piekarz
# Copyright (c) 2026 Luiz Soneghet Nascimento
# Copyright (c) 2026 Rodolfo Ribeiro Gomes
#
# This file is part of Foobar.
#
# Foobar is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Foobar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Foobar.  If not, see <https://www.gnu.org/licenses/>.

from django.db.models.signals import post_migrate
from django.dispatch import receiver
from django.apps import apps

from django.utils.translation import gettext_lazy as _

@receiver(post_migrate)
def create_default_categories(sender, **kwargs):
    Esporte = apps.get_model('torneio', 'Esporte')
    esportes = [
        {"nome": "Basquete"},
        {"nome": "Basquete 3x3"},
        {"nome": "Cabo de guerra"},
        {"nome": "Futebol"},
        {"nome": "Futebol de salão"},
        {"nome": "Handebol"},
        {"nome": "Queimada"},
        {"nome": "Tênis de mesa"},
        {"nome": "Vôlei"},
        {"nome": "Xadrez"},
    ]
    for e in esportes:
        esporte, recem_criado = Esporte.objects.get_or_create(
            nome=e["nome"],
        )
        if recem_criado:
            print(_("Esporte '{nome}' criado.").format(nome=e["nome"]))
