Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions badge_generator/migrations/0004_auto_20260326_1143.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Generated by Django 6.0.3 on 2026-03-26 10:43

from django.db import migrations

from badge_generator.illustrations import ILLUSTRATIONS_BY_ABBREVIATION


def populate_badge_level_and_category(apps, schema_editor):
create_categories(apps, schema_editor)
create_levels(apps, schema_editor)

def create_levels(apps, schema_editor):

BadgeLevel = apps.get_model('badge_generator', 'BadgeLevel')
levels_to_create = [
{
"name": "Découverte",
"description": "Premier contact avec le sujet.",
"rank": 1,
"posture_text": "JE DÉCOUVRE",
"stroke_width": 2,
},
{
"name": "Compréhension",
"description": "Je comprends les bases du sujet.",
"rank": 2,
"posture_text": "JE COMPRENDS",
"stroke_width": 4,
},
{
"name": "Pratique",
"description": "Je pratique de manière autonome.",
"rank": 3,
"posture_text": "JE PRATIQUE",
"stroke_width": 7,
},
{
"name": "Maîtrise",
"description": "Maîtrise avancée du sujet.",
"rank": 4,
"posture_text": "JE MAÎTRISE",
"stroke_width": 11,
},
{
"name": "Transmission",
"description": "Capacité à transmettre et former les autres.",
"rank": 5,
"posture_text": "JE TRANSMETS",
"stroke_width": 16,
},
]

for level_data in levels_to_create:
BadgeLevel.objects.update_or_create(
name=level_data["name"],
defaults=level_data,
)


def create_categories(apps, schema_editor):
BadgeCategory = apps.get_model('badge_generator', 'BadgeCategory')
categories_to_create = [
{
"name": "Compétence",
"abbreviation": "Cp",
"description": "Reconnaître un savoir ou une compétence acquise.",
"icon": "💡",
"color": "#0077B6",
"display_order": 1,
},
{
"name": "Savoir-faire",
"abbreviation": "Sf",
"description": "Reconnaître un savoir-faire technique ou manuel.",
"icon": "🔧",
"color": "#E76F51",
"display_order": 2,
},
{
"name": "Savoir-être",
"abbreviation": "Se",
"description": "Reconnaître des qualités humaines et relationnelles.",
"icon": "❤️",
"color": "#E63946",
"display_order": 3,
},
{
"name": "Savoir-vivre",
"abbreviation": "Sv",
"description": "Reconnaître le vivre-ensemble et le respect mutuel.",
"icon": "🤝",
"color": "#2A9D8F",
"display_order": 4,
},
{
"name": "Projet",
"abbreviation": "Pj",
"description": "Reconnaître l'initiative et le lancement de projets.",
"icon": "🚀",
"color": "#F4A261",
"display_order": 5,
},
{
"name": "Participation",
"abbreviation": "Pc",
"description": "Reconnaître la participation active et le volontariat.",
"icon": "🙌",
"color": "#50B83C",
"display_order": 6,
},
{
"name": "Groupe",
"abbreviation": "Gp",
"description": "Reconnaître le travail en équipe et la communauté.",
"icon": "👥",
"color": "#9C6ADE",
"display_order": 7,
},
{
"name": "Expérience",
"abbreviation": "Xp",
"description": "Reconnaître l'expérience acquise et les défis relevés.",
"icon": "🏔️",
"color": "#264653",
"display_order": 8,
},
]

for category_data in categories_to_create:
# On recupere l'illustration SVG correspondante.
# Get the matching SVG illustration.
abbreviation = category_data["abbreviation"]
illustration_svg = ILLUSTRATIONS_BY_ABBREVIATION.get(abbreviation, "")

# On ajoute l'illustration et la couleur de texte par defaut.
# Add illustration and default text color.
category_data["illustration_svg"] = illustration_svg
category_data["text_color"] = "#473467"

# On utilise update_or_create pour ne pas creer de doublons.
# Use update_or_create to avoid duplicates.
BadgeCategory.objects.update_or_create(
name=category_data["name"],
defaults=category_data,
)


class Migration(migrations.Migration):

dependencies = [
('badge_generator', '0003_remove_generatedbadge_pictogram_and_more'),
]

operations = [
migrations.RunPython(populate_badge_level_and_category),
]
5 changes: 5 additions & 0 deletions badge_generator/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from badge_generator.models import BadgeCategory, BadgeLevel
from badge_generator.shapes import ALL_SHAPES, DEFAULT_SHAPE_KEY
from core.models import Structure


# ============================================================================
Expand Down Expand Up @@ -183,3 +184,7 @@ def validate_shape(self, value):
if not value or value not in ALL_SHAPES:
return DEFAULT_SHAPE_KEY
return value




41 changes: 41 additions & 0 deletions badge_generator/static/badge_generator/css/badge_generator.css
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,44 @@
max-height: 240px;
}
}

#structures{
max-height: 0;
overflow: hidden;
animation: hideTest 0.5s forwards;
}

#structures.showed{
animation: showTest 0.5s forwards;
max-height: 100px;
}


#form_icon_import{
max-height: 0;
overflow: hidden;
animation: hideTest 0.5s forwards;
}

#form_icon_import.showed{
animation: showTest 0.5s forwards;
max-height: 100px;
}

@keyframes showTest {
0%{
max-height: 0;
}
100%{
max-height: 100px;
}
}

@keyframes hideTest {
0%{
max-height: 100px;
}
100%{
max-height: 0;
}
}
Loading