initial commit

This commit is contained in:
2025-08-05 10:26:39 +05:00
commit b7412bbef6
298 changed files with 10533 additions and 0 deletions

View File

@@ -0,0 +1,347 @@
# Generated by Django 5.2.4 on 2025-08-01 09:53
import core.apps.contracts.validators.attached_files
import core.apps.contracts.validators.owners
import django.core.validators
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="LegalEntityModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"name",
models.CharField(
max_length=255,
validators=[core.apps.contracts.validators.owners.name_validator],
verbose_name="Name",
),
),
("role", models.CharField(verbose_name="Role")),
(
"bin_code",
models.CharField(
blank=True,
max_length=14,
null=True,
validators=[core.apps.contracts.validators.owners.bin_code_validator],
verbose_name="BIN code",
),
),
("identifier", models.CharField(blank=True, max_length=255, null=True, verbose_name="Identifier")),
(
"phone",
models.CharField(
max_length=25,
validators=[
django.core.validators.RegexValidator(
message="Enter a valid international phone number (E.164 format, e.g., +14155552671).",
regex="^\\+?[1-9]\\d{1,14}$",
)
],
verbose_name="Phone",
),
),
],
options={
"verbose_name": "Legal Entity",
"verbose_name_plural": "Legal Entities",
"db_table": "legal_entities",
},
),
migrations.CreateModel(
name="ContractModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"name",
models.CharField(
max_length=255,
validators=[
django.core.validators.RegexValidator(
message="Enter a valid contract name. Use letters, numbers, spaces, and limited punctuation (e.g., &, -, (), ., ', \"). Length must be 3 to 100 characters.",
regex="^[A-Za-z0-9À-ÿ&()\\-.,'\\\" ]{3,100}$",
)
],
verbose_name="name",
),
),
("identifier", models.CharField(verbose_name="Identifier")),
("allow_add_files", models.BooleanField(default=False)),
("allow_delete_files", models.BooleanField(default=False)),
],
options={
"verbose_name": "Contract",
"verbose_name_plural": "Contracts",
"db_table": "contracts",
"indexes": [models.Index(fields=["name"], name="contracts_name_inx")],
},
),
migrations.CreateModel(
name="ContractAttachedFileModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"name",
models.CharField(
max_length=150,
validators=[
django.core.validators.MinLengthValidator(
3, message="File name must be at least 3 characters long."
),
django.core.validators.MaxLengthValidator(
150, message="File name must be at most 150 characters long."
),
core.apps.contracts.validators.attached_files.starts_with_letter_validator,
django.core.validators.RegexValidator(
code="invalid_characters",
message="File name can only contain letters, digits, spaces, dots, underscores, or hyphens.",
regex="^[A-Za-z0-9\\s._-]+$",
),
],
verbose_name="name",
),
),
("allow_pdf", models.BooleanField(default=True)),
("allow_word", models.BooleanField(default=True)),
("allow_image", models.BooleanField(default=True)),
(
"contract",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="attached_files",
to="contracts.contractmodel",
verbose_name="Contract",
),
),
],
options={
"verbose_name": "Contract Attached File",
"verbose_name_plural": "Contract Attached Files",
"db_table": "contract_attached_files",
"unique_together": {("name", "contract")},
},
),
migrations.CreateModel(
name="ContractOwnerModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"status",
models.CharField(
blank=True,
choices=[("accepted", "Accepted"), ("rejected", "Rejected"), ("pending", "Pending")],
default="pending",
max_length=255,
verbose_name="Owner Status",
),
),
(
"contract",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="owners",
to="contracts.contractmodel",
verbose_name="Contract",
),
),
],
options={
"verbose_name": "Contract Owner",
"verbose_name_plural": "Contract Owners",
"db_table": "contract_owners",
},
),
migrations.CreateModel(
name="ContractFileContentModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
("document", models.FileField(upload_to="", verbose_name="Document")),
(
"file",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="contents",
to="contracts.contractattachedfilemodel",
verbose_name="File",
),
),
(
"contract_owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="contracts.contractownermodel",
verbose_name="Contract Owner",
),
),
],
options={
"verbose_name": "Contract File Content",
"verbose_name_plural": "Contract File Contents",
"db_table": "contract_file_contents",
},
),
migrations.CreateModel(
name="IndividualModel",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="Created At")),
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Updated At")),
(
"full_name",
models.CharField(
max_length=512,
validators=[
django.core.validators.RegexValidator(
message="Invalid Full Name, Please enter Full Name in the format: <first name> <last name> <father name>",
regex="^[A-Z][a-z]+ [A-Z][a-z]+ [A-Z][a-z]+$",
)
],
verbose_name="name",
),
),
(
"iin_code",
models.CharField(
blank=True,
max_length=14,
null=True,
unique=True,
validators=[
django.core.validators.RegexValidator(
code="invalid_iin",
message="IIN code must consist of exactly 14 digits.",
regex="^\\d{14}$",
)
],
verbose_name="IIN code",
),
),
(
"person_code",
models.CharField(
blank=True,
max_length=64,
null=True,
unique=True,
validators=[
django.core.validators.RegexValidator(
code="invalid_person_code",
message="Person Code must be 3 to 64 characters long and contain only letters, digits, dashes, or underscores.",
regex="^[A-Za-z0-9_-]{3,64}$",
)
],
verbose_name="Person Code (if no IIN code)",
),
),
(
"phone",
models.CharField(
validators=[
django.core.validators.RegexValidator(
message="Enter a valid international phone number (E.164 format, e.g., +14155552671).",
regex="^\\+?[1-9]\\d{1,14}$",
)
],
verbose_name="Phone",
),
),
("use_face_id", models.BooleanField(default=False, verbose_name="Use FaceID")),
],
options={
"verbose_name": "Individual",
"verbose_name_plural": "Individuals",
"db_table": "individuals",
"indexes": [
models.Index(fields=["full_name"], name="individuals_fullname_inx"),
models.Index(fields=["iin_code"], name="individuals_iin_inx"),
models.Index(fields=["person_code"], name="individuals_code_inx"),
models.Index(fields=["phone"], name="individuals_phone_inx"),
],
},
),
migrations.AddField(
model_name="contractownermodel",
name="individual",
field=models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="owner",
to="contracts.individualmodel",
verbose_name="Individual",
),
),
migrations.AddField(
model_name="contractownermodel",
name="legal_entity",
field=models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="owner",
to="contracts.legalentitymodel",
verbose_name="Legal Entity",
),
),
migrations.AddConstraint(
model_name="contractownermodel",
constraint=models.UniqueConstraint(fields=("individual", "contract"), name="unique_individual_contract"),
),
migrations.AddConstraint(
model_name="contractownermodel",
constraint=models.UniqueConstraint(
fields=("legal_entity", "contract"), name="unique_legal_entity_contract"
),
),
]