updating cycle close request feature to get approval from national dashboard instead auto from system

This commit is contained in:
Alberto-Audrix committed 2026-09-09 14:18:39 +07:00
1 parent 3a868cf1db
commit e4dbfd0252
31 files changed
+1322 -182

No files matched your search

@@ -0,0 +1,78 @@
# Generated manually for GM cycle-close approval request flow
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
def null_end_dates_for_open_cycles(apps, schema_editor):
Cycle = apps.get_model("farms", "Cycle")
Cycle.objects.filter(status="active").update(end_date=None)
class Migration(migrations.Migration):
dependencies = [
("farms", "0014_kandang_feed_in_button_urls"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.RemoveConstraint(
model_name="cycle",
name="chk_cycles_date_range",
),
migrations.AlterField(
model_name="cycle",
name="end_date",
field=models.DateField(blank=True, null=True),
),
migrations.AlterField(
model_name="cycle",
name="total_days",
field=models.IntegerField(default=1),
),
migrations.AlterField(
model_name="cycle",
name="status",
field=models.CharField(
choices=[
("active", "Active"),
("pending_close", "Pending close"),
("closed", "Closed"),
],
db_index=True,
default="active",
max_length=30,
),
),
migrations.AddField(
model_name="cycle",
name="proposed_end_date",
field=models.DateField(blank=True, null=True),
),
migrations.AddField(
model_name="cycle",
name="close_requested_at",
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name="cycle",
name="close_requested_by",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="requested_cycle_closes",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AddConstraint(
model_name="cycle",
constraint=models.CheckConstraint(
condition=models.Q(("end_date__isnull", True))
| models.Q(("end_date__gte", models.F("start_date"))),
name="chk_cycles_date_range",
),
),
migrations.RunPython(null_end_dates_for_open_cycles, migrations.RunPython.noop),
]