Browse Source

category icons updated

master
Mohsen Taba 1 month ago
parent
commit
9151011c9a
  1. 16
      apps/course/management/commands/set_default_category_icons.py
  2. 28
      apps/course/migrations/0015_rename_course_cour_ended_a_0f47b4_idx_course_cour_ended_a_32eaaa_idx_and_more.py
  3. 10
      apps/course/models/course.py
  4. 1
      entrypoint.sh
  5. 4
      static/images/Frame.svg

16
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".'))

28
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'),
),
]

10
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')) 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')) 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): def __str__(self):
return extract_text_from_json(self.name) return extract_text_from_json(self.name)
@ -137,6 +137,10 @@ class CourseCategory(models.Model):
self.slug = [] self.slug = []
else: else:
self.slug = format_multilingual_field(self.slug) 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) super().save(*args, **kwargs)
@property @property
@ -465,7 +469,9 @@ class Course(models.Model):
for k, v in val.items(): for k, v in val.items():
raw_timings.append({"day": k, "time": str(v)}) raw_timings.append({"day": k, "time": str(v)})
normalized_timings = []
en_timings = []
ru_timings = []
fa_timings = []
for item in raw_timings: for item in raw_timings:
if isinstance(item, dict): if isinstance(item, dict):
day_key = normalize_weekday_to_key(item.get('day')) day_key = normalize_weekday_to_key(item.get('day'))

1
entrypoint.sh

@ -5,6 +5,7 @@ python manage.py migrate
# python manage.py seed_images # python manage.py seed_images
# python manage.py compilemessages # python manage.py compilemessages
python manage.py collectstatic --noinput python manage.py collectstatic --noinput
python manage.py set_default_category_icons
# python manage.py set_hadiscorrection_fixed_text # python manage.py set_hadiscorrection_fixed_text
# Seed Russian data (only runs once, skips if data exists) # Seed Russian data (only runs once, skips if data exists)
# python manage.py seed_corrections # python manage.py seed_corrections

4
static/images/Frame.svg

@ -0,0 +1,4 @@
<svg width="36" height="38" viewBox="0 0 36 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.99" d="M15.261 33.8673C16.2118 35.7754 18.8217 37.4955 19.353 37.6083C19.3996 37.6177 19.4462 37.6177 19.4928 37.6177H28.4411C30.7993 37.6177 30.8645 34.685 30.8645 34.685C30.8645 34.685 30.9578 32.5513 30.9578 30.2202C30.9578 27.8891 32.6449 28.0583 33.6795 27.8985C35.4971 27.6166 35.1336 25.7084 34.9845 25.1445C34.9565 25.0505 34.9192 24.9565 34.854 24.8719L31.6289 20.6327C30.9205 19.7021 30.5383 18.5554 30.5383 17.3804V12.7183C30.5383 12.6901 30.5383 12.6619 30.5383 12.6337C30.4451 11.9099 29.224 2.70775 17.7497 1.6926C6.10769 0.658645 1.8293 10.6598 1.62423 11.1767C1.61491 11.1955 1.61491 11.2049 1.60559 11.2143C-0.976354 18.6118 2.07165 24.3173 4.23414 27.156C5.20354 28.4343 6.01448 30.7748 6.01448 32.3821L5.99583 36.8657C5.99583 37.2793 6.33139 37.6177 6.74152 37.6177H11.9241C13.7324 37.5707 14.3848 33.8485 15.261 33.8673Z" fill="#01353B"/>
<path opacity="0.99" d="M20.2884 20.4792C19.4278 19.9055 18.8313 19.1502 18.5087 18.1846C18.1273 17.0373 18.2153 15.9091 18.5967 14.7809C18.8216 14.1212 19.066 13.471 19.2518 12.8018C19.6625 11.2529 18.8705 9.95264 17.6481 9.36943C17.5308 9.31206 17.4037 9.27382 17.2766 9.23558C17.0321 9.14953 16.905 8.92007 16.9734 8.70973C17.0517 8.47071 17.2961 8.33686 17.5504 8.43246C19.0074 8.94875 19.9168 9.93352 20.1808 11.4346C20.3275 12.2855 20.1221 13.0982 19.8483 13.9013C19.6332 14.5227 19.3789 15.1442 19.2323 15.7848C18.9585 17.0086 19.1932 18.1559 20.0341 19.1311C20.6013 19.7812 21.3542 20.0776 22.205 20.2115C23.574 20.4314 26.1262 19.5709 27.1529 18.3471C27.8863 17.4771 28.3948 16.521 28.561 15.3928C28.9326 12.8496 27.4169 10.6123 25.3048 9.57021C25.0896 9.46504 24.8549 9.36943 24.6105 9.2547C24.6789 9.55109 24.7572 9.81879 24.8158 10.0865C25.0505 11.2529 25.0407 12.4098 24.5029 13.5093C24.366 13.7961 24.1704 14.0638 23.9749 14.3315C23.838 14.5227 23.5837 14.5419 23.3979 14.408C23.2219 14.2837 23.173 14.0447 23.2806 13.8535C23.3295 13.7674 23.3882 13.7005 23.4468 13.624C23.8869 13.0026 24.0727 12.3046 24.0824 11.5589C24.102 10.0769 23.6717 8.72885 22.7037 7.57199C21.7845 6.47249 20.5915 5.7363 19.242 5.24869C18.0099 4.80889 16.7387 4.6846 15.448 4.82802C14.4408 4.94275 13.5803 5.35386 13.0033 6.23346C12.4753 7.04614 12.6122 8.04047 13.3456 8.69061C13.4923 8.8149 13.6585 8.92007 13.8345 9.02524C14.079 9.16865 14.1768 9.40767 14.0594 9.61801C13.9421 9.83791 13.6683 9.90484 13.414 9.77099C12.8273 9.46504 12.3873 9.01568 12.0841 8.43246C12.0646 8.38466 12.0352 8.33686 12.0157 8.28905C11.8592 8.43246 11.7126 8.57588 11.5463 8.69061C10.6662 9.34075 9.71773 9.40767 8.71054 9.00612C8.48563 8.91051 8.39762 8.67149 8.47585 8.45159C8.5443 8.26037 8.77899 8.1552 8.99411 8.203C9.24836 8.26993 9.5026 8.3751 9.75684 8.38466C10.6662 8.43246 11.4779 7.83013 11.7614 6.92185C11.9472 6.31951 12.1721 5.74586 12.622 5.2965C12.8664 5.05748 13.1304 4.83758 13.3847 4.61768C11.3703 4.9045 9.51238 5.61201 7.88914 6.86448C6.5397 7.91618 5.52272 9.2069 5.04357 10.8418C4.79911 11.6736 4.81867 12.5341 5.14136 13.3659C5.55206 14.3984 6.4908 14.8287 7.62512 14.5419C8.53452 14.3124 9.30703 13.8344 10.06 13.2989C10.6467 12.8783 11.2334 12.4672 11.9277 12.2377C13.1793 11.817 14.4994 12.3907 14.9297 13.5475C15.1155 14.0447 15.1155 14.5419 14.9493 15.039C14.8808 15.2398 14.7048 15.3737 14.5288 15.3737C14.3625 15.3737 14.1768 15.2494 14.1181 15.0773C14.0887 14.9912 14.0887 14.8861 14.1181 14.8096C14.4114 13.863 13.8541 13.0408 12.8469 12.9548C12.4851 12.9261 12.1428 13.0312 11.8495 13.2129C11.3507 13.4997 10.8618 13.8248 10.3827 14.1499C9.61016 14.6757 8.8181 15.1538 7.89892 15.3737C7.04818 15.584 6.22678 15.5744 5.46405 15.0773C4.97512 14.7522 4.61332 14.3124 4.36885 13.7866C4.3493 13.7387 4.31996 13.6909 4.3004 13.6431C4.3004 13.6431 4.29063 13.6336 4.27107 13.624C4.00705 14.0447 3.82125 14.4941 3.72347 14.9721C3.40078 16.5688 3.81148 17.9838 4.97512 19.1502C5.70852 19.8864 6.61792 20.2975 7.67401 20.3549C9.60039 20.4696 11.1747 19.8003 12.3677 18.2993C12.4948 18.1368 12.6513 18.0507 12.8664 18.0889C13.0229 18.1176 13.1696 18.2802 13.1793 18.4618C13.1793 18.567 13.15 18.6913 13.0913 18.7678C12.2308 19.9055 11.1063 20.6608 9.70795 21.0241C9.66883 21.0337 9.62972 21.0433 9.59061 21.0528C9.20924 21.1389 9.20924 21.1389 9.20924 21.5404C9.20924 22.0185 9.20924 22.4965 9.20924 22.9746C9.20924 23.2231 9.25814 23.4526 9.51238 23.5673C9.76662 23.6821 9.97197 23.5865 10.1773 23.4239C11.0183 22.7738 11.8495 22.1045 12.71 21.4735C13.6389 20.8042 14.7048 20.4887 15.8587 20.4887C17.2766 20.4887 18.6847 20.4887 20.1026 20.4887C20.1515 20.4792 20.2199 20.4792 20.2884 20.4792Z" fill="#25D076"/>
</svg>
Loading…
Cancel
Save