43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
def copy_staff_mobile_to_voip(apps, schema_editor):
|
|
User = apps.get_model("accounts", "User")
|
|
User.objects.filter(account_type="STAFF", voip_mobile="", mobile__isnull=False).exclude(mobile="").update(
|
|
voip_mobile=models.F("mobile")
|
|
)
|
|
|
|
|
|
def clear_copied_voip_mobile(apps, schema_editor):
|
|
User = apps.get_model("accounts", "User")
|
|
User.objects.filter(account_type="STAFF", voip_mobile=models.F("mobile")).update(voip_mobile="")
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [("accounts", "0006_user_voip_call_user_voip_extension_and_more")]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="user",
|
|
name="voip_mobile",
|
|
field=models.CharField(
|
|
blank=True,
|
|
help_text="مستقل از شماره حساب مشتری است و میتواند تکراری باشد.",
|
|
max_length=16,
|
|
verbose_name="شماره موبایل کارشناس برای VOIP",
|
|
),
|
|
),
|
|
migrations.AlterField(
|
|
model_name="user",
|
|
name="mobile",
|
|
field=models.CharField(
|
|
blank=True,
|
|
max_length=16,
|
|
null=True,
|
|
unique=True,
|
|
verbose_name="شماره موبایل حساب",
|
|
),
|
|
),
|
|
migrations.RunPython(copy_staff_mobile_to_voip, clear_copied_voip_mobile),
|
|
]
|