bottleneckcrm/backend/leads/migrations/0001_initial.py

628 lines
26 KiB
Python

# Generated by Django 5.2.8 on 2025-11-27 12:17
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("common", "0001_initial"),
("contacts", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Company",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("name", models.CharField(blank=True, max_length=100, null=True)),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="companies",
to="common.org",
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Company",
"verbose_name_plural": "Companies",
"db_table": "company",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="Lead",
fields=[
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Last Modified At"
),
),
(
"id",
models.UUIDField(
db_index=True,
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
unique=True,
),
),
("title", models.CharField(max_length=64, verbose_name="Title")),
(
"first_name",
models.CharField(
max_length=255, null=True, verbose_name="First name"
),
),
(
"last_name",
models.CharField(
max_length=255, null=True, verbose_name="Last name"
),
),
("email", models.EmailField(blank=True, max_length=254, null=True)),
(
"phone",
models.CharField(blank=True, max_length=50, null=True),
),
(
"contact_title",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="Job Title"
),
),
(
"website",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="Website"
),
),
(
"linkedin_url",
models.URLField(
blank=True,
max_length=500,
null=True,
verbose_name="LinkedIn URL",
),
),
(
"status",
models.CharField(
blank=True,
choices=[
("assigned", "Assigned"),
("in process", "In Process"),
("converted", "Converted"),
("recycled", "Recycled"),
("closed", "Closed"),
],
max_length=255,
null=True,
verbose_name="Status",
),
),
(
"source",
models.CharField(
blank=True,
choices=[
("call", "Call"),
("email", "Email"),
("existing customer", "Existing Customer"),
("partner", "Partner"),
("public relations", "Public Relations"),
("compaign", "Campaign"),
("other", "Other"),
],
max_length=255,
null=True,
verbose_name="Source",
),
),
(
"industry",
models.CharField(
blank=True,
choices=[
("ADVERTISING", "ADVERTISING"),
("AGRICULTURE", "AGRICULTURE"),
("APPAREL & ACCESSORIES", "APPAREL & ACCESSORIES"),
("AUTOMOTIVE", "AUTOMOTIVE"),
("BANKING", "BANKING"),
("BIOTECHNOLOGY", "BIOTECHNOLOGY"),
(
"BUILDING MATERIALS & EQUIPMENT",
"BUILDING MATERIALS & EQUIPMENT",
),
("CHEMICAL", "CHEMICAL"),
("COMPUTER", "COMPUTER"),
("EDUCATION", "EDUCATION"),
("ELECTRONICS", "ELECTRONICS"),
("ENERGY", "ENERGY"),
("ENTERTAINMENT & LEISURE", "ENTERTAINMENT & LEISURE"),
("FINANCE", "FINANCE"),
("FOOD & BEVERAGE", "FOOD & BEVERAGE"),
("GROCERY", "GROCERY"),
("HEALTHCARE", "HEALTHCARE"),
("INSURANCE", "INSURANCE"),
("LEGAL", "LEGAL"),
("MANUFACTURING", "MANUFACTURING"),
("PUBLISHING", "PUBLISHING"),
("REAL ESTATE", "REAL ESTATE"),
("SERVICE", "SERVICE"),
("SOFTWARE", "SOFTWARE"),
("SPORTS", "SPORTS"),
("TECHNOLOGY", "TECHNOLOGY"),
("TELECOMMUNICATIONS", "TELECOMMUNICATIONS"),
("TELEVISION", "TELEVISION"),
("TRANSPORTATION", "TRANSPORTATION"),
("VENTURE CAPITAL", "VENTURE CAPITAL"),
],
max_length=255,
null=True,
verbose_name="Industry",
),
),
(
"rating",
models.CharField(
blank=True,
choices=[("HOT", "Hot"), ("WARM", "Warm"), ("COLD", "Cold")],
max_length=10,
null=True,
verbose_name="Rating",
),
),
(
"opportunity_amount",
models.DecimalField(
blank=True,
decimal_places=2,
max_digits=12,
null=True,
verbose_name="Deal Value",
),
),
(
"probability",
models.IntegerField(
blank=True,
default=0,
null=True,
verbose_name="Win Probability %",
),
),
(
"close_date",
models.DateField(
default=None, null=True, verbose_name="Expected Close Date"
),
),
(
"address_line",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="Address"
),
),
(
"city",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="City"
),
),
(
"state",
models.CharField(
blank=True, max_length=255, null=True, verbose_name="State"
),
),
(
"postcode",
models.CharField(
blank=True, max_length=64, null=True, verbose_name="Postal Code"
),
),
(
"country",
models.CharField(
blank=True,
choices=[
("GB", "United Kingdom"),
("AF", "Afghanistan"),
("AX", "Aland Islands"),
("AL", "Albania"),
("DZ", "Algeria"),
("AS", "American Samoa"),
("AD", "Andorra"),
("AO", "Angola"),
("AI", "Anguilla"),
("AQ", "Antarctica"),
("AG", "Antigua and Barbuda"),
("AR", "Argentina"),
("AM", "Armenia"),
("AW", "Aruba"),
("AU", "Australia"),
("AT", "Austria"),
("AZ", "Azerbaijan"),
("BS", "Bahamas"),
("BH", "Bahrain"),
("BD", "Bangladesh"),
("BB", "Barbados"),
("BY", "Belarus"),
("BE", "Belgium"),
("BZ", "Belize"),
("BJ", "Benin"),
("BM", "Bermuda"),
("BT", "Bhutan"),
("BO", "Bolivia"),
("BA", "Bosnia and Herzegovina"),
("BW", "Botswana"),
("BV", "Bouvet Island"),
("BR", "Brazil"),
("IO", "British Indian Ocean Territory"),
("BN", "Brunei Darussalam"),
("BG", "Bulgaria"),
("BF", "Burkina Faso"),
("BI", "Burundi"),
("KH", "Cambodia"),
("CM", "Cameroon"),
("CA", "Canada"),
("CV", "Cape Verde"),
("KY", "Cayman Islands"),
("CF", "Central African Republic"),
("TD", "Chad"),
("CL", "Chile"),
("CN", "China"),
("CX", "Christmas Island"),
("CC", "Cocos (Keeling) Islands"),
("CO", "Colombia"),
("KM", "Comoros"),
("CG", "Congo"),
("CD", "Congo, The Democratic Republic of the"),
("CK", "Cook Islands"),
("CR", "Costa Rica"),
("CI", "Cote d'Ivoire"),
("HR", "Croatia"),
("CU", "Cuba"),
("CY", "Cyprus"),
("CZ", "Czech Republic"),
("DK", "Denmark"),
("DJ", "Djibouti"),
("DM", "Dominica"),
("DO", "Dominican Republic"),
("EC", "Ecuador"),
("EG", "Egypt"),
("SV", "El Salvador"),
("GQ", "Equatorial Guinea"),
("ER", "Eritrea"),
("EE", "Estonia"),
("ET", "Ethiopia"),
("FK", "Falkland Islands (Malvinas)"),
("FO", "Faroe Islands"),
("FJ", "Fiji"),
("FI", "Finland"),
("FR", "France"),
("GF", "French Guiana"),
("PF", "French Polynesia"),
("TF", "French Southern Territories"),
("GA", "Gabon"),
("GM", "Gambia"),
("GE", "Georgia"),
("DE", "Germany"),
("GH", "Ghana"),
("GI", "Gibraltar"),
("GR", "Greece"),
("GL", "Greenland"),
("GD", "Grenada"),
("GP", "Guadeloupe"),
("GU", "Guam"),
("GT", "Guatemala"),
("GG", "Guernsey"),
("GN", "Guinea"),
("GW", "Guinea-Bissau"),
("GY", "Guyana"),
("HT", "Haiti"),
("HM", "Heard Island and McDonald Islands"),
("VA", "Holy See (Vatican City State)"),
("HN", "Honduras"),
("HK", "Hong Kong"),
("HU", "Hungary"),
("IS", "Iceland"),
("IN", "India"),
("ID", "Indonesia"),
("IR", "Iran, Islamic Republic of"),
("IQ", "Iraq"),
("IE", "Ireland"),
("IM", "Isle of Man"),
("IL", "Israel"),
("IT", "Italy"),
("JM", "Jamaica"),
("JP", "Japan"),
("JE", "Jersey"),
("JO", "Jordan"),
("KZ", "Kazakhstan"),
("KE", "Kenya"),
("KI", "Kiribati"),
("KP", "Korea, Democratic People's Republic of"),
("KR", "Korea, Republic of"),
("KW", "Kuwait"),
("KG", "Kyrgyzstan"),
("LA", "Lao People's Democratic Republic"),
("LV", "Latvia"),
("LB", "Lebanon"),
("LS", "Lesotho"),
("LR", "Liberia"),
("LY", "Libyan Arab Jamahiriya"),
("LI", "Liechtenstein"),
("LT", "Lithuania"),
("LU", "Luxembourg"),
("MO", "Macao"),
("MK", "Macedonia, The Former Yugoslav Republic of"),
("MG", "Madagascar"),
("MW", "Malawi"),
("MY", "Malaysia"),
("MV", "Maldives"),
("ML", "Mali"),
("MT", "Malta"),
("MH", "Marshall Islands"),
("MQ", "Martinique"),
("MR", "Mauritania"),
("MU", "Mauritius"),
("YT", "Mayotte"),
("MX", "Mexico"),
("FM", "Micronesia, Federated States of"),
("MD", "Moldova"),
("MC", "Monaco"),
("MN", "Mongolia"),
("ME", "Montenegro"),
("MS", "Montserrat"),
("MA", "Morocco"),
("MZ", "Mozambique"),
("MM", "Myanmar"),
("NA", "Namibia"),
("NR", "Nauru"),
("NP", "Nepal"),
("NL", "Netherlands"),
("AN", "Netherlands Antilles"),
("NC", "New Caledonia"),
("NZ", "New Zealand"),
("NI", "Nicaragua"),
("NE", "Niger"),
("NG", "Nigeria"),
("NU", "Niue"),
("NF", "Norfolk Island"),
("MP", "Northern Mariana Islands"),
("NO", "Norway"),
("OM", "Oman"),
("PK", "Pakistan"),
("PW", "Palau"),
("PS", "Palestinian Territory, Occupied"),
("PA", "Panama"),
("PG", "Papua New Guinea"),
("PY", "Paraguay"),
("PE", "Peru"),
("PH", "Philippines"),
("PN", "Pitcairn"),
("PL", "Poland"),
("PT", "Portugal"),
("PR", "Puerto Rico"),
("QA", "Qatar"),
("RE", "Reunion"),
("RO", "Romania"),
("RU", "Russian Federation"),
("RW", "Rwanda"),
("BL", "Saint Barthelemy"),
("SH", "Saint Helena"),
("KN", "Saint Kitts and Nevis"),
("LC", "Saint Lucia"),
("MF", "Saint Martin"),
("PM", "Saint Pierre and Miquelon"),
("VC", "Saint Vincent and the Grenadines"),
("WS", "Samoa"),
("SM", "San Marino"),
("ST", "Sao Tome and Principe"),
("SA", "Saudi Arabia"),
("SN", "Senegal"),
("RS", "Serbia"),
("SC", "Seychelles"),
("SL", "Sierra Leone"),
("SG", "Singapore"),
("SK", "Slovakia"),
("SI", "Slovenia"),
("SB", "Solomon Islands"),
("SO", "Somalia"),
("ZA", "South Africa"),
("GS", "South Georgia and the South Sandwich Islands"),
("ES", "Spain"),
("LK", "Sri Lanka"),
("SD", "Sudan"),
("SR", "Suriname"),
("SJ", "Svalbard and Jan Mayen"),
("SZ", "Swaziland"),
("SE", "Sweden"),
("CH", "Switzerland"),
("SY", "Syrian Arab Republic"),
("TW", "Taiwan, Province of China"),
("TJ", "Tajikistan"),
("TZ", "Tanzania, United Republic of"),
("TH", "Thailand"),
("TL", "Timor-Leste"),
("TG", "Togo"),
("TK", "Tokelau"),
("TO", "Tonga"),
("TT", "Trinidad and Tobago"),
("TN", "Tunisia"),
("TR", "Turkey"),
("TM", "Turkmenistan"),
("TC", "Turks and Caicos Islands"),
("TV", "Tuvalu"),
("UG", "Uganda"),
("UA", "Ukraine"),
("AE", "United Arab Emirates"),
("US", "United States"),
("UM", "United States Minor Outlying Islands"),
("UY", "Uruguay"),
("UZ", "Uzbekistan"),
("VU", "Vanuatu"),
("VE", "Venezuela"),
("VN", "Viet Nam"),
("VG", "Virgin Islands, British"),
("VI", "Virgin Islands, U.S."),
("WF", "Wallis and Futuna"),
("EH", "Western Sahara"),
("YE", "Yemen"),
("ZM", "Zambia"),
("ZW", "Zimbabwe"),
],
max_length=3,
null=True,
verbose_name="Country",
),
),
(
"last_contacted",
models.DateField(
blank=True, null=True, verbose_name="Last Contacted"
),
),
(
"next_follow_up",
models.DateField(
blank=True, null=True, verbose_name="Next Follow-up"
),
),
(
"description",
models.TextField(blank=True, null=True, verbose_name="Notes"),
),
("is_active", models.BooleanField(default=True)),
("created_from_site", models.BooleanField(default=False)),
(
"assigned_to",
models.ManyToManyField(
related_name="lead_assigned_users", to="common.profile"
),
),
(
"company",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="lead_company",
to="leads.company",
),
),
(
"contacts",
models.ManyToManyField(
related_name="lead_contacts", to="contacts.contact"
),
),
(
"created_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_created_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Created By",
),
),
(
"org",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="leads",
to="common.org",
),
),
("tags", models.ManyToManyField(blank=True, to="common.tags")),
(
"teams",
models.ManyToManyField(
related_name="lead_teams", to="common.teams"
),
),
(
"updated_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="%(class)s_updated_by",
to=settings.AUTH_USER_MODEL,
verbose_name="Last Modified By",
),
),
],
options={
"verbose_name": "Lead",
"verbose_name_plural": "Leads",
"db_table": "lead",
"ordering": ("-created_at",),
"indexes": [
models.Index(fields=["status"], name="lead_status_e8cfda_idx"),
models.Index(fields=["source"], name="lead_source_b6a91c_idx"),
models.Index(
fields=["org", "-created_at"], name="lead_org_id_efd8ea_idx"
),
],
},
),
]