# Generated by Django 4.2.24 on 2026-02-23 08:57

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import phonenumber_field.modelfields
import testimonials.utils
import testimonials.validators


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="TestimonialCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        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(
                        db_index=True,
                        help_text="Name of the testimonial category (e.g., Products, Services, Events).",
                        max_length=100,
                        verbose_name="Name",
                    ),
                ),
                (
                    "slug",
                    models.SlugField(
                        help_text="Unique identifier for the category, used in URLs.",
                        max_length=120,
                        unique=True,
                        verbose_name="Slug",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        help_text="Optional description providing more details about this category.",
                        verbose_name="Description",
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        db_index=True,
                        default=True,
                        help_text="If checked, this category is active and can be assigned to testimonials.",
                        verbose_name="Is Active",
                    ),
                ),
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True,
                        default=0,
                        help_text="Controls the display order of categories. Lower numbers appear first.",
                        verbose_name="Order",
                    ),
                ),
            ],
            options={
                "verbose_name": "Testimonial Category",
                "verbose_name_plural": "Testimonial Categories",
                "ordering": ["order", "name"],
                "indexes": [
                    models.Index(
                        fields=["is_active", "order"],
                        name="testimonial_is_acti_bef2c4_idx",
                    ),
                    models.Index(fields=["name"], name="testimonial_name_ec3791_idx"),
                    models.Index(fields=["slug"], name="testimonial_slug_0a0a7b_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="Testimonial",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        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"),
                ),
                (
                    "author_name",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text="Full name of the testimonial author if not linked to a user account.",
                        max_length=255,
                        verbose_name="Author Name",
                    ),
                ),
                (
                    "author_email",
                    models.EmailField(
                        blank=True,
                        db_index=True,
                        help_text="Email address of the testimonial author. Useful for verification or follow-up communication.",
                        max_length=254,
                        verbose_name="Author Email",
                    ),
                ),
                (
                    "author_phone",
                    phonenumber_field.modelfields.PhoneNumberField(
                        blank=True,
                        help_text="Optional phone number of the testimonial author.",
                        max_length=128,
                        region="NG",
                        verbose_name="Author Phone",
                    ),
                ),
                (
                    "author_title",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("CEO", "CEO"),
                            ("CTO", "CTO"),
                            ("CFO", "CFO"),
                            ("COO", "COO"),
                            ("President", "President"),
                            ("Vice President", "Vice President"),
                            ("Executive Director", "Executive Director"),
                            ("Founder", "Founder"),
                            ("Co-Founder", "Co-Founder"),
                            ("Director", "Director"),
                            ("Senior Director", "Senior Director"),
                            ("Manager", "Manager"),
                            ("Senior Manager", "Senior Manager"),
                            ("Project Manager", "Project Manager"),
                            ("Product Manager", "Product Manager"),
                            ("Team Lead", "Team Lead"),
                            ("Department Head", "Department Head"),
                            ("Senior Consultant", "Senior Consultant"),
                            ("Consultant", "Consultant"),
                            ("Specialist", "Specialist"),
                            ("Analyst", "Analyst"),
                            ("Coordinator", "Coordinator"),
                            ("Supervisor", "Supervisor"),
                            ("Senior Developer", "Senior Developer"),
                            ("Software Engineer", "Software Engineer"),
                            ("Lead Developer", "Lead Developer"),
                            ("Architect", "Architect"),
                            ("Technical Lead", "Technical Lead"),
                            ("Marketing Manager", "Marketing Manager"),
                            ("Sales Manager", "Sales Manager"),
                            ("Account Manager", "Account Manager"),
                            (
                                "Business Development Manager",
                                "Business Development Manager",
                            ),
                            ("Professor", "Professor"),
                            ("Dr.", "Dr."),
                            ("Attorney", "Attorney"),
                            ("Principal", "Principal"),
                            ("Customer", "Customer"),
                            ("Client", "Client"),
                            ("User", "User"),
                            ("Member", "Member"),
                            ("Other", "Other"),
                        ],
                        help_text="Professional title or role of the testimonial author.",
                        max_length=255,
                        verbose_name="Author Title",
                    ),
                ),
                (
                    "company",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text="Company or organization associated with the author, if applicable.",
                        max_length=255,
                        verbose_name="Company",
                    ),
                ),
                (
                    "location",
                    models.CharField(
                        blank=True,
                        help_text="Geographical location of the testimonial author.",
                        max_length=255,
                        verbose_name="Location",
                    ),
                ),
                (
                    "avatar",
                    models.ImageField(
                        blank=True,
                        help_text="Profile picture of the testimonial author.",
                        null=True,
                        upload_to=testimonials.utils.generate_upload_path,
                        validators=[
                            testimonials.validators.validate_avatar_size,
                            testimonials.validators.image_dimension_validator,
                        ],
                        verbose_name="Avatar",
                    ),
                ),
                (
                    "title",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text="Short descriptive title for the testimonial.",
                        max_length=255,
                        verbose_name="Title",
                    ),
                ),
                (
                    "content",
                    models.TextField(
                        help_text="Full testimonial text provided by the author.",
                        validators=[
                            testimonials.validators.validate_testimonial_content
                        ],
                        verbose_name="Content",
                    ),
                ),
                (
                    "rating",
                    models.PositiveSmallIntegerField(
                        db_index=True,
                        help_text="Rating score given by the author, from 1 to 5 stars.",
                        validators=[testimonials.validators.validate_rating],
                        verbose_name="Rating",
                    ),
                ),
                (
                    "source",
                    models.CharField(
                        choices=[
                            ("website", "Website"),
                            ("mobile_app", "Mobile App"),
                            ("email", "Email"),
                            ("third_party", "Third Party"),
                            ("social_media", "Social Media"),
                            ("other", "Other"),
                        ],
                        db_index=True,
                        default="website",
                        help_text="Origin of the testimonial (e.g., Website, Mobile Apple, Email ).",
                        max_length=30,
                        verbose_name="Source",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending", "Pending"),
                            ("approved", "Approved"),
                            ("rejected", "Rejected"),
                            ("featured", "Featured"),
                            ("archived", "Archived"),
                        ],
                        db_index=True,
                        default="pending",
                        help_text="Moderation status of the testimonial.",
                        max_length=30,
                        verbose_name="Status",
                    ),
                ),
                (
                    "is_anonymous",
                    models.BooleanField(
                        db_index=True, default=False, verbose_name="Is Anonymous"
                    ),
                ),
                (
                    "is_verified",
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text="Indicates whether this testimonial has been verified by an admin.",
                        verbose_name="Is Verified",
                    ),
                ),
                (
                    "display_order",
                    models.PositiveIntegerField(
                        db_index=True,
                        default=0,
                        help_text="Controls the order in which testimonials are displayed. Lower numbers appear first.",
                        verbose_name="Display Order",
                    ),
                ),
                (
                    "slug",
                    models.SlugField(
                        blank=True,
                        help_text="Unique slug used for testimonial URLs.",
                        max_length=255,
                        unique=True,
                        verbose_name="Slug",
                    ),
                ),
                (
                    "ip_address",
                    models.GenericIPAddressField(
                        blank=True,
                        help_text="IP address from which the testimonial was submitted.",
                        null=True,
                        verbose_name="IP Address",
                    ),
                ),
                (
                    "website",
                    models.URLField(
                        blank=True,
                        help_text="Optional website link provided by the testimonial author.",
                        verbose_name="Website",
                    ),
                ),
                (
                    "social_media",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Links to the author's social media profiles (JSON format).",
                        null=True,
                        verbose_name="Social Media",
                    ),
                ),
                (
                    "approved_at",
                    models.DateTimeField(
                        blank=True,
                        db_index=True,
                        help_text="Date and time when the testimonial was approved.",
                        null=True,
                        verbose_name="Approved At",
                    ),
                ),
                (
                    "rejection_reason",
                    models.TextField(
                        blank=True,
                        help_text="Reason provided for rejecting the testimonial, if applicable.",
                        verbose_name="Rejection Reason",
                    ),
                ),
                (
                    "response",
                    models.TextField(
                        blank=True,
                        help_text="Official response from the admin or company to this testimonial.",
                        verbose_name="Response",
                    ),
                ),
                (
                    "response_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="Date and time when a response was made.",
                        null=True,
                        verbose_name="Response At",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Optional JSON field for storing additional metadata related to the testimonial. Use this for custom attributes or integration-specific information.",
                        null=True,
                        verbose_name="Extra Data",
                    ),
                ),
                (
                    "approved_by",
                    models.ForeignKey(
                        blank=True,
                        help_text="Admin user who approved this testimonial.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="approved_testimonials",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Approved By",
                    ),
                ),
                (
                    "author",
                    models.ForeignKey(
                        blank=True,
                        help_text="Registered user who submitted the testimonial. Optional if testimonial is provided by a guest.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="testimonials",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        blank=True,
                        help_text="Category under which this testimonial is grouped.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="testimonials",
                        to="testimonials.testimonialcategory",
                        verbose_name="Category",
                    ),
                ),
                (
                    "response_by",
                    models.ForeignKey(
                        blank=True,
                        help_text="Admin user who responded to the testimonial.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="testimonial_responses",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Response By",
                    ),
                ),
            ],
            options={
                "verbose_name": "Testimonial",
                "verbose_name_plural": "Testimonials",
                "ordering": ["-display_order", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="TestimonialMedia",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        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"),
                ),
                (
                    "file",
                    models.FileField(
                        help_text="Upload the media file.",
                        upload_to=testimonials.utils.generate_upload_path,
                        validators=[testimonials.validators.validate_media_file_size],
                        verbose_name="File",
                    ),
                ),
                (
                    "media_type",
                    models.CharField(
                        choices=[
                            ("image", "Image"),
                            ("video", "Video"),
                            ("audio", "Audio"),
                            ("document", "Document"),
                        ],
                        db_index=True,
                        default="image",
                        help_text="Type of media (e.g., image, video, document).",
                        max_length=20,
                        verbose_name="Media Type",
                    ),
                ),
                (
                    "title",
                    models.CharField(
                        blank=True,
                        help_text="Optional short title for the media file.",
                        max_length=255,
                        verbose_name="Title",
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True,
                        help_text="Optional description or caption for the media file.",
                        verbose_name="Description",
                    ),
                ),
                (
                    "is_primary",
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text="Mark this as the primary or featured media for the testimonial.",
                        verbose_name="Is Primary",
                    ),
                ),
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True,
                        default=0,
                        help_text="Display order of the media files. Lower numbers are shown first.",
                        verbose_name="Order",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Optional JSON field for storing additional metadata, such as thumbnails, dimensions, or custom attributes.",
                        null=True,
                        verbose_name="Extra Data",
                    ),
                ),
                (
                    "testimonial",
                    models.ForeignKey(
                        help_text="The testimonial this media file is attached to. Deleting the testimonial will also delete its media files.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="media",
                        to="testimonials.testimonial",
                        verbose_name="Testimonial",
                    ),
                ),
            ],
            options={
                "verbose_name": "Testimonial Media",
                "verbose_name_plural": "Testimonial Media",
                "ordering": ["-is_primary", "order", "-created_at"],
                "indexes": [
                    models.Index(
                        fields=["testimonial", "is_primary"],
                        name="testimonial_testimo_183b0d_idx",
                    ),
                    models.Index(
                        fields=["media_type"], name="testimonial_media_t_ca1e9e_idx"
                    ),
                    models.Index(
                        fields=["is_primary", "order"],
                        name="testimonial_is_prim_d29134_idx",
                    ),
                    models.Index(
                        fields=["testimonial", "media_type"],
                        name="testimonial_testimo_7043a1_idx",
                    ),
                ],
            },
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(fields=["status"], name="testimonial_status_c6beca_idx"),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(fields=["rating"], name="testimonial_rating_c196fb_idx"),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["author_name"], name="testimonial_author__3e7554_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["created_at"], name="testimonial_created_f9dacc_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["approved_at"], name="testimonial_approve_81209c_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["display_order"], name="testimonial_display_a74a5a_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["is_anonymous"], name="testimonial_is_anon_24a3ee_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["is_verified"], name="testimonial_is_veri_a59c61_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["status", "created_at"], name="testimonial_status_a11574_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["status", "rating"], name="testimonial_status_947f08_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["status", "display_order"], name="testimonial_status_eee89a_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["category", "status"], name="testimonial_categor_f29720_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["author", "status"], name="testimonial_author__689f6a_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["rating", "created_at"], name="testimonial_rating_de5606_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="testimonial",
            index=models.Index(
                fields=["is_verified", "status"], name="testimonial_is_veri_c3220b_idx"
            ),
        ),
        migrations.AddConstraint(
            model_name="testimonial",
            constraint=models.CheckConstraint(
                check=models.Q(("rating__gte", 1), ("rating__lte", 5)),
                name="testimonial_rating_range",
            ),
        ),
        migrations.AddConstraint(
            model_name="testimonial",
            constraint=models.CheckConstraint(
                check=models.Q(
                    ("is_anonymous", True),
                    ("author_name", ""),
                    ("author_email", ""),
                    _negated=True,
                ),
                name="testimonial_author_info_required",
            ),
        ),
    ]
