Browse Source
feat(transmitters): add SahabiStatus model, relation, and admin endpoints
feat(transmitters): add SahabiStatus model, relation, and admin endpoints
- Add SahabiStatus model with multilingual title, description, and slug - Add ForeignKey sahabi_status to Transmitters model - Create migration 0061 to create SahabiStatus and populate from existing companion_type - Register DovodiSahabiStatusViewSet and admin routes in urls.py - Update RELATIONAL_MIGRATION_ROADMAP.md for sahabi_status migrationmaster
6 changed files with 248 additions and 27 deletions
-
47RELATIONAL_MIGRATION_ROADMAP.md
-
116apps/hadis/migrations/0061_sahabi_status_and_relation.py
-
49apps/hadis/models/transmitter.py
-
38apps/hadis/serializers/serializers_admin.py
-
5apps/hadis/urls.py
-
20apps/hadis/views_admin.py
@ -0,0 +1,116 @@ |
|||||
|
# Generated by Django 4.2.30 on 2026-10-20 14:49 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
SAHABI_STATUS_DATA = [ |
||||
|
{ |
||||
|
"slug": "companion", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "صحابي", "title": "صحابي"}, |
||||
|
{"language_code": "fa", "text": "صحابی", "title": "صحابی"}, |
||||
|
{"language_code": "en", "text": "Companion", "title": "Companion"}, |
||||
|
{"language_code": "ru", "text": "Сподвижник", "title": "Сподвижник"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "saw-the-prophet", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "رأى النبي", "title": "رأى النبي"}, |
||||
|
{"language_code": "fa", "text": "رؤیت پیامبر", "title": "رؤیت پیامبر"}, |
||||
|
{"language_code": "en", "text": "Saw the Prophet", "title": "Saw the Prophet"}, |
||||
|
{"language_code": "ru", "text": "Видел Пророка", "title": "Видел Пророка"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "contemporary", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "أدرك زمان النبي", "title": "أدرك زمان النبي"}, |
||||
|
{"language_code": "fa", "text": "درک زمان پیامبر", "title": "درک زمان پیامبر"}, |
||||
|
{"language_code": "en", "text": "Contemporary of the Prophet", "title": "Contemporary of the Prophet"}, |
||||
|
{"language_code": "ru", "text": "Застал время Пророка", "title": "Застал время Пророка"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "minor-companion", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "صحابي صغير", "title": "صحابي صغير"}, |
||||
|
{"language_code": "fa", "text": "صحابی صغیر", "title": "صحابی صغیر"}, |
||||
|
{"language_code": "en", "text": "Minor Companion", "title": "Minor Companion"}, |
||||
|
{"language_code": "ru", "text": "Малый сподвижник", "title": "Малый сподвижник"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "mukhadram", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "مخضرم", "title": "مخضرم"}, |
||||
|
{"language_code": "fa", "text": "مخضرم", "title": "مخضرم"}, |
||||
|
{"language_code": "en", "text": "Mukhadram", "title": "Mukhadram"}, |
||||
|
{"language_code": "ru", "text": "Мухадрам", "title": "Мухадрам"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "unproven", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "غير مثبت", "title": "غير مثبت"}, |
||||
|
{"language_code": "fa", "text": "اثباتنشده", "title": "اثباتنشده"}, |
||||
|
{"language_code": "en", "text": "Unproven", "title": "Unproven"}, |
||||
|
{"language_code": "ru", "text": "Не доказано", "title": "Не доказано"}, |
||||
|
], |
||||
|
}, |
||||
|
{ |
||||
|
"slug": "disputed", |
||||
|
"title": [ |
||||
|
{"language_code": "ar", "text": "مختلف فيه", "title": "مختلف فيه"}, |
||||
|
{"language_code": "fa", "text": "اختلافی / محل بحث", "title": "اختلافی / محل بحث"}, |
||||
|
{"language_code": "en", "text": "Disputed", "title": "Disputed"}, |
||||
|
{"language_code": "ru", "text": "Спорный", "title": "Спорный"}, |
||||
|
], |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
def seed_sahabi_statuses(apps, schema_editor): |
||||
|
SahabiStatus = apps.get_model('hadis', 'SahabiStatus') |
||||
|
for item in SAHABI_STATUS_DATA: |
||||
|
SahabiStatus.objects.get_or_create( |
||||
|
slug=item["slug"], |
||||
|
defaults={"title": item["title"]}, |
||||
|
) |
||||
|
|
||||
|
|
||||
|
def reverse_seed(apps, schema_editor): |
||||
|
pass |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('hadis', '0060_transmitter_feature_and_relations'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='SahabiStatus', |
||||
|
fields=[ |
||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('title', models.JSONField(default=list, verbose_name='Title')), |
||||
|
('slug', models.SlugField(allow_unicode=True, blank=True, max_length=255, unique=True, verbose_name='slug')), |
||||
|
('description', models.JSONField(blank=True, default=list, verbose_name='Description')), |
||||
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')), |
||||
|
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')), |
||||
|
], |
||||
|
options={ |
||||
|
'verbose_name': 'Sahabi Status', |
||||
|
'verbose_name_plural': 'Sahabi Statuses', |
||||
|
'ordering': ['id'], |
||||
|
}, |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='transmitters', |
||||
|
name='sahabi_status', |
||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transmitters', to='hadis.sahabistatus', verbose_name='Sahabi Status'), |
||||
|
), |
||||
|
migrations.RunPython(seed_sahabi_statuses, reverse_seed), |
||||
|
] |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue