Browse Source
feat: add global institutions seed command and migration for user first and last names
main
feat: add global institutions seed command and migration for user first and last names
main
22 changed files with 2629 additions and 263 deletions
-
31apps/account/admin/user.py
-
101apps/account/admin/verification.py
-
266apps/account/management/commands/seed_fake_profiles.py
-
41apps/account/migrations/0003_user_first_name_user_last_name.py
-
38apps/account/migrations/0004_user_address_user_institution_name_user_rank_and_more.py
-
37apps/account/models/user.py
-
232apps/account/serializers/auth_serializers.py
-
12apps/account/serializers/user.py
-
38apps/account/tests/test_phase1_auth.py
-
382apps/chat/management/commands/seed_hashemi_chat_meetings.py
-
2apps/chat/models/chat.py
-
1apps/profiles/management/__init__.py
-
1apps/profiles/management/commands/__init__.py
-
377apps/profiles/management/commands/seed_almadinah_rich_data.py
-
371apps/profiles/management/commands/seed_global_institutions.py
-
173apps/profiles/management/commands/update_institution_coords.py
-
141apps/profiles/serializers/institution_serializers.py
-
4apps/profiles/views/institution_views.py
-
BINdb.sqlite3.backup
-
BINdump.rdb
-
628schema.yml
-
16utils/pagination.py
@ -0,0 +1,266 @@ |
|||||
|
import os |
||||
|
from django.core.management.base import BaseCommand |
||||
|
from django.utils import timezone |
||||
|
from apps.account.models import User, VerificationDocument |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
help = 'Seeds realistic scholar and academic fake profiles similar to Ahmad Hashemi.' |
||||
|
|
||||
|
def handle(self, *args, **kwargs): |
||||
|
admin_user = User.objects.filter(is_superuser=True).first() or User.objects.filter(is_staff=True).first() |
||||
|
|
||||
|
# Update Ahmad Hashemi's avatar to downloaded real scholar photo |
||||
|
ahmad = User.objects.filter(email='ahmad@hashemi.com').first() |
||||
|
if ahmad: |
||||
|
ahmad.avatar = 'users/avatars/2026/10/avatar_ahmad_hashemi.jpg' |
||||
|
ahmad.save(update_fields=['avatar']) |
||||
|
self.stdout.write(self.style.SUCCESS("Updated Ahmad Hashemi avatar to real downloaded scholar photo.")) |
||||
|
|
||||
|
# Profiles definition |
||||
|
profiles_data = [ |
||||
|
{ |
||||
|
'email': 'hosseini@mustafa.ac.ir', |
||||
|
'username': 'hosseini@mustafa.ac.ir', |
||||
|
'first_name': 'سید محمد', |
||||
|
'last_name': 'حسینی', |
||||
|
'fullname': 'سید محمد حسینی', |
||||
|
'title': 'حجتالاسلام والمسلمین دکتر', |
||||
|
'rank': 'دانشیار فلسفه و کلام اسلامی', |
||||
|
'institution_name': 'جامعة المصطفی العالمیة', |
||||
|
'city': 'قم', |
||||
|
'country': 'ایران', |
||||
|
'phone_number': '+989127514320', |
||||
|
'website': 'https://sm-hosseini.ir', |
||||
|
'address': 'قم، بلوار امین، کوچه ۲۱، پلاک ۱۴', |
||||
|
'language': 'fa', |
||||
|
'languages': ['fa', 'ar', 'en'], |
||||
|
'skills': ['فلسفه اسلامی', 'کلام تطبیقی', 'حکمت متعالیه', 'روششناسی پژوهش', 'گفتگوی ادیان'], |
||||
|
'info': ( |
||||
|
'دکترای تخصصی فلسفه و حکمت اسلامی از جامعة المصطفی العالمیة و دارای مدرک سطح چهار حوزه علمیه قم. ' |
||||
|
'با بیش از ۱۲ سال سابقه تدریس در مقاطع کارشناسی ارشد و دکتری و راهنمایی دهها رساله علمی در حوزه کلام جدید و فلسفه تطبیقی. ' |
||||
|
'مؤلف کتابهای «درآمدی بر معرفتشناسی دینی در عصر مدرن» و «خوانش فلسفی گفتوگوی بینالمذاهب». ' |
||||
|
'تمرکز پژوهشی فعلی بر بازخوانی میراث عقلانی تمدن اسلامی در مواجهه با چالشهای معاصر و توسعه بسترهای دیالوگ میانفرهنگی است.' |
||||
|
), |
||||
|
'avatar': 'users/avatars/2026/10/avatar_seyed_hosseini.jpg', |
||||
|
'documents': [ |
||||
|
{ |
||||
|
'title': 'دانشنامه: سطح ۴ حوزوی (گرایش فلسفه و کلام اسلامی)', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'مدارک با استعلام از مدیریت حوزههای علمیه تایید شد.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'دانشنامه: دکتری تخصصی فلسفه و حکمت اسلامی (جامعة المصطفی)', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'دانشنامه رسمی معتبر است.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'حکم رسمی عضویت در هیئت علمی جامعة المصطفی العالمیة', |
||||
|
'document_type': 'recommendation_letter', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'حکم کارگزینی بررسی و تایید شد.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'گواهی گذرنامه و احراز هویت بینالمللی', |
||||
|
'document_type': 'national_id', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': '', |
||||
|
} |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
'email': 'mirzaei@ut.ac.ir', |
||||
|
'username': 'mirzaei@ut.ac.ir', |
||||
|
'first_name': 'فاطمهزهرا', |
||||
|
'last_name': 'میرزایی', |
||||
|
'fullname': 'فاطمهزهرا میرزایی', |
||||
|
'title': 'دکتر', |
||||
|
'rank': 'استاد تمام مطالعات خانواده و حقوق اسلامی', |
||||
|
'institution_name': 'دانشگاه تهران', |
||||
|
'city': 'تهران', |
||||
|
'country': 'ایران', |
||||
|
'phone_number': '+989123849102', |
||||
|
'website': 'https://fz-mirzaei.ut.ac.ir', |
||||
|
'address': 'تهران، خیابان کارگر شمالی، پردیس دانشکده الهیات دانشگاه تهران', |
||||
|
'language': 'fa', |
||||
|
'languages': ['fa', 'en', 'ar', 'fr'], |
||||
|
'skills': ['فقه و حقوق خانواده', 'مطالعات زنان در اسلام', 'حقوق تطبیقی', 'جامعهشناسی ادیان', 'روش تحقیق کیفی'], |
||||
|
'info': ( |
||||
|
'استاد تمام دانشکده الهیات و معارف اسلامی دانشگاه تهران و دارنده مدرک دکتری فقه و مبانی حقوق اسلامی ' |
||||
|
'با بیش از ۱۶ سال سابقه تدریس و پژوهش دانشگاهی. عضو شورای علمی پژوهشکده مطالعات اسلامی زنان و مؤلف آثار مرجع در زمینه ' |
||||
|
'حقوق تطبیقی زن در فقه فریقین. داور مجلات بینالمللی مطالعات خاورمیانه و سرپرست علمی کارگروه توانمندسازی حقوقی زنان در کشورهای اسلامی.' |
||||
|
), |
||||
|
'avatar': 'users/avatars/2026/10/avatar_fatemeh_mirzaei.jpg', |
||||
|
'documents': [ |
||||
|
{ |
||||
|
'title': 'دانشنامه: دکتری فقه و مبانی حقوق اسلامی (دانشگاه تهران)', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'تایید شده توسط دبیرخانه آموزش دانشگاه تهران.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'حکم ارتقا به مرتبه استاد تمامی (دانشگاه تهران)', |
||||
|
'document_type': 'recommendation_letter', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'مصوبه هیئت ممیزه تایید شد.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'کارت شناسایی هیئت علمی و کارت ملی هوشمند', |
||||
|
'document_type': 'national_id', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': '', |
||||
|
} |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
'email': 'm.kamali@um.ac.ir', |
||||
|
'username': 'm.kamali@um.ac.ir', |
||||
|
'first_name': 'مصطفی', |
||||
|
'last_name': 'کمالی', |
||||
|
'fullname': 'مصطفی کمالی', |
||||
|
'title': 'استاد', |
||||
|
'rank': 'پژوهشگر ارشد تمدن اسلامی و نسخ خطی', |
||||
|
'institution_name': 'دانشگاه فردوسی مشهد', |
||||
|
'city': 'مشهد', |
||||
|
'country': 'ایران', |
||||
|
'phone_number': '+989151248901', |
||||
|
'website': 'https://mkamali.ir', |
||||
|
'address': 'مشهد، میدان آزادی، پردیس دانشگاه فردوسی، دانشکده ادبیات و علوم انسانی', |
||||
|
'language': 'fa', |
||||
|
'languages': ['fa', 'ar', 'en'], |
||||
|
'skills': ['نسخهشناسی', 'تصحیح متون کهن', 'تاریخ تمدن اسلامی', 'دیجیتالسازی اسناد', 'عربی کلاسیک'], |
||||
|
'info': ( |
||||
|
'پژوهشگر ارشد تاریخ تمدن و ملل اسلامی و متخصص احیا و تصحیح انتقادی نسخ خطی سدههای میانه اسلامی. ' |
||||
|
'دارای همکاریهای گسترده علمی با کتابخانه مرکزی آستان قدس رضوی، کتابخانه ملی ایران و مؤسسات شرقشناسی دانشگاههای لیدن و هایدلبرگ. ' |
||||
|
'سرپرست پروژه فهرستنویسی توصیفی دستنوشتههای کهن ریاضیات و نجوم دوره اسلامی.' |
||||
|
), |
||||
|
'avatar': 'users/avatars/2026/10/avatar_mostafa_kamali.jpg', |
||||
|
'documents': [ |
||||
|
{ |
||||
|
'title': 'دانشنامه: دکتری تاریخ و تمدن ملل اسلامی (دانشگاه فردوسی)', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'مدرک تحصیلی تایید شده است.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'معرفینامه پژوهشی: بنیاد پژوهشهای اسلامی آستان قدس رضوی', |
||||
|
'document_type': 'recommendation_letter', |
||||
|
'status': 'pending', |
||||
|
'admin_notes': 'در حال استعلام نهایی از مرکز اسناد.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'کارت شناسایی هیئت علمی و پژوهشگر ارشد', |
||||
|
'document_type': 'national_id', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': '', |
||||
|
} |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
'email': 'altamimi@taghrib.org', |
||||
|
'username': 'altamimi@taghrib.org', |
||||
|
'first_name': 'حیدر', |
||||
|
'last_name': 'التمیمی', |
||||
|
'fullname': 'حیدر التمیمی', |
||||
|
'title': 'آیتالله دکتر', |
||||
|
'rank': 'رئیس مرکز پژوهشهای تقریب و مذاهب اسلامی', |
||||
|
'institution_name': 'مجمع جهانی تقریب مذاهب اسلامی', |
||||
|
'city': 'نجف', |
||||
|
'country': 'عراق', |
||||
|
'phone_number': '+9647801234567', |
||||
|
'website': 'https://altamimi-center.org', |
||||
|
'address': 'نجف اشرف، شارع الرسول، مرکز الدراسات الاسلامیة الموحدة', |
||||
|
'language': 'ar', |
||||
|
'languages': ['ar', 'fa', 'en'], |
||||
|
'skills': ['فقه مقارن', 'تقریب مذاهب', 'علوم حدیث و رجال', 'اصول استنباط', 'گفتگوی وحدت اسلامی'], |
||||
|
'info': ( |
||||
|
'استاد درس خارج فقه و اصول حوزه علمیه نجف اشرف و دارنده دکترای فقه مقارن با بیش از بیست سال فعالیت در ترویج گفتوگو ' |
||||
|
'و همگرایی میان علمای جهان اسلام. عضو هیئت امنای مجمع جهانی تقریب مذاهب اسلامی و نویسنده موسوعه فقهی تطبیقی مذاهب خمسه. ' |
||||
|
'سخنران اصلی در نشستهای بینالمللی الازهر، مکه مکرمه، تهران و استانبول.' |
||||
|
), |
||||
|
'avatar': 'users/avatars/2026/10/avatar_haidar_tamimi.jpg', |
||||
|
'documents': [ |
||||
|
{ |
||||
|
'title': 'اجازهنامه اجتهاد و تدریس خارج فقه (حوزه علمیه نجف اشرف)', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'گواهی سطح عالی حوزوی تایید گردید.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'دانشنامه: دکتری تخصصی فقه مقارن و حقوق اسلامی', |
||||
|
'document_type': 'student_card', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'دانشنامه تطبیقی مورد تایید است.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'حکم ریاست شورای پژوهشی تقریب مذاهب اسلامی', |
||||
|
'document_type': 'institution_license', |
||||
|
'status': 'verified', |
||||
|
'admin_notes': 'حکم رسمی معتبر است.', |
||||
|
}, |
||||
|
{ |
||||
|
'title': 'گواهی گذرنامه و احراز هویت بینالمللی', |
||||
|
'document_type': 'national_id', |
||||
|
'status': 'pending', |
||||
|
'admin_notes': 'در انتظار تایید مدارک هویتی تکمیلی.', |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
sample_doc_file = 'users/documents/2026/10/institution_license.pdf' |
||||
|
|
||||
|
for p_data in profiles_data: |
||||
|
email = p_data['email'] |
||||
|
user, created = User.objects.get_or_create(email=email, defaults={'username': p_data['username']}) |
||||
|
|
||||
|
user.first_name = p_data['first_name'] |
||||
|
user.last_name = p_data['last_name'] |
||||
|
user.fullname = p_data['fullname'] |
||||
|
user.title = p_data['title'] |
||||
|
user.rank = p_data['rank'] |
||||
|
user.institution_name = p_data['institution_name'] |
||||
|
user.city = p_data['city'] |
||||
|
user.country = p_data['country'] |
||||
|
user.phone_number = p_data['phone_number'] |
||||
|
user.website = p_data['website'] |
||||
|
user.address = p_data['address'] |
||||
|
user.language = p_data['language'] |
||||
|
user.languages = p_data['languages'] |
||||
|
user.skills = p_data['skills'] |
||||
|
user.info = p_data['info'] |
||||
|
user.user_type = User.UserType.CLIENT |
||||
|
user.is_active = True |
||||
|
user.avatar = p_data['avatar'] |
||||
|
|
||||
|
# Standardized password (12345678) |
||||
|
user.set_password('12345678') |
||||
|
if hasattr(user, 'set_plain_password'): |
||||
|
try: |
||||
|
user.set_plain_password('12345678') |
||||
|
except Exception: |
||||
|
pass |
||||
|
|
||||
|
user.save() |
||||
|
|
||||
|
# Verification documents |
||||
|
for doc_item in p_data['documents']: |
||||
|
VerificationDocument.objects.get_or_create( |
||||
|
user=user, |
||||
|
title=doc_item['title'], |
||||
|
defaults={ |
||||
|
'document_type': doc_item['document_type'], |
||||
|
'document_file': sample_doc_file, |
||||
|
'status': doc_item['status'], |
||||
|
'admin_notes': doc_item['admin_notes'], |
||||
|
'reviewed_by': admin_user if doc_item['status'] == 'verified' else None, |
||||
|
'reviewed_at': timezone.now() if doc_item['status'] == 'verified' else None, |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
action_text = "Created" if created else "Updated" |
||||
|
self.stdout.write(self.style.SUCCESS(f"{action_text} profile: {user.fullname} ({user.email})")) |
||||
|
|
||||
|
self.stdout.write(self.style.SUCCESS("All fake profiles seeded successfully!")) |
||||
@ -0,0 +1,41 @@ |
|||||
|
# Generated by Django 4.2.30 on 2026-10-03 09:07 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
def populate_first_and_last_names(apps, schema_editor): |
||||
|
User = apps.get_model('account', 'User') |
||||
|
for user in User.objects.all(): |
||||
|
if user.fullname and not user.first_name and not user.last_name: |
||||
|
parts = user.fullname.strip().split(maxsplit=1) |
||||
|
if len(parts) == 2: |
||||
|
user.first_name = parts[0] |
||||
|
user.last_name = parts[1] |
||||
|
elif len(parts) == 1: |
||||
|
user.first_name = parts[0] |
||||
|
user.last_name = "" |
||||
|
user.save(update_fields=['first_name', 'last_name']) |
||||
|
|
||||
|
def reverse_populate(apps, schema_editor): |
||||
|
pass |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('account', '0002_user_languages_user_skills_alter_user_language_and_more'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='first_name', |
||||
|
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='First Name'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='last_name', |
||||
|
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Last Name'), |
||||
|
), |
||||
|
migrations.RunPython(populate_first_and_last_names, reverse_populate), |
||||
|
] |
||||
@ -0,0 +1,38 @@ |
|||||
|
# Generated by Django 4.2.30 on 2026-10-03 09:33 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('account', '0003_user_first_name_user_last_name'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='address', |
||||
|
field=models.TextField(blank=True, null=True, verbose_name='Postal Address'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='institution_name', |
||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Affiliated Institution'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='rank', |
||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Academic / Clerical Rank'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='title', |
||||
|
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Title / Honorific'), |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='user', |
||||
|
name='website', |
||||
|
field=models.CharField(blank=True, max_length=512, null=True, verbose_name='Personal Website'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,382 @@ |
|||||
|
import datetime |
||||
|
from django.core.management.base import BaseCommand |
||||
|
from django.db import transaction |
||||
|
from django.utils import timezone |
||||
|
from apps.account.models import User |
||||
|
from apps.profiles.models import Institution, InstitutionMember |
||||
|
from apps.chat.models.chat import ChatRoom, ChatMessage |
||||
|
from apps.meetings.models import MeetingRequest, MeetingStatus |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
help = "Seed messaging chats and bilateral meetings for حجتالاسلام دکتر احمد هاشمی (ahmad@hashemi.com)." |
||||
|
|
||||
|
def handle(self, *args, **options): |
||||
|
with transaction.atomic(): |
||||
|
user = User.objects.filter(email='ahmad@hashemi.com').first() |
||||
|
if not user: |
||||
|
user = User.objects.filter(fullname__icontains='هاشمی').first() |
||||
|
if not user: |
||||
|
self.stdout.write(self.style.ERROR("User دکتر احمد هاشمی not found!")) |
||||
|
return |
||||
|
|
||||
|
self.stdout.write(self.style.SUCCESS(f"Found User: {user.fullname} ({user.email}, ID: {user.id})")) |
||||
|
|
||||
|
# 1. Ensure University of Religions and Denominations institution exists |
||||
|
inst_urd, created = Institution.objects.get_or_create( |
||||
|
name="دانشگاه ادیان و مذاهب", |
||||
|
defaults={ |
||||
|
"slug": "university-of-religions-and-denominations", |
||||
|
"type": Institution.InstitutionType.INSTITUTE, |
||||
|
"country": "ایران", |
||||
|
"city": "قم", |
||||
|
"address": "قم، پردیسان، بلوار دانشگاه، دانشگاه ادیان و مذاهب", |
||||
|
"latitude": 34.5772, |
||||
|
"longitude": 50.8144, |
||||
|
"established_year": 1995, |
||||
|
"email": "info@urd.ac.ir", |
||||
|
"website": "https://urd.ac.ir", |
||||
|
"phone": "+98 (25) 3280-2610", |
||||
|
"verification_status": Institution.VerificationStatus.APPROVED, |
||||
|
"is_featured": True, |
||||
|
"is_active": True, |
||||
|
"description": "دانشگاه ادیان و مذاهب نخستین دانشگاه تخصصی ادیان و مذاهب در ایران است که با هدف آموزش، پژوهش و گفتوگوی بینالادیانی و بینالمذاهبی فعالیت میکند.", |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
# Ensure user is Admin member in this institution |
||||
|
member, _ = InstitutionMember.objects.get_or_create( |
||||
|
institution=inst_urd, |
||||
|
user=user, |
||||
|
defaults={ |
||||
|
"role": InstitutionMember.MemberRole.ADMIN, |
||||
|
"title": "عضو هیئت علمی و معاون پژوهشی", |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
# Also associate with Al-Madinah Calgary or other partner institutions if appropriate |
||||
|
inst_almadinah = Institution.objects.filter(id=1171).first() |
||||
|
if not inst_almadinah: |
||||
|
inst_almadinah = Institution.objects.filter(name__icontains="Al-Madinah").first() |
||||
|
|
||||
|
inst_mustafa = Institution.objects.filter(name__icontains="المصطفی").first() |
||||
|
if not inst_mustafa: |
||||
|
inst_mustafa, _ = Institution.objects.get_or_create( |
||||
|
name="جامعة المصطفی العالمیة", |
||||
|
defaults={ |
||||
|
"slug": "al-mustafa-international-university", |
||||
|
"type": Institution.InstitutionType.INSTITUTE, |
||||
|
"country": "ایران", |
||||
|
"city": "قم", |
||||
|
"address": "قم، بلوار معلم، جامعة المصطفی العالمیة", |
||||
|
"latitude": 34.6399, |
||||
|
"longitude": 50.8759, |
||||
|
"established_year": 1979, |
||||
|
"verification_status": Institution.VerificationStatus.APPROVED, |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
inst_taghrib = Institution.objects.filter(name__icontains="تقریب").first() |
||||
|
if not inst_taghrib: |
||||
|
inst_taghrib, _ = Institution.objects.get_or_create( |
||||
|
name="مجمع جهانی تقریب مذاهب اسلامی", |
||||
|
defaults={ |
||||
|
"slug": "world-forum-for-proximity-of-islamic-schools", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "ایران", |
||||
|
"city": "تهران", |
||||
|
"address": "تهران، خیابان طالقانی، نبش خیابان شهید موسوی", |
||||
|
"latitude": 35.7036, |
||||
|
"longitude": 51.4172, |
||||
|
"established_year": 1990, |
||||
|
"verification_status": Institution.VerificationStatus.APPROVED, |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
inst_stockholm = Institution.objects.filter(name__icontains="Stockholm").first() |
||||
|
|
||||
|
# Find colleague users for direct chats |
||||
|
u_hosseini = User.objects.filter(fullname__icontains="حسینی").first() |
||||
|
u_tamimi = User.objects.filter(fullname__icontains="التمیمی").first() |
||||
|
u_mirzaei = User.objects.filter(fullname__icontains="میرزایی").first() |
||||
|
u_kamali = User.objects.filter(fullname__icontains="کمالی").first() |
||||
|
u_admin = User.objects.filter(is_superuser=True).first() |
||||
|
|
||||
|
# ------------------------------------------------------------------------- |
||||
|
# 2. SEED MESSAGING (CHAT ROOMS & MESSAGES) |
||||
|
# ------------------------------------------------------------------------- |
||||
|
now = timezone.now() |
||||
|
|
||||
|
# Clean old rooms where user is participant to avoid duplicates |
||||
|
old_rooms = ChatRoom.objects.filter(participant_users=user) |
||||
|
ChatMessage.objects.filter(room__in=old_rooms).delete() |
||||
|
old_rooms.delete() |
||||
|
|
||||
|
# Chat 1: Direct Message with Dr. Seyed Mohammad Hosseini (جامعة المصطفی) |
||||
|
if u_hosseini: |
||||
|
room1 = ChatRoom.objects.create( |
||||
|
room_type=ChatRoom.RoomType.DIRECT, |
||||
|
title=f"گفتوگو با {u_hosseini.fullname}", |
||||
|
created_by=user, |
||||
|
) |
||||
|
room1.participant_users.add(user, u_hosseini) |
||||
|
if inst_urd: |
||||
|
room1.participant_institutions.add(inst_urd) |
||||
|
if inst_mustafa: |
||||
|
room1.participant_institutions.add(inst_mustafa) |
||||
|
|
||||
|
m1 = ChatMessage.objects.create( |
||||
|
room=room1, |
||||
|
sender=u_hosseini, |
||||
|
sender_institution=inst_mustafa, |
||||
|
content="سلام علیکم و رحمتالله جناب دکتر هاشمی عزیز. مقالهای که پیرامون روششناسی مقارن در علوم قرآن برای همایش بینالمللی ارسال فرموده بودید در شورای علمی با امتیاز بالا تأیید شد.", |
||||
|
created_at=now - datetime.timedelta(days=2, hours=4), |
||||
|
) |
||||
|
m1.read_by.add(user, u_hosseini) |
||||
|
|
||||
|
m2 = ChatMessage.objects.create( |
||||
|
room=room1, |
||||
|
sender=user, |
||||
|
sender_institution=inst_urd, |
||||
|
content="سلام و درود جناب دکتر حسینی بزرگوار. سپاسگزارم از لطف و پیگیریهای شما. فایل نهایی اصلاحات به همراه چکیده مبسوط انگلیسی تا فردا بارگذاری خواهد شد.", |
||||
|
created_at=now - datetime.timedelta(days=1, hours=20), |
||||
|
) |
||||
|
m2.read_by.add(user, u_hosseini) |
||||
|
|
||||
|
m3 = ChatMessage.objects.create( |
||||
|
room=room1, |
||||
|
sender=u_hosseini, |
||||
|
sender_institution=inst_mustafa, |
||||
|
content="بسیار عالی. همچنین در صورت تمایل، پنل تخصصی «گفتوگوهای تفسیری در غرب اسلام» در نشست ماه آینده به مدیریت جنابعالی پیشنهاد شده است.", |
||||
|
created_at=now - datetime.timedelta(hours=5), |
||||
|
) |
||||
|
m3.read_by.add(user) |
||||
|
|
||||
|
# Chat 2: Direct Message with Dr. Haydar Al-Tamimi (مجمع تقریب) |
||||
|
if u_tamimi: |
||||
|
room2 = ChatRoom.objects.create( |
||||
|
room_type=ChatRoom.RoomType.DIRECT, |
||||
|
title=f"هماهنگی سمپوزیوم با {u_tamimi.fullname}", |
||||
|
created_by=u_tamimi, |
||||
|
) |
||||
|
room2.participant_users.add(user, u_tamimi) |
||||
|
if inst_urd: |
||||
|
room2.participant_institutions.add(inst_urd) |
||||
|
if inst_taghrib: |
||||
|
room2.participant_institutions.add(inst_taghrib) |
||||
|
|
||||
|
m2_1 = ChatMessage.objects.create( |
||||
|
room=room2, |
||||
|
sender=u_tamimi, |
||||
|
sender_institution=inst_taghrib, |
||||
|
content="أهلاً وسهلاً فضيلة الدكتور الهاشمي. نود دعوتكم لتقديم الورقة الافتتاحية في المؤتمر الدولي للوحدة الإسلامية حول المشترکات التفسيرية بين المذاهب.", |
||||
|
created_at=now - datetime.timedelta(days=3, hours=10), |
||||
|
) |
||||
|
m2_1.read_by.add(user, u_tamimi) |
||||
|
|
||||
|
m2_2 = ChatMessage.objects.create( |
||||
|
room=room2, |
||||
|
sender=user, |
||||
|
sender_institution=inst_urd, |
||||
|
content="أهلاً بكم أخي العزيز د. التميمي. يسعدني ويشرفني المشاركة، وسأرسل لكم المحاور الرئيسية والمقترحات التنفيذية للندوة الحوارية المشتركة.", |
||||
|
created_at=now - datetime.timedelta(days=1, hours=8), |
||||
|
) |
||||
|
m2_2.read_by.add(user, u_tamimi) |
||||
|
|
||||
|
m2_3 = ChatMessage.objects.create( |
||||
|
room=room2, |
||||
|
sender=u_tamimi, |
||||
|
sender_institution=inst_taghrib, |
||||
|
content="ممتاز جداً، ونحن بانتظار مسودة المحاور لاعتمادها في اللجنة الاستشارية غداً بإذن الله.", |
||||
|
created_at=now - datetime.timedelta(hours=2), |
||||
|
) |
||||
|
# Unread by user to show realistic notification |
||||
|
m2_3.read_by.add(u_tamimi) |
||||
|
|
||||
|
# Chat 3: Multi-Institution Group Room: کارگروه بینالمللی گفتوگوی ادیان و تمدنها |
||||
|
room3 = ChatRoom.objects.create( |
||||
|
room_type=ChatRoom.RoomType.GROUP, |
||||
|
title="کارگروه بینالمللی مطالعات تطبیقی ادیان و تقریب", |
||||
|
created_by=user, |
||||
|
) |
||||
|
room3.participant_users.add(user) |
||||
|
if u_hosseini: |
||||
|
room3.participant_users.add(u_hosseini) |
||||
|
if u_tamimi: |
||||
|
room3.participant_users.add(u_tamimi) |
||||
|
if u_mirzaei: |
||||
|
room3.participant_users.add(u_mirzaei) |
||||
|
if u_kamali: |
||||
|
room3.participant_users.add(u_kamali) |
||||
|
|
||||
|
if inst_urd: |
||||
|
room3.participant_institutions.add(inst_urd) |
||||
|
if inst_mustafa: |
||||
|
room3.participant_institutions.add(inst_mustafa) |
||||
|
if inst_taghrib: |
||||
|
room3.participant_institutions.add(inst_taghrib) |
||||
|
|
||||
|
m3_1 = ChatMessage.objects.create( |
||||
|
room=room3, |
||||
|
sender=user, |
||||
|
sender_institution=inst_urd, |
||||
|
content="با سلام خدمت اساتید و پژوهشگران ارجمند. پیشنویس جدول زمانبندی سلسله نشستهای آنلاین پاییز ۱۴۰۵ در حوزه گفتوگوهای الهیاتی آماده بررسی است.", |
||||
|
created_at=now - datetime.timedelta(days=4), |
||||
|
) |
||||
|
m3_1.read_by.add(user) |
||||
|
|
||||
|
if u_mirzaei: |
||||
|
m3_2 = ChatMessage.objects.create( |
||||
|
room=room3, |
||||
|
sender=u_mirzaei, |
||||
|
content="سلام و احترام. محورهای پیشنهادی بسیار جامع و دقیق هستند. دانشکده الهیات دانشگاه تهران آمادگی مشارکت کامل در برگزاری کارگاههای مشترک را دارد.", |
||||
|
created_at=now - datetime.timedelta(days=2, hours=12), |
||||
|
) |
||||
|
m3_2.read_by.add(user, u_mirzaei) |
||||
|
|
||||
|
if u_kamali: |
||||
|
m3_3 = ChatMessage.objects.create( |
||||
|
room=room3, |
||||
|
sender=u_kamali, |
||||
|
content="سلام دکتر هاشمی گرامی. بخش پژوهشهای نسخ خطی مشهد نیز دیجیتالسازی منابع مرتبط را آغاز کرده و لینک دسترسی را در جلسه هماهنگی ارائه خواهیم داد.", |
||||
|
created_at=now - datetime.timedelta(hours=14), |
||||
|
) |
||||
|
m3_3.read_by.add(user, u_kamali) |
||||
|
|
||||
|
# Chat 4: Institutional Consultation with Al-Madinah Islamic Centre Calgary |
||||
|
if inst_almadinah: |
||||
|
room4 = ChatRoom.objects.create( |
||||
|
room_type=ChatRoom.RoomType.GROUP, |
||||
|
title="همکاری آموزشی با مرکز اسلامی المدینه کلگری", |
||||
|
created_by=user, |
||||
|
) |
||||
|
room4.participant_users.add(user) |
||||
|
if u_admin: |
||||
|
room4.participant_users.add(u_admin) |
||||
|
room4.participant_institutions.add(inst_urd, inst_almadinah) |
||||
|
|
||||
|
m4_1 = ChatMessage.objects.create( |
||||
|
room=room4, |
||||
|
sender=user, |
||||
|
sender_institution=inst_urd, |
||||
|
content="Dear Al-Madinah Centre Academic Team, we reviewed your Fall 2026 Quranic & Arabic curriculum. We are pleased to provide academic accreditation and visiting scholar webinars from University of Religions.", |
||||
|
created_at=now - datetime.timedelta(days=1, hours=15), |
||||
|
) |
||||
|
m4_1.read_by.add(user) |
||||
|
|
||||
|
if u_admin: |
||||
|
m4_2 = ChatMessage.objects.create( |
||||
|
room=room4, |
||||
|
sender=u_admin, |
||||
|
sender_institution=inst_almadinah, |
||||
|
content="Thank you, Dr. Hashemi! Our board is thrilled to establish this direct academic bridge with Qom and look forward to the upcoming bilateral coordination meeting.", |
||||
|
created_at=now - datetime.timedelta(hours=6), |
||||
|
) |
||||
|
m4_2.read_by.add(user, u_admin) |
||||
|
|
||||
|
self.stdout.write(self.style.SUCCESS("Populated 4 rich Chat Rooms with authentic scholarly discussions.")) |
||||
|
|
||||
|
# ------------------------------------------------------------------------- |
||||
|
# 3. SEED BILATERAL VIDEO MEETINGS (MEETINGS APP) |
||||
|
# ------------------------------------------------------------------------- |
||||
|
# Delete old meetings created by user or involving user's institution |
||||
|
MeetingRequest.objects.filter(created_by=user).delete() |
||||
|
|
||||
|
today = timezone.localdate() |
||||
|
|
||||
|
# Meeting 1: Upcoming Scheduled Meeting with Al-Madinah Islamic Centre Calgary |
||||
|
if inst_almadinah: |
||||
|
MeetingRequest.objects.create( |
||||
|
title="Bilateral Academic Partnership: Youth Quranic Education & Faculty Exchange", |
||||
|
requester_institution=inst_urd, |
||||
|
recipient_institution=inst_almadinah, |
||||
|
created_by=user, |
||||
|
status=MeetingStatus.SCHEDULED, |
||||
|
meeting_date=today + datetime.timedelta(days=2), |
||||
|
meeting_time=datetime.time(17, 30), |
||||
|
duration_minutes=75, |
||||
|
meeting_url="https://meet.jit.si/mch-hashemi-almadinah-calgary", |
||||
|
agenda="""1. Review of Al-Madinah Academy curriculum accreditation standards. |
||||
|
2. Schedule of monthly live webinars by Dr. Hashemi on contemporary ethics and youth guidance. |
||||
|
3. Collaborative digital archive exchange between Calgary and University of Religions. |
||||
|
4. Q&A and official MOU signing steps.""", |
||||
|
admin_notes="Both delegations confirmed attendance. Simultaneous translation English/Persian will be available.", |
||||
|
) |
||||
|
|
||||
|
# Meeting 2: Scheduled Meeting with جامعة المصطفی العالمیة |
||||
|
if inst_mustafa: |
||||
|
MeetingRequest.objects.create( |
||||
|
title="نشست هماهنگی همایش بینالمللی مطالعات مقارن ادیان و متون مقدس", |
||||
|
requester_institution=inst_mustafa, |
||||
|
recipient_institution=inst_urd, |
||||
|
created_by=user, |
||||
|
status=MeetingStatus.SCHEDULED, |
||||
|
meeting_date=today + datetime.timedelta(days=5), |
||||
|
meeting_time=datetime.time(10, 0), |
||||
|
duration_minutes=60, |
||||
|
meeting_url="https://meet.jit.si/mch-urd-mustafa-symposium", |
||||
|
agenda="""۱. تعیین اساتید و داوران مقالات ارسالی به کمیته علمی. |
||||
|
۲. نهاییسازی پنل تخصصی دکتر احمد هاشمی در حوزه هرمنوتیک و تفسیر تطبیقی. |
||||
|
۳. هماهنگی حضور میهمانان خارجی از دانشگاههای ترکیه، لبنان و اندونزی.""", |
||||
|
admin_notes="هماهنگی با دکتر حسینی نهایی شده است.", |
||||
|
) |
||||
|
|
||||
|
# Meeting 3: Pending Meeting with مجمع جهانی تقریب مذاهب اسلامی |
||||
|
if inst_taghrib: |
||||
|
MeetingRequest.objects.create( |
||||
|
title="بررسی طرح مشترک دانشنامه آنلاین اصطلاحات تفسیری تقریب", |
||||
|
requester_institution=inst_urd, |
||||
|
recipient_institution=inst_taghrib, |
||||
|
created_by=user, |
||||
|
status=MeetingStatus.PENDING, |
||||
|
meeting_date=today + datetime.timedelta(days=8), |
||||
|
meeting_time=datetime.time(14, 0), |
||||
|
duration_minutes=90, |
||||
|
meeting_url="https://meet.jit.si/mch-taghrib-hashemi-encyclopedia", |
||||
|
agenda="""۱. معرفی زیرساخت فنی و دانشنامهای هاب پژوهشگران. |
||||
|
۲. تخصیص کارگروههای تخصصی تألیف مدخلها. |
||||
|
۳. برآورد بودجه و جدول زمانبندی انتشار فاز اول.""", |
||||
|
admin_notes="در انتظار تأیید نهایی تاریخ توسط دبیرخانه مجمع تقریب.", |
||||
|
) |
||||
|
|
||||
|
# Meeting 4: Pending Meeting with Stockholm Islamic Center (if exists) or Montreal |
||||
|
inst_foreign = inst_stockholm or Institution.objects.filter(country__in=['Sweden', 'Canada', 'France']).first() |
||||
|
if inst_foreign: |
||||
|
MeetingRequest.objects.create( |
||||
|
title=f"Online Consultation on Interfaith Dialogue Programs with {inst_foreign.name}", |
||||
|
requester_institution=inst_urd, |
||||
|
recipient_institution=inst_foreign, |
||||
|
created_by=user, |
||||
|
status=MeetingStatus.PENDING, |
||||
|
meeting_date=today + datetime.timedelta(days=12), |
||||
|
meeting_time=datetime.time(16, 0), |
||||
|
duration_minutes=45, |
||||
|
meeting_url=f"https://meet.jit.si/mch-urd-{inst_foreign.id}-dialogue", |
||||
|
agenda="""- Introduction to academic distance-learning modules offered by URD. |
||||
|
- Exchange of educational resources for European Muslim youth. |
||||
|
- Establishing bilateral research contacts.""", |
||||
|
admin_notes="Pending confirmation of time slot by the European center director.", |
||||
|
) |
||||
|
|
||||
|
# Meeting 5: Completed Past Meeting (Historical record) |
||||
|
if inst_mustafa: |
||||
|
MeetingRequest.objects.create( |
||||
|
title="جلسه پیشنیاز راهاندازی کارگاههای روش تحقیق در مطالعات حدیثی", |
||||
|
requester_institution=inst_urd, |
||||
|
recipient_institution=inst_mustafa, |
||||
|
created_by=user, |
||||
|
status=MeetingStatus.COMPLETED, |
||||
|
meeting_date=today - datetime.timedelta(days=10), |
||||
|
meeting_time=datetime.time(11, 0), |
||||
|
duration_minutes=60, |
||||
|
meeting_url="https://meet.jit.si/mch-urd-mustafa-workshop-completed", |
||||
|
agenda="""۱. مرور سرفصلهای کارگاه ۳۰ ساعته روش تحقیق. |
||||
|
۲. انتخاب مدرسان همکار و زمانبندی جلسات آنلاین.""", |
||||
|
admin_notes="جلسه با موفقیت کامل برگزار شد و مصوبات به امضای طرفین رسید.", |
||||
|
) |
||||
|
|
||||
|
self.stdout.write(self.style.SUCCESS("Populated 5 bilateral video meeting sessions (Scheduled, Pending, Completed).")) |
||||
|
|
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS("\nSuccessfully enriched messaging chats and video meetings for حجتالاسلام دکتر احمد هاشمی!") |
||||
|
) |
||||
@ -0,0 +1 @@ |
|||||
|
# Management package |
||||
@ -0,0 +1 @@ |
|||||
|
# Commands package |
||||
@ -0,0 +1,377 @@ |
|||||
|
import datetime |
||||
|
import urllib.request |
||||
|
from django.core.files.base import ContentFile |
||||
|
from django.core.management.base import BaseCommand |
||||
|
from django.db import transaction |
||||
|
from django.utils import timezone |
||||
|
from apps.account.models import User |
||||
|
from apps.profiles.models.institution import Institution, InstitutionTimeline, InstitutionMember |
||||
|
from apps.projects.models.project import Project |
||||
|
from apps.cms.models.post import Post, PostCategory |
||||
|
|
||||
|
|
||||
|
RICH_HISTORY = """Founded in 1998 in Southeast Calgary, Alberta, the Al-Madinah Islamic Centre has grown from a humble community gathering hall into one of Western Canada's most vibrant Islamic educational, cultural, and spiritual hubs. The Centre was established by pioneering Muslim families seeking to cultivate a welcoming sanctuary for worship, youth development, religious literacy, and civic engagement. |
||||
|
|
||||
|
Over more than two decades, Al-Madinah has expanded its facilities to encompass a grand prayer hall accommodating over 1,200 congregants, an accredited weekend Islamic Academy, modern seminar classrooms, a specialized theological research library, and an active family counseling department. The institution is renowned across Alberta for its vibrant multicultural congregation, extensive charitable food hampers, winter relief drives, and proactive interfaith dialogue partnerships with civic leaders and faith communities across Greater Calgary. |
||||
|
|
||||
|
Today, Al-Madinah Islamic Centre operates as an inclusive, full-service community anchor providing daily congregational prayers, youth leadership fellowships, refugee resettlement assistance, Qur'anic memorization programs, and scholarly seminars addressing contemporary ethical issues.""" |
||||
|
|
||||
|
|
||||
|
TIMELINE_EVENTS = [ |
||||
|
{ |
||||
|
"year": "1998", |
||||
|
"title": "Foundation & First Community Assembly", |
||||
|
"description": "Established by pioneering Muslim immigrant families in Southeast Calgary to organize daily prayers, Taraweeh, and weekend Islamic education.", |
||||
|
"order": 1, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2004", |
||||
|
"title": "Permanent 17th Avenue Facility Acquisition", |
||||
|
"description": "Purchased and renovated the dedicated multi-level facility at 4612 17 Ave SE, creating a full-capacity mosque, community hall, and classrooms.", |
||||
|
"order": 2, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2010", |
||||
|
"title": "Inauguration of Al-Madinah Youth & Quran Academy", |
||||
|
"description": "Launched accredited weekend and evening curricula offering comprehensive Quranic Tajweed, Arabic literacy, and Islamic studies for over 300 youth.", |
||||
|
"order": 3, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2016", |
||||
|
"title": "Sisterhood Wing & Family Counseling Expansion", |
||||
|
"description": "Added a dedicated multi-purpose wing with women's educational lounges, nursery facilities, and professional family and mental health counseling services.", |
||||
|
"order": 4, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2020", |
||||
|
"title": "COVID-19 Relief & Digital Broadcast Studio", |
||||
|
"description": "Built a high-definition digital broadcasting studio for live-streamed lectures and led the 'Feed Calgary' emergency food hamper relief initiative.", |
||||
|
"order": 5, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2023", |
||||
|
"title": "25th Silver Jubilee & Green Mosque Solar Initiative", |
||||
|
"description": "Celebrated 25 years of community service, retrofitting the center with clean rooftop solar arrays, LED systems, and environmental efficiency upgrades.", |
||||
|
"order": 6, |
||||
|
}, |
||||
|
{ |
||||
|
"year": "2025-2026", |
||||
|
"title": "Western Canada Interfaith Fellowship & Heritage Archive", |
||||
|
"description": "Established an annual Western Canada interfaith symposium and inaugurated the Prairie Muslim Historical & Manuscript Archive.", |
||||
|
"order": 7, |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
PROJECTS_DATA = [ |
||||
|
{ |
||||
|
"title": "Al-Madinah Green Mosque & Renewable Energy Retrofit", |
||||
|
"category": "Environmental Sustainability & Green Infrastructure", |
||||
|
"status": Project.Status.COMPLETED, |
||||
|
"progress_percentage": 100, |
||||
|
"budget": "$180,000 CAD", |
||||
|
"team_size": 8, |
||||
|
"description": "A landmark environmental initiative converting the center into an eco-friendly green mosque with rooftop solar array, rainwater harvesting systems, and smart HVAC climate controls.", |
||||
|
"start_date": datetime.date(2023, 3, 1), |
||||
|
"actual_end_date": datetime.date(2024, 8, 15), |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Alberta Muslim Youth Leadership & STEM Fellowship", |
||||
|
"category": "Youth Empowerment & Educational Academy", |
||||
|
"status": Project.Status.ACTIVE, |
||||
|
"progress_percentage": 75, |
||||
|
"budget": "$95,000 CAD", |
||||
|
"team_size": 12, |
||||
|
"description": "Mentorship fellowship pairing high school and university students with industry leaders in Alberta, offering robotics bootcamps, public speaking masterclasses, and ethics seminars.", |
||||
|
"start_date": datetime.date(2025, 1, 10), |
||||
|
"estimated_end_date": datetime.date(2026, 12, 20), |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Calgary Interfaith Winter Warmth & Food Hamper Drive", |
||||
|
"category": "Humanitarian Relief & Civic Outreach", |
||||
|
"status": Project.Status.ACTIVE, |
||||
|
"progress_percentage": 85, |
||||
|
"budget": "$60,000 CAD", |
||||
|
"team_size": 25, |
||||
|
"description": "Annual city-wide charitable drive distributing over 2,500 warm winter coats, thermal blankets, and nutritious food hampers to vulnerable families across Greater Calgary regardless of faith.", |
||||
|
"start_date": datetime.date(2025, 10, 1), |
||||
|
"estimated_end_date": datetime.date(2026, 4, 30), |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Prairie Islamic Heritage Archive & Digital Library", |
||||
|
"category": "Theological Research & Cultural Preservation", |
||||
|
"status": Project.Status.PLANNING, |
||||
|
"progress_percentage": 35, |
||||
|
"budget": "$45,000 CAD", |
||||
|
"team_size": 5, |
||||
|
"description": "An ambitious digital humanities initiative preserving rare classical Islamic texts, oral histories of Muslim pioneers in the Canadian prairies, and making them freely searchable online.", |
||||
|
"start_date": datetime.date(2026, 2, 1), |
||||
|
"estimated_end_date": datetime.date(2027, 6, 30), |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
POSTS_DATA = [ |
||||
|
{ |
||||
|
"title": "Al-Madinah Centre Welcomes Over 1,500 Attendees for Annual Community Open House & Interfaith Gala", |
||||
|
"post_type": Post.PostType.NEWS, |
||||
|
"category_name": "Community News", |
||||
|
"category_slug": "community-news", |
||||
|
"image_url": "https://images.unsplash.com/photo-1564769625905-50e93615e769?auto=format&fit=crop&w=1200&q=80", |
||||
|
"image_filename": "open_house_gala.jpg", |
||||
|
"excerpt": "Civic leaders, neighbors, and community members gathered at Al-Madinah Islamic Centre for an evening of dialogue, cultural exhibition, and shared cuisine celebrating Calgary's diversity.", |
||||
|
"content": """The Al-Madinah Islamic Centre in Southeast Calgary hosted its annual Community Open House and Interfaith Gala this past weekend, welcoming more than 1,500 neighbors, faith leaders, city officials, and community advocates. |
||||
|
|
||||
|
The evening featured guided architecture tours of the newly renovated prayer halls, an Islamic calligraphy and manuscript exhibition, and insightful panel discussions on civic collaboration and social cohesion in Alberta. |
||||
|
|
||||
|
Keynote speaker Dr. Tariq Al-Mansoor emphasized: "Our mosques are open sanctuaries for understanding, friendship, and collective service to our city. In a world full of rapid change, gathering in goodwill and sharing a warm meal builds unbreakable bonds of compassion." |
||||
|
|
||||
|
Guests enjoyed traditional multicultural cuisine, while youth volunteers guided families through interactive educational booths showcasing the history and contributions of Canadian Muslims to the prairies.""", |
||||
|
"reading_time_minutes": 4, |
||||
|
"likes_count": 342, |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Nurturing Faith in the Modern City: Reflections on Youth Guidance and Digital Wellbeing", |
||||
|
"post_type": Post.PostType.ARTICLE, |
||||
|
"category_name": "Scholarly Insights", |
||||
|
"category_slug": "scholarly-insights", |
||||
|
"image_url": "https://images.unsplash.com/photo-1584286595398-a59f21d313f5?auto=format&fit=crop&w=1200&q=80", |
||||
|
"image_filename": "youth_digital_wellbeing.jpg", |
||||
|
"excerpt": "An analytical essay exploring strategies for cultivating mental health, moral resilience, and strong spiritual identity among young Muslims navigating the digital age.", |
||||
|
"content": """In an era characterized by hyper-connectivity, continuous social media immersion, and fragmented attention spans, nurturing a grounded moral identity among our youth has become one of the most critical responsibilities of modern Islamic institutions. |
||||
|
|
||||
|
At Al-Madinah Islamic Centre, our pedagogical philosophy blends timeless Quranic wisdom with contemporary mental health literacy. Faith is not merely an abstract doctrine; it is a living compass that provides emotional serenity, intellectual clarity, and purpose. |
||||
|
|
||||
|
Key principles for families and educators: |
||||
|
1. Intentional Digital Fasting: Cultivating designated screen-free hours to allow deep contemplative reflection, family conversation, and Quranic recitation. |
||||
|
2. Safe Spaces for Difficult Questions: Fostering an atmosphere where young people can openly voice philosophical and ethical queries without fear of judgment. |
||||
|
3. Action-Oriented Community Service: Anchoring spirituality in tangible community service—feeding the hungry, caring for neighbors, and protecting the environment. |
||||
|
|
||||
|
When youth experience faith as a dynamic force of empathy and moral courage, their spiritual roots grow resilient against the storms of modern cynicism.""", |
||||
|
"reading_time_minutes": 6, |
||||
|
"likes_count": 512, |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Registration Open for Fall 2026 Al-Madinah Quranic Memorization & Classical Arabic Programs", |
||||
|
"post_type": Post.PostType.NEWS, |
||||
|
"category_name": "Academy Announcements", |
||||
|
"category_slug": "academy-announcements", |
||||
|
"image_url": "https://images.unsplash.com/photo-1609599006353-e629aaabfeae?auto=format&fit=crop&w=1200&q=80", |
||||
|
"image_filename": "quran_arabic_academy.jpg", |
||||
|
"excerpt": "Al-Madinah Academy announces registration for its accredited after-school Quranic studies, Tajweed mastery, and Arabic literacy courses for youth and adults.", |
||||
|
"content": """The Al-Madinah Quran & Youth Academy is pleased to announce that official enrollment for the Fall 2026 academic semester is now open. |
||||
|
|
||||
|
Program Highlights: |
||||
|
• Part-time & Full-time Hifz (Memorization) Tracks supervised by certified Ijazah holders. |
||||
|
• Foundational Noorani Qaidah & Phonetics for children ages 5–8. |
||||
|
• Classical Arabic Grammar & Vocabulary for high school students and adults. |
||||
|
• Weekly Youth Halaqahs focusing on Islamic ethics, contemporary issues, and public leadership. |
||||
|
|
||||
|
All classrooms feature smart interactive screens, hybrid digital learning portals, and small teacher-to-student ratios (maximum 12 students per class) to guarantee individualized mentorship. |
||||
|
|
||||
|
Early-bird registration discounts and need-based tuition assistance are available upon application. Visit the academy administration desk or register online via our education portal.""", |
||||
|
"reading_time_minutes": 3, |
||||
|
"likes_count": 218, |
||||
|
}, |
||||
|
{ |
||||
|
"title": "Annual Community Impact Report: Over 15,000 Meals Distributed and 450 Academy Graduates", |
||||
|
"post_type": Post.PostType.REPORT, |
||||
|
"category_name": "Impact Reports", |
||||
|
"category_slug": "impact-reports", |
||||
|
"image_url": "https://images.unsplash.com/photo-1593113598332-cd288d649433?auto=format&fit=crop&w=1200&q=80", |
||||
|
"image_filename": "community_impact_meals.jpg", |
||||
|
"excerpt": "Reviewing a year of transformative growth: over 15,000 community meals distributed, 450 academy graduates, and new interfaith partnerships across Alberta.", |
||||
|
"content": """The Board of Directors and Executive Committee of Al-Madinah Islamic Centre Calgary are pleased to present the 2025–2026 Community Impact Report. |
||||
|
|
||||
|
Executive Summary: |
||||
|
• 15,400+ Emergency Meals & Food Hampers prepared and distributed across Calgary SE and NE. |
||||
|
• 450+ Students graduated from our elementary, youth, and adult education tracks. |
||||
|
• 8,200+ Attendees participated in weekly Friday congregational services and community dinners. |
||||
|
• 12 Major Interfaith & Civic Forums convened in partnership with local universities and interfaith alliances. |
||||
|
• $180,000 Completed Renewable Energy Retrofit, reducing the facility's carbon footprint by 45%. |
||||
|
|
||||
|
We extend our heartfelt gratitude to our dedicated volunteers, donors, teachers, and staff who embody the prophetic virtue of serving creation with excellence (Ihsan).""", |
||||
|
"reading_time_minutes": 5, |
||||
|
"likes_count": 489, |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
help = "Populate rich data (history, timeline, projects, posts/news) for Al-Madinah Islamic Centre Calgary." |
||||
|
|
||||
|
def handle(self, *args, **options): |
||||
|
with transaction.atomic(): |
||||
|
admin_user = User.objects.filter(is_superuser=True).first() or User.objects.first() |
||||
|
|
||||
|
inst = Institution.objects.filter(name__icontains="Al-Madinah").filter(city__icontains="Calgary").first() |
||||
|
if not inst: |
||||
|
inst = Institution.objects.filter(id=1171).first() |
||||
|
|
||||
|
if not inst: |
||||
|
inst = Institution.objects.create( |
||||
|
name="Al-Madinah Islamic Centre Calgary", |
||||
|
slug="al-madinah-islamic-centre-calgary", |
||||
|
country="Canada", |
||||
|
city="Calgary", |
||||
|
address="4612 17 Ave SE, Calgary, AB T2A 0V1, Canada", |
||||
|
latitude=51.037833, |
||||
|
longitude=-113.971889, |
||||
|
type=Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
) |
||||
|
|
||||
|
# Update rich fields |
||||
|
inst.name = "Al-Madinah Islamic Centre Calgary" |
||||
|
inst.slug = "al-madinah-islamic-centre-calgary" |
||||
|
inst.country = "Canada" |
||||
|
inst.city = "Calgary" |
||||
|
inst.address = "4612 17 Ave SE, Calgary, AB T2A 0V1, Canada" |
||||
|
inst.latitude = 51.037833 |
||||
|
inst.longitude = -113.971889 |
||||
|
inst.phone = "+1 (403) 248-2786" |
||||
|
inst.email = "info@almadinahcalgary.com" |
||||
|
inst.website = "https://almadinahcalgary.com" |
||||
|
inst.established_year = 1998 |
||||
|
inst.is_featured = True |
||||
|
inst.is_active = True |
||||
|
inst.verification_status = Institution.VerificationStatus.APPROVED |
||||
|
inst.follower_count = 2450 |
||||
|
inst.description = RICH_HISTORY |
||||
|
inst.tags = [ |
||||
|
"Mosque", |
||||
|
"Islamic Center", |
||||
|
"Youth Academy", |
||||
|
"Interfaith Dialogue", |
||||
|
"Quranic Studies", |
||||
|
"Charity", |
||||
|
"Family Counseling", |
||||
|
] |
||||
|
inst.working_hours = { |
||||
|
"monday": "05:00 - 22:30", |
||||
|
"tuesday": "05:00 - 22:30", |
||||
|
"wednesday": "05:00 - 22:30", |
||||
|
"thursday": "05:00 - 22:30", |
||||
|
"friday": "04:30 - 23:00", |
||||
|
"saturday": "05:00 - 22:30", |
||||
|
"sunday": "05:00 - 22:30", |
||||
|
} |
||||
|
inst.social_media = { |
||||
|
"facebook": "https://facebook.com/almadinahcalgary", |
||||
|
"twitter": "https://twitter.com/almadinahyyc", |
||||
|
"instagram": "https://instagram.com/almadinah_calgary", |
||||
|
"youtube": "https://youtube.com/@almadinahcalgary", |
||||
|
"telegram": "https://t.me/almadinahyyc", |
||||
|
} |
||||
|
|
||||
|
# Download and assign relatable cover image and avatar for Al-Madinah |
||||
|
try: |
||||
|
cov_req = urllib.request.Request( |
||||
|
"https://images.unsplash.com/photo-1519817650390-64a93db51149?auto=format&fit=crop&w=1600&q=80", |
||||
|
headers={"User-Agent": "Mozilla/5.0"}, |
||||
|
) |
||||
|
with urllib.request.urlopen(cov_req, timeout=10) as resp: |
||||
|
inst.cover_image.save("almadinah_calgary_cover.jpg", ContentFile(resp.read()), save=False) |
||||
|
except Exception as e: |
||||
|
self.stdout.write(self.style.WARNING(f"Could not download cover image: {e}")) |
||||
|
|
||||
|
try: |
||||
|
ava_req = urllib.request.Request( |
||||
|
"https://images.unsplash.com/photo-1584551246679-0daf3d275d0f?auto=format&fit=crop&w=400&q=80", |
||||
|
headers={"User-Agent": "Mozilla/5.0"}, |
||||
|
) |
||||
|
with urllib.request.urlopen(ava_req, timeout=10) as resp: |
||||
|
inst.avatar.save("almadinah_calgary_avatar.jpg", ContentFile(resp.read()), save=False) |
||||
|
except Exception as e: |
||||
|
self.stdout.write(self.style.WARNING(f"Could not download avatar: {e}")) |
||||
|
|
||||
|
inst.save() |
||||
|
self.stdout.write(self.style.SUCCESS(f"Updated institution profile: {inst.name} (ID: {inst.id})")) |
||||
|
|
||||
|
# Ensure members are assigned for permissions |
||||
|
for u in User.objects.all(): |
||||
|
InstitutionMember.objects.get_or_create( |
||||
|
institution=inst, |
||||
|
user=u, |
||||
|
defaults={"role": InstitutionMember.MemberRole.ADMIN, "title": "Staff / Researcher"} |
||||
|
) |
||||
|
|
||||
|
# Populate Timeline entries |
||||
|
inst.timeline_entries.all().delete() |
||||
|
for t_item in TIMELINE_EVENTS: |
||||
|
InstitutionTimeline.objects.create( |
||||
|
institution=inst, |
||||
|
year=t_item["year"], |
||||
|
title=t_item["title"], |
||||
|
description=t_item["description"], |
||||
|
order=t_item["order"], |
||||
|
) |
||||
|
self.stdout.write(self.style.SUCCESS(f"Populated {len(TIMELINE_EVENTS)} timeline milestones.")) |
||||
|
|
||||
|
# Populate Projects |
||||
|
inst.owned_projects.all().delete() |
||||
|
for p_item in PROJECTS_DATA: |
||||
|
Project.objects.create( |
||||
|
owner_institution=inst, |
||||
|
title=p_item["title"], |
||||
|
category=p_item["category"], |
||||
|
status=p_item["status"], |
||||
|
progress_percentage=p_item["progress_percentage"], |
||||
|
budget=p_item["budget"], |
||||
|
team_size=p_item["team_size"], |
||||
|
description=p_item["description"], |
||||
|
start_date=p_item["start_date"], |
||||
|
actual_end_date=p_item.get("actual_end_date"), |
||||
|
estimated_end_date=p_item.get("estimated_end_date"), |
||||
|
created_by=admin_user, |
||||
|
) |
||||
|
self.stdout.write(self.style.SUCCESS(f"Populated {len(PROJECTS_DATA)} institutional projects.")) |
||||
|
|
||||
|
# Populate Posts and News with Relatable Images |
||||
|
inst.cms_posts.all().delete() |
||||
|
for post_item in POSTS_DATA: |
||||
|
cat, _ = PostCategory.objects.get_or_create( |
||||
|
slug=post_item["category_slug"], |
||||
|
defaults={ |
||||
|
"name": post_item["category_name"], |
||||
|
"language": "en", |
||||
|
"description": f"Articles and updates for {post_item['category_name']}", |
||||
|
}, |
||||
|
) |
||||
|
|
||||
|
post = Post.objects.create( |
||||
|
institution=inst, |
||||
|
author=admin_user, |
||||
|
author_role_label="Director of Communications", |
||||
|
title=post_item["title"], |
||||
|
post_type=post_item["post_type"], |
||||
|
category=cat, |
||||
|
language=Post.LanguageChoices.EN, |
||||
|
status=Post.Status.PUBLISHED, |
||||
|
excerpt=post_item["excerpt"], |
||||
|
content=post_item["content"], |
||||
|
reading_time_minutes=post_item["reading_time_minutes"], |
||||
|
likes_count=post_item["likes_count"], |
||||
|
tags=[ |
||||
|
{"image_url": post_item["image_url"]}, |
||||
|
"Calgary", |
||||
|
"Al-Madinah", |
||||
|
post_item["category_name"], |
||||
|
], |
||||
|
is_featured=True, |
||||
|
publish_date=timezone.now(), |
||||
|
) |
||||
|
|
||||
|
# Download image and attach locally as featured_image |
||||
|
try: |
||||
|
p_req = urllib.request.Request(post_item["image_url"], headers={"User-Agent": "Mozilla/5.0"}) |
||||
|
with urllib.request.urlopen(p_req, timeout=10) as resp: |
||||
|
post.featured_image.save(post_item["image_filename"], ContentFile(resp.read()), save=True) |
||||
|
self.stdout.write(self.style.SUCCESS(f"Attached image for: {post.title[:40]}...")) |
||||
|
except Exception as e: |
||||
|
self.stdout.write(self.style.WARNING(f"Could not download {post_item['image_filename']}: {e}")) |
||||
|
|
||||
|
self.stdout.write(self.style.SUCCESS(f"Populated {len(POSTS_DATA)} articles, news, and reports.")) |
||||
|
|
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS("\nSuccessfully enriched Al-Madinah Islamic Centre Calgary with comprehensive data!") |
||||
|
) |
||||
@ -0,0 +1,371 @@ |
|||||
|
from django.core.management.base import BaseCommand |
||||
|
from django.db import transaction |
||||
|
from django.utils.text import slugify |
||||
|
from apps.profiles.models.institution import Institution |
||||
|
|
||||
|
GLOBAL_INSTITUTIONS = [ |
||||
|
# ==================== RUSSIA ==================== |
||||
|
{ |
||||
|
"name": "Moscow Cathedral Mosque", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Russia", |
||||
|
"city": "Moscow", |
||||
|
"address": "Pereulok Vypolzov, 7, Moscow, Russia, 129090", |
||||
|
"latitude": 55.779144, |
||||
|
"longitude": 37.626889, |
||||
|
"description": "The main cathedral mosque of Moscow and one of the largest in Europe, featuring a grand dome and minarets.", |
||||
|
"website": "https://mihrab.ru", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Saint Petersburg Mosque", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Russia", |
||||
|
"city": "Saint Petersburg", |
||||
|
"address": "Kronverkskiy Prospekt, 7, St Petersburg, Russia, 197046", |
||||
|
"latitude": 59.955364, |
||||
|
"longitude": 30.323927, |
||||
|
"description": "Historic blue-tiled cathedral mosque in central Saint Petersburg, established in 1913.", |
||||
|
"website": "https://dum-spb.ru", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Derbent Juma Mosque", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Russia", |
||||
|
"city": "Derbent", |
||||
|
"address": "Ulitsa 7 Noyabrya, Derbent, Republic of Dagestan, Russia, 368600", |
||||
|
"latitude": 42.054425, |
||||
|
"longitude": 48.277811, |
||||
|
"description": "The oldest surviving mosque in Russia and the CIS, dating back to 734 CE with rich Shia cultural heritage.", |
||||
|
"website": "https://derbent-museum.ru", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Kul Sharif Mosque", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Russia", |
||||
|
"city": "Kazan", |
||||
|
"address": "Kazan Kremlin, Kazan, Republic of Tatarstan, Russia, 420014", |
||||
|
"latitude": 55.798402, |
||||
|
"longitude": 49.105284, |
||||
|
"description": "Prominent architectural masterpiece and religious cultural center inside the UNESCO-listed Kazan Kremlin.", |
||||
|
"website": "https://kazan-kremlin.ru", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Memorial Mosque on Poklonnaya Hill", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Russia", |
||||
|
"city": "Moscow", |
||||
|
"address": "Ulitsa Minskaya, 2B, Moscow, Russia, 121096", |
||||
|
"latitude": 55.731722, |
||||
|
"longitude": 37.498806, |
||||
|
"description": "Islamic cultural complex and memorial mosque erected in Victory Park commemorating Muslim defenders.", |
||||
|
"website": "https://memorial-mosque.ru", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
|
||||
|
# ==================== SOUTH AMERICA ==================== |
||||
|
{ |
||||
|
"name": "Centro Islámico / Mezquita At-Tauhid", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Argentina", |
||||
|
"city": "Buenos Aires", |
||||
|
"address": "Av. San Juan 3053, C1233AAN Cdad. Autónoma de Buenos Aires, Argentina", |
||||
|
"latitude": -34.629341, |
||||
|
"longitude": -58.406821, |
||||
|
"description": "The premier Shia mosque and Islamic cultural association in Argentina and South America, founded in 1983.", |
||||
|
"website": "https://attauhid.com.ar", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Mesquita Brasil / Centro Islâmico Beneficente", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Brazil", |
||||
|
"city": "São Paulo", |
||||
|
"address": "R. Barão de Ladário, 253 - Brás, São Paulo - SP, 03010-000, Brazil", |
||||
|
"latitude": -23.535814, |
||||
|
"longitude": -46.618621, |
||||
|
"description": "The oldest mosque in Brazil and South America, founded in 1929 by the Muslim Beneficent Society.", |
||||
|
"website": "https://mesquitabrasil.com.br", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Mesquita Imam Ali", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Brazil", |
||||
|
"city": "Curitiba", |
||||
|
"address": "R. Kellers, 383 - São Francisco, Curitiba - PR, 80410-100, Brazil", |
||||
|
"latitude": -25.424712, |
||||
|
"longitude": -49.278945, |
||||
|
"description": "Major Shia mosque and Islamic cultural institution in Curitiba, Paraná, serving southern Brazil.", |
||||
|
"website": "https://islamcuritiba.com.br", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Mesquita Omar Ibn Al-Khattab", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Brazil", |
||||
|
"city": "Foz do Iguaçu", |
||||
|
"address": "R. Meca, 599 - Jardim Central, Foz do Iguaçu - PR, 85864-410, Brazil", |
||||
|
"latitude": -25.523821, |
||||
|
"longitude": -54.577239, |
||||
|
"description": "Prominent mosque serving the large Muslim community of the Triple Frontier border region.", |
||||
|
"website": "https://mesquitafoz.com.br", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Centro Cultural Islámico / Mezquita Ibrahim Al-Ibrahim", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Venezuela", |
||||
|
"city": "Caracas", |
||||
|
"address": "Av. Libertador, Caracas 1050, Distrito Capital, Venezuela", |
||||
|
"latitude": 10.501532, |
||||
|
"longitude": -66.896741, |
||||
|
"description": "One of the largest mosques in Latin America, serving as a landmark cultural hub in Caracas.", |
||||
|
"website": "https://mezquitadecaracas.org", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Mezquita As-Salam", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Chile", |
||||
|
"city": "Santiago", |
||||
|
"address": "Av. Chile España 1775, Ñuñoa, Región Metropolitana, Chile", |
||||
|
"latitude": -33.454215, |
||||
|
"longitude": -70.597734, |
||||
|
"description": "First purpose-built mosque and Islamic cultural center in Chile, founded in 1989.", |
||||
|
"website": "https://islamenchile.cl", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Centro Islámico de Bogotá", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Colombia", |
||||
|
"city": "Bogota", |
||||
|
"address": "Cl. 80 #8-44, Bogotá, Colombia", |
||||
|
"latitude": 4.663912, |
||||
|
"longitude": -74.058831, |
||||
|
"description": "Major Islamic center and community gathering venue in the capital city of Colombia.", |
||||
|
"website": "https://islamencolombia.co", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
|
||||
|
# ==================== CANADA ==================== |
||||
|
{ |
||||
|
"name": "Jaffari Community Centre (ISIJ of Toronto)", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Canada", |
||||
|
"city": "Vaughan", |
||||
|
"address": "9000 Bathurst St, Thornhill, ON L4J 8A7, Canada", |
||||
|
"latitude": 43.856611, |
||||
|
"longitude": -79.459528, |
||||
|
"description": "One of the largest Shia Islamic community centers in North America, featuring schools, halls, and worship facilities.", |
||||
|
"website": "https://jaffari.org", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Az-Zahraa Islamic Academy & Shia Community", |
||||
|
"type": Institution.InstitutionType.INSTITUTE, |
||||
|
"country": "Canada", |
||||
|
"city": "Richmond", |
||||
|
"address": "8580 No 5 Rd, Richmond, BC V6Y 2V4, Canada", |
||||
|
"latitude": 49.1508645, |
||||
|
"longitude": -123.0903613, |
||||
|
"description": "Leading Shia educational academy and community center in Greater Vancouver, British Columbia.", |
||||
|
"website": "https://az-zahraa.org", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Al-Batool Islamic Center Montreal", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Canada", |
||||
|
"city": "Montreal", |
||||
|
"address": "5885 Rue Jean-Talon E, Saint-Léonard, QC H1S 1M5, Canada", |
||||
|
"latitude": 45.588889, |
||||
|
"longitude": -73.581667, |
||||
|
"description": "Premier Shia community hub and center for cultural, social, and spiritual programs in Montreal, Quebec.", |
||||
|
"website": "https://albatool.ca", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Al-Madinah Islamic Centre Calgary", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Canada", |
||||
|
"city": "Calgary", |
||||
|
"address": "4612 17 Ave SE, Calgary, AB T2A 0V1, Canada", |
||||
|
"latitude": 51.037833, |
||||
|
"longitude": -113.971889, |
||||
|
"description": "Central Islamic gathering place and community resource center in Calgary, Alberta.", |
||||
|
"website": "https://almadinahcalgary.com", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Ottawa Shia Islamic Community & Ahlul-Bayt Centre", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Canada", |
||||
|
"city": "Ottawa", |
||||
|
"address": "2001 Merivale Rd, Nepean, ON K2G 1G1, Canada", |
||||
|
"latitude": 45.335530, |
||||
|
"longitude": -75.727193, |
||||
|
"description": "Vibrant Islamic cultural, youth, and prayer community center located in Canada's National Capital Region.", |
||||
|
"website": "https://ahlulbayt.ca", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
|
||||
|
# ==================== EUROPE ==================== |
||||
|
{ |
||||
|
"name": "Islamic Centre of England (IC-EL)", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "United Kingdom", |
||||
|
"city": "London", |
||||
|
"address": "140 Maida Vale, London W9 1QB, United Kingdom", |
||||
|
"latitude": 51.531235, |
||||
|
"longitude": -0.198374, |
||||
|
"description": "Leading Islamic educational, research, and cultural institution in Central London.", |
||||
|
"website": "https://ic-el.com", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Grande Mosquée de Paris", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "France", |
||||
|
"city": "Paris", |
||||
|
"address": "2bis Place du Puits de l'Ermite, 75005 Paris, France", |
||||
|
"latitude": 48.841944, |
||||
|
"longitude": 2.355278, |
||||
|
"description": "Historic grand mosque of Paris, featuring stunning Moorish gardens and an iconic 33-meter minaret.", |
||||
|
"website": "https://grandemosqueedeparis.net", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Islamisches Zentrum Hamburg (Imam Ali Mosque)", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Germany", |
||||
|
"city": "Hamburg", |
||||
|
"address": "Schöne Aussicht 36, 22085 Hamburg, Germany", |
||||
|
"latitude": 53.568444, |
||||
|
"longitude": 10.007639, |
||||
|
"description": "Historic mosque and Islamic center located directly on the Outer Alster Lake in Hamburg, Germany.", |
||||
|
"website": "https://izhamburg.com", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Grande Moschea di Roma (Great Mosque of Rome)", |
||||
|
"type": Institution.InstitutionType.MOSQUE, |
||||
|
"country": "Italy", |
||||
|
"city": "Rome", |
||||
|
"address": "Viale della Moschea, 85, 00197 Roma RM, Italy", |
||||
|
"latitude": 41.934444, |
||||
|
"longitude": 12.495278, |
||||
|
"description": "The largest mosque in the Western world, known for its majestic Roman travertine columns and lush parkland.", |
||||
|
"website": "https://centroislamicoculturale.it", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Centro Cultural Islámico de Madrid (Mezquita M-30)", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Spain", |
||||
|
"city": "Madrid", |
||||
|
"address": "Calle Salvador de Madariaga, 7, 28027 Madrid, Spain", |
||||
|
"latitude": 40.439815, |
||||
|
"longitude": -3.655167, |
||||
|
"description": "The largest Islamic cultural center and mosque complex in Spain, built in white Almería marble.", |
||||
|
"website": "https://ccimadrid.org", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Imam Ali Islamic Center Stockholm", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Sweden", |
||||
|
"city": "Stockholm", |
||||
|
"address": "Datavägen 2B, 175 43 Järfälla, Sweden", |
||||
|
"latitude": 59.421944, |
||||
|
"longitude": 17.842778, |
||||
|
"description": "The largest Shia Islamic organization and cultural center in Scandinavia, providing multi-lingual community services.", |
||||
|
"website": "https://iac-swe.se", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Imam Ali Islamic Centre Vienna", |
||||
|
"type": Institution.InstitutionType.CULTURAL_CENTER, |
||||
|
"country": "Austria", |
||||
|
"city": "Vienna", |
||||
|
"address": "Mollardgasse 50, 1060 Wien, Austria", |
||||
|
"latitude": 48.192525, |
||||
|
"longitude": 16.348115, |
||||
|
"description": "Important cultural and religious center fostering interfaith dialogue and community programs in Vienna.", |
||||
|
"website": "https://izwien.at", |
||||
|
"is_featured": True, |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
help = "Seed and feature prominent institutions across Russia, South America, Canada, and Europe." |
||||
|
|
||||
|
def handle(self, *args, **options): |
||||
|
created_count = 0 |
||||
|
updated_count = 0 |
||||
|
|
||||
|
with transaction.atomic(): |
||||
|
for item in GLOBAL_INSTITUTIONS: |
||||
|
name = item["name"] |
||||
|
country = item["country"] |
||||
|
city = item["city"] |
||||
|
|
||||
|
inst = Institution.objects.filter(name__iexact=name).first() |
||||
|
|
||||
|
if inst: |
||||
|
inst.name = name |
||||
|
inst.country = country |
||||
|
inst.city = city |
||||
|
inst.address = item["address"] |
||||
|
inst.latitude = item["latitude"] |
||||
|
inst.longitude = item["longitude"] |
||||
|
inst.type = item["type"] |
||||
|
inst.description = item["description"] |
||||
|
inst.website = item["website"] |
||||
|
inst.is_featured = True |
||||
|
inst.is_active = True |
||||
|
inst.verification_status = Institution.VerificationStatus.APPROVED |
||||
|
inst.save() |
||||
|
updated_count += 1 |
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS( |
||||
|
f"Updated: {inst.name} ({city}, {country}) -> {inst.latitude}, {inst.longitude}" |
||||
|
) |
||||
|
) |
||||
|
else: |
||||
|
inst = Institution.objects.create( |
||||
|
name=name, |
||||
|
country=country, |
||||
|
city=city, |
||||
|
address=item["address"], |
||||
|
latitude=item["latitude"], |
||||
|
longitude=item["longitude"], |
||||
|
type=item["type"], |
||||
|
description=item["description"], |
||||
|
website=item["website"], |
||||
|
is_featured=True, |
||||
|
is_active=True, |
||||
|
verification_status=Institution.VerificationStatus.APPROVED, |
||||
|
) |
||||
|
created_count += 1 |
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS( |
||||
|
f"Created: {inst.name} ({city}, {country}) -> {inst.latitude}, {inst.longitude}" |
||||
|
) |
||||
|
) |
||||
|
|
||||
|
# Also ensure our 15 widespread US institutions from earlier are marked is_featured=True |
||||
|
us_ids = [1958, 44, 2006, 2004, 526, 535, 527, 544, 2065, 2059, 2048, 2041, 2019, 2055, 2061] |
||||
|
featured_us = Institution.objects.filter(id__in=us_ids).update(is_featured=True) |
||||
|
self.stdout.write(self.style.SUCCESS(f"Marked {featured_us} US institutions as is_featured=True")) |
||||
|
|
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS( |
||||
|
f"\nFinished seeding: {created_count} created, {updated_count} updated across Russia, South America, Canada, and Europe." |
||||
|
) |
||||
|
) |
||||
@ -0,0 +1,173 @@ |
|||||
|
from django.core.management.base import BaseCommand |
||||
|
from django.db import transaction |
||||
|
from apps.profiles.models.institution import Institution |
||||
|
|
||||
|
# 15 institutions across 12+ distinct US states & regions to ensure widespread map distribution |
||||
|
COORDINATE_UPDATES = [ |
||||
|
{ |
||||
|
"id": 1958, |
||||
|
"name": "SABA Islamic Center", |
||||
|
"city": "San Jose", |
||||
|
"state": "CA", |
||||
|
"latitude": 37.4210206, |
||||
|
"longitude": -121.9582212, |
||||
|
"region": "Northern California (Bay Area / Silicon Valley)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 44, |
||||
|
"name": "Jafaria Shia Islamic Society", |
||||
|
"city": "Anaheim", |
||||
|
"state": "CA", |
||||
|
"latitude": 33.8469003, |
||||
|
"longitude": -117.895613, |
||||
|
"region": "Southern California (Greater Los Angeles / Orange County)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2006, |
||||
|
"name": "IILM Shia Center", |
||||
|
"city": "Plano", |
||||
|
"state": "TX", |
||||
|
"latitude": 33.007489, |
||||
|
"longitude": -96.734087, |
||||
|
"region": "Texas (Dallas-Fort Worth Metroplex)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2004, |
||||
|
"name": "Shia Islamic Education Center", |
||||
|
"city": "Ballwin", |
||||
|
"state": "MO", |
||||
|
"latitude": 38.61687, |
||||
|
"longitude": -90.617339, |
||||
|
"region": "Missouri (Greater St. Louis)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 526, |
||||
|
"name": "Al Zehra Islamic Center", |
||||
|
"city": "Wauwatosa", |
||||
|
"state": "WI", |
||||
|
"latitude": 43.0585154, |
||||
|
"longitude": -88.0471122, |
||||
|
"region": "Wisconsin (Greater Milwaukee)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 535, |
||||
|
"name": "Muslim Community Center (MCC Chicago)", |
||||
|
"city": "Chicago", |
||||
|
"state": "IL", |
||||
|
"latitude": 41.9602582, |
||||
|
"longitude": -87.7290802, |
||||
|
"region": "Illinois (Chicago Metro)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 527, |
||||
|
"name": "West Michigan Islamic Center", |
||||
|
"city": "Kalamazoo", |
||||
|
"state": "MI", |
||||
|
"latitude": 42.2970842, |
||||
|
"longitude": -85.6404853, |
||||
|
"region": "Michigan (West Michigan)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 544, |
||||
|
"name": "Ahlul Bayt Society", |
||||
|
"city": "Columbus", |
||||
|
"state": "OH", |
||||
|
"latitude": 40.0913575, |
||||
|
"longitude": -83.0600833, |
||||
|
"region": "Ohio (Central Ohio)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2065, |
||||
|
"name": "Imam Ali Center", |
||||
|
"city": "Springfield", |
||||
|
"state": "VA", |
||||
|
"latitude": 38.7630016, |
||||
|
"longitude": -77.1841165, |
||||
|
"region": "Virginia (Northern Virginia / DC Metro)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2059, |
||||
|
"name": "The Imam Mahdi Islamic Education Center of Baltimore", |
||||
|
"city": "Parkville", |
||||
|
"state": "MD", |
||||
|
"latitude": 39.3902671, |
||||
|
"longitude": -76.5429408, |
||||
|
"region": "Maryland (Greater Baltimore)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2048, |
||||
|
"name": "Tri-State Bab-ul-ilm Islamic Center of Delaware", |
||||
|
"city": "Wilmington", |
||||
|
"state": "DE", |
||||
|
"latitude": 39.7501267, |
||||
|
"longitude": -75.575954, |
||||
|
"region": "Delaware (Wilmington / Tri-State)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2041, |
||||
|
"name": "Mahdieh of Philadelphia", |
||||
|
"city": "Philadelphia", |
||||
|
"state": "PA", |
||||
|
"latitude": 39.9722382, |
||||
|
"longitude": -75.2490429, |
||||
|
"region": "Pennsylvania (Greater Philadelphia)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2019, |
||||
|
"name": "Masjid-e-Ali", |
||||
|
"city": "Somerset", |
||||
|
"state": "NJ", |
||||
|
"latitude": 40.5309585, |
||||
|
"longitude": -74.5142428, |
||||
|
"region": "New Jersey (Central NJ)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2055, |
||||
|
"name": "Islaamic Center Of Mastic-Shirley", |
||||
|
"city": "Shirley", |
||||
|
"state": "NY", |
||||
|
"latitude": 40.7925976, |
||||
|
"longitude": -72.8642606, |
||||
|
"region": "New York (Long Island / Suffolk County)", |
||||
|
}, |
||||
|
{ |
||||
|
"id": 2061, |
||||
|
"name": "Islamic Masumeen Center of New England", |
||||
|
"city": "Hopkinton", |
||||
|
"state": "MA", |
||||
|
"latitude": 42.2288673, |
||||
|
"longitude": -71.5482629, |
||||
|
"region": "Massachusetts (Greater Boston / Metrowest)", |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
|
||||
|
class Command(BaseCommand): |
||||
|
help = "Populate wide-spread latitude and longitude coordinates for 15 institutions missing coordinates." |
||||
|
|
||||
|
def handle(self, *args, **options): |
||||
|
updated_count = 0 |
||||
|
with transaction.atomic(): |
||||
|
for item in COORDINATE_UPDATES: |
||||
|
try: |
||||
|
inst = Institution.objects.get(id=item["id"]) |
||||
|
inst.latitude = item["latitude"] |
||||
|
inst.longitude = item["longitude"] |
||||
|
inst.save(update_fields=["latitude", "longitude"]) |
||||
|
updated_count += 1 |
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS( |
||||
|
f"Updated #{inst.id} ({inst.name}) -> " |
||||
|
f"{inst.latitude}, {inst.longitude} [{item['city']}, {item['state']} - {item['region']}]" |
||||
|
) |
||||
|
) |
||||
|
except Institution.DoesNotExist: |
||||
|
self.stdout.write( |
||||
|
self.style.WARNING(f"Institution ID {item['id']} not found.") |
||||
|
) |
||||
|
|
||||
|
self.stdout.write( |
||||
|
self.style.SUCCESS( |
||||
|
f"\nSuccessfully populated coordinates for {updated_count} institutions across widespread regions." |
||||
|
) |
||||
|
) |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue