From 778cd16a2024c4ae238a4b390cb46fbd99727845 Mon Sep 17 00:00:00 2001 From: Pawan Verma Date: Thu, 9 Jan 2025 20:58:55 +0530 Subject: [PATCH 1/2] Add created date to UserVisit and CompletedWork --- ...ork_date_created_uservisit_date_created.py | 25 +++++++++++++++++++ commcare_connect/opportunity/models.py | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py diff --git a/commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py b/commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py new file mode 100644 index 00000000..c8ddbbad --- /dev/null +++ b/commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.5 on 2025-01-09 15:24 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + dependencies = [ + ("opportunity", "0064_alter_completedwork_unique_together"), + ] + + operations = [ + migrations.AddField( + model_name="completedwork", + name="date_created", + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name="uservisit", + name="date_created", + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + ] diff --git a/commcare_connect/opportunity/models.py b/commcare_connect/opportunity/models.py index d15b7a28..c5f73992 100644 --- a/commcare_connect/opportunity/models.py +++ b/commcare_connect/opportunity/models.py @@ -454,6 +454,7 @@ class CompletedWork(models.Model): reason = models.CharField(max_length=300, null=True, blank=True) status_modified_date = models.DateTimeField(null=True) payment_date = models.DateTimeField(null=True) + date_created = models.DateTimeField(auto_now_add=True) class Meta: unique_together = ("opportunity_access", "entity_id", "payment_unit") @@ -576,6 +577,7 @@ class UserVisit(XFormBaseModel): ) review_created_on = models.DateTimeField(blank=True, null=True) justification = models.CharField(max_length=300, null=True, blank=True) + date_created = models.DateTimeField(auto_now_add=True) def __init__(self, *args, **kwargs): self.status = VisitValidationStatus.pending From 8d00a351320e2c0896b188e8c5012cc26f83b232 Mon Sep 17 00:00:00 2001 From: Pawan Verma Date: Fri, 10 Jan 2025 13:06:21 +0530 Subject: [PATCH 2/2] Fix migration sequence --- ...0066_completedwork_date_created_uservisit_date_created.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename commcare_connect/opportunity/migrations/{0065_completedwork_date_created_uservisit_date_created.py => 0066_completedwork_date_created_uservisit_date_created.py} (83%) diff --git a/commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py b/commcare_connect/opportunity/migrations/0066_completedwork_date_created_uservisit_date_created.py similarity index 83% rename from commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py rename to commcare_connect/opportunity/migrations/0066_completedwork_date_created_uservisit_date_created.py index c8ddbbad..646d160f 100644 --- a/commcare_connect/opportunity/migrations/0065_completedwork_date_created_uservisit_date_created.py +++ b/commcare_connect/opportunity/migrations/0066_completedwork_date_created_uservisit_date_created.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.5 on 2025-01-09 15:24 +# Generated by Django 4.2.5 on 2025-01-10 07:36 from django.db import migrations, models import django.utils.timezone @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ("opportunity", "0064_alter_completedwork_unique_together"), + ("opportunity", "0065_uservisit_unique_xform_entity_deliver_unit"), ] operations = [