This commit is contained in:
javad committed 2026-09-10 11:34:19 +03:30
commit fa9d154db9
260 files changed
+17643

No files matched your search

@@ -0,0 +1,21 @@
from django.db import migrations
def assign_legacy_contacts(apps, schema_editor):
OrganizationalUnit = apps.get_model("staff", "OrganizationalUnit")
ContactGroup = apps.get_model("customers", "ContactGroup")
CustomerProfile = apps.get_model("customers", "CustomerProfile")
sales = OrganizationalUnit.objects.filter(slug="sales").first()
if sales is None or not CustomerProfile.objects.exists():
return
group, _ = ContactGroup.objects.get_or_create(
unit=sales,
name="مخاطبان فروش",
defaults={"description": "گروه پیش‌فرض مخاطبان موجود پیش از راه‌اندازی دفترچه سازمانی"},
)
group.contacts.add(*CustomerProfile.objects.filter(groups__isnull=True))
class Migration(migrations.Migration):
dependencies = [("tickets", "0005_bootstrap_legacy_staff_unit")]
operations = [migrations.RunPython(assign_legacy_contacts, migrations.RunPython.noop)]