From 9151011c9ac1efb9ccf05731f09bf8abd6689905 Mon Sep 17 00:00:00 2001 From: mohsentaba Date: Sun, 14 Jun 2026 12:05:34 +0330 Subject: [PATCH] category icons updated --- .../commands/set_default_category_icons.py | 16 +++++++++++ ...course_cour_ended_a_32eaaa_idx_and_more.py | 28 +++++++++++++++++++ apps/course/models/course.py | 10 +++++-- entrypoint.sh | 1 + static/images/Frame.svg | 4 +++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 apps/course/management/commands/set_default_category_icons.py create mode 100644 apps/course/migrations/0015_rename_course_cour_ended_a_0f47b4_idx_course_cour_ended_a_32eaaa_idx_and_more.py create mode 100644 static/images/Frame.svg diff --git a/apps/course/management/commands/set_default_category_icons.py b/apps/course/management/commands/set_default_category_icons.py new file mode 100644 index 0000000..a0d52b8 --- /dev/null +++ b/apps/course/management/commands/set_default_category_icons.py @@ -0,0 +1,16 @@ +from django.core.management.base import BaseCommand +from apps.course.models import CourseCategory + +class Command(BaseCommand): + help = 'Sets the default icon (/static/images/Frame.svg) for all CourseCategory instances with blank or null icons.' + + def handle(self, *args, **options): + categories = CourseCategory.objects.filter(icon__isnull=True) | CourseCategory.objects.filter(icon='') + + count = 0 + for cat in categories: + cat.icon = "/static/images/Frame.svg" + cat.save() + count += 1 + + self.stdout.write(self.style.SUCCESS(f'Successfully updated {count} CourseCategory icons to "/static/images/Frame.svg".')) diff --git a/apps/course/migrations/0015_rename_course_cour_ended_a_0f47b4_idx_course_cour_ended_a_32eaaa_idx_and_more.py b/apps/course/migrations/0015_rename_course_cour_ended_a_0f47b4_idx_course_cour_ended_a_32eaaa_idx_and_more.py new file mode 100644 index 0000000..50121ad --- /dev/null +++ b/apps/course/migrations/0015_rename_course_cour_ended_a_0f47b4_idx_course_cour_ended_a_32eaaa_idx_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.2.12 on 2026-06-14 11:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('course', '0014_courselivesession_web_egress_fields'), + ] + + operations = [ + migrations.RenameIndex( + model_name='courselivesession', + new_name='course_cour_ended_a_32eaaa_idx', + old_name='course_cour_ended_a_0f47b4_idx', + ), + migrations.RenameIndex( + model_name='courselivesession', + new_name='course_cour_web_egr_c57929_idx', + old_name='course_cour_web_egr_5d55cb_idx', + ), + migrations.AlterField( + model_name='coursecategory', + name='icon', + field=models.CharField(blank=True, max_length=500, null=True, verbose_name='Icon URL'), + ), + ] diff --git a/apps/course/models/course.py b/apps/course/models/course.py index 2a5def9..e41493b 100644 --- a/apps/course/models/course.py +++ b/apps/course/models/course.py @@ -123,7 +123,7 @@ class CourseCategory(models.Model): name = models.JSONField(default=list, null=False, blank=False, verbose_name=_('Category Name')) slug = models.JSONField(default=list, null=True, blank=True, verbose_name=_('Slug')) - icon = models.URLField(null=True, blank=True, verbose_name=_('Icon URL')) + icon = models.CharField(max_length=500, null=True, blank=True, verbose_name=_('Icon URL')) def __str__(self): return extract_text_from_json(self.name) @@ -137,6 +137,10 @@ class CourseCategory(models.Model): self.slug = [] else: self.slug = format_multilingual_field(self.slug) + + if not self.icon or str(self.icon).strip() == "": + self.icon = "/static/images/Frame.svg" + super().save(*args, **kwargs) @property @@ -465,7 +469,9 @@ class Course(models.Model): for k, v in val.items(): raw_timings.append({"day": k, "time": str(v)}) - normalized_timings = [] + en_timings = [] + ru_timings = [] + fa_timings = [] for item in raw_timings: if isinstance(item, dict): day_key = normalize_weekday_to_key(item.get('day')) diff --git a/entrypoint.sh b/entrypoint.sh index 5dedfa4..61798fc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,6 +5,7 @@ python manage.py migrate # python manage.py seed_images # python manage.py compilemessages python manage.py collectstatic --noinput +python manage.py set_default_category_icons # python manage.py set_hadiscorrection_fixed_text # Seed Russian data (only runs once, skips if data exists) # python manage.py seed_corrections diff --git a/static/images/Frame.svg b/static/images/Frame.svg new file mode 100644 index 0000000..1aa2db1 --- /dev/null +++ b/static/images/Frame.svg @@ -0,0 +1,4 @@ + + + +