<commit_before>from django.conf import settings

from agir.payments.payment_modes import PAYMENT_MODES
from agir.system_pay import AbstractSystemPayPaymentMode

_CAMPAGNES = {}


def init_campagnes():
    for config in settings.MUNICIPALES_CAMPAGNES:
        code_departement = config["code_departement"]
        slug = config["slug"]
        snake_case = "_".join(slug.split("-"))
        title_case = "".join(c.title() for c in slug.split("-"))
        payment_id = f"{snake_case}_system_pay"

        _CAMPAGNES[code_departement, slug] = {**config, "payment_mode": payment_id}

        sp_config = config["sp_config"]
        payment_mode = type(
            f"{title_case}PaymentMode",
            (AbstractSystemPayPaymentMode,),
            {
                "id": payment_id,
                "url_fragment": f"carte-{code_departement}-{slug}",
                "label": f"Prêt par carte à {config['nom_liste']}",
                "sp_config": sp_config,
                "campagne": _CAMPAGNES[code_departement, slug],
            },
        )

        PAYMENT_MODES[payment_id] = payment_mode()
<commit_msg>fix: affichage des prêts pour Montpellier<commit_after>from django.conf import settings

from agir.payments.payment_modes import PAYMENT_MODES
from agir.system_pay import AbstractSystemPayPaymentMode

_CAMPAGNES = {}


def init_campagnes():
    for config in settings.MUNICIPALES_CAMPAGNES:
        code_departement = config["code_departement"]
        slug = config["slug"]
        snake_case = "_".join(slug.split("-"))
        title_case = "".join(c.title() for c in slug.split("-"))
        payment_id = f"{snake_case}_system_pay"

        _CAMPAGNES[code_departement, slug] = {**config, "payment_mode": payment_id}

        sp_config = config["sp_config"]
        payment_mode = type(
            f"{title_case}PaymentMode",
            (AbstractSystemPayPaymentMode,),
            {
                "id": payment_id,
                "url_fragment": f"carte-{code_departement}-{slug}",
                "label": f"Prêt par carte à {config['nom_liste']}",
                "title": f"Prêt à {config['nom_liste']}",
                "sp_config": sp_config,
                "campagne": _CAMPAGNES[code_departement, slug],
            },
        )

        PAYMENT_MODES[payment_id] = payment_mode()

{'fraction_non_alphanumeric': 0.12077922077922078, 'fraction_numerical': 0.0, 'mean_word_length': 2.5996884735202492, 'pattern_counts': {'":': 13, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4095331', 'n_tokens_mistral': 764, 'n_tokens_neox': 746, 'n_words': 131}