Browse Source

feat: add management command to seed quick access links for profiles

main
sina_sajjadi 2 weeks ago
parent
commit
e056039765
  1. 83
      apps/profiles/management/commands/seed_quick_access_links.py

83
apps/profiles/management/commands/seed_quick_access_links.py

@ -48,22 +48,98 @@ PRESETS = [
}, },
] ]
PRESETS_ENGLISH = [
{
"title": "Virtual Tour 360°",
"url": "https://centralmosque.kz/virtual-tour",
"description": "Interactive 360° panoramic walkthrough of the historical prayer halls, minaret, and courtyard.",
"icon": "landmark",
"color": "emerald",
"category": "Virtual Tour",
"is_live": False,
"is_external": True,
"order": 1,
},
{
"title": "Live Prayer & Jumu'ah Broadcast",
"url": "https://centralmosque.kz/live",
"description": "Continuous high-definition live stream of daily prayers, Azan recitation, and Friday congregational Khutbah.",
"icon": "video",
"color": "rose",
"category": "Live Stream",
"is_live": True,
"is_external": True,
"order": 2,
},
{
"title": "Digital Islamic Library",
"url": "https://centralmosque.kz/library",
"description": "Access to historical Islamic manuscripts, Quranic commentaries, and regional Kazakh Islamic heritage.",
"icon": "bookOpen",
"color": "blue",
"category": "Digital Library",
"is_live": False,
"is_external": True,
"order": 3,
},
{
"title": "Friday Sermons & Audio Lectures",
"url": "https://centralmosque.kz/media/lectures",
"description": "Archive of weekly Friday sermons, educational video series, and religious audio podcasts in Kazakh and Russian.",
"icon": "film",
"color": "purple",
"category": "Multimedia",
"is_live": False,
"is_external": True,
"order": 4,
},
{
"title": "Prayer Times & Hijri Calendar",
"url": "https://centralmosque.kz/prayer-times",
"description": "Official daily prayer times, monthly timetable, and regional religious events calendar.",
"icon": "calendar",
"color": "amber",
"category": "Services",
"is_live": False,
"is_external": True,
"order": 5,
},
{
"title": "Charity & Sadaqah Fund",
"url": "https://centralmosque.kz/charity",
"description": "Secure online portal for Zakat, voluntary Sadaqah, and supporting community welfare initiatives.",
"icon": "heartHandshake",
"color": "teal",
"category": "Charity",
"is_live": False,
"is_external": True,
"order": 6,
},
]
class Command(BaseCommand): class Command(BaseCommand):
help = "Seed canonical quick access links for primary institution (e.g. Astan Quds / ID 1)"
help = "Seed canonical quick access links for institutions (e.g. Astan Quds / ID 1 or Central City Mosque / ID 1815)"
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('--institution-id', type=int, default=1, help='Institution ID to attach links to') parser.add_argument('--institution-id', type=int, default=1, help='Institution ID to attach links to')
parser.add_argument('--preset', type=str, choices=['fa', 'en'], default=None, help='Preset language/template (fa or en)')
def handle(self, *args, **options): def handle(self, *args, **options):
inst_id = options.get('institution_id', 1) inst_id = options.get('institution_id', 1)
preset_choice = options.get('preset')
institution = Institution.objects.filter(id=inst_id).first() or Institution.objects.first() institution = Institution.objects.filter(id=inst_id).first() or Institution.objects.first()
if not institution: if not institution:
self.stdout.write(self.style.WARNING("No institution found to seed quick access links.")) self.stdout.write(self.style.WARNING("No institution found to seed quick access links."))
return return
if preset_choice == 'en' or institution.id == 1815 or 'central' in institution.name.lower():
presets = PRESETS_ENGLISH
else:
presets = PRESETS
created_count = 0 created_count = 0
for item in PRESETS:
for item in presets:
link, created = QuickAccessLink.objects.update_or_create( link, created = QuickAccessLink.objects.update_or_create(
institution=institution, institution=institution,
title=item['title'], title=item['title'],
@ -84,6 +160,7 @@ class Command(BaseCommand):
self.stdout.write( self.stdout.write(
self.style.SUCCESS( self.style.SUCCESS(
f"Successfully seeded canonical quick access links for '{institution.name}' (ID: {institution.id})."
f"Successfully seeded canonical quick access links ({len(presets)} links) for '{institution.name}' (ID: {institution.id})."
) )
) )
Loading…
Cancel
Save