Browse Source
course fileds updated for multilangual feat . serializers synced and dropdown values handle multilangual fileds statically
master
course fileds updated for multilangual feat . serializers synced and dropdown values handle multilangual fileds statically
master
4 changed files with 257 additions and 5 deletions
-
38apps/course/migrations/0009_alter_course_description_and_more.py
-
204apps/course/models/course.py
-
16apps/course/serializers/course.py
-
4apps/course/views/admin.py
@ -0,0 +1,38 @@ |
|||
# Generated by Django 5.2.12 on 2026-06-06 09:11 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('course', '0008_remove_course_course_cour_status_57ffd9_idx_and_more'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.SeparateDatabaseAndState( |
|||
database_operations=[ |
|||
migrations.RunSQL( |
|||
sql=[ |
|||
"ALTER TABLE course_course ALTER COLUMN description TYPE jsonb USING CASE WHEN description IS NULL OR description = '' THEN '[]'::jsonb ELSE jsonb_build_array(jsonb_build_object('title', description, 'language_code', 'en')) END;", |
|||
"ALTER TABLE course_course ALTER COLUMN short_description TYPE jsonb USING CASE WHEN short_description IS NULL OR short_description = '' THEN '[]'::jsonb ELSE jsonb_build_array(jsonb_build_object('title', short_description, 'language_code', 'en')) END;" |
|||
], |
|||
reverse_sql=[ |
|||
"ALTER TABLE course_course ALTER COLUMN description TYPE text USING CASE WHEN jsonb_array_length(description) > 0 THEN description->0->>'title' ELSE '' END;", |
|||
"ALTER TABLE course_course ALTER COLUMN short_description TYPE varchar(500) USING CASE WHEN jsonb_array_length(short_description) > 0 THEN LEFT(short_description->0->>'title', 500) ELSE '' END;" |
|||
] |
|||
) |
|||
], |
|||
state_operations=[ |
|||
migrations.AlterField( |
|||
model_name='course', |
|||
name='description', |
|||
field=models.JSONField(blank=True, default=list, null=True, verbose_name='Course Description'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='course', |
|||
name='short_description', |
|||
field=models.JSONField(blank=True, default=list, null=True, verbose_name='Short Description'), |
|||
), |
|||
] |
|||
) |
|||
] |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue