update link registration site to executive dashboard
This commit is contained in:
1 parent
1e6f6b3b57
commit
d0d1ae7d24
26 files changed
+1044
-55
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# Move pusat registration fields onto sites; drop pusat_registrations.
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def forwards_copy_registrations(apps, schema_editor):
|
||||
Site = apps.get_model("farms", "Site")
|
||||
PusatRegistration = apps.get_model("farms", "PusatRegistration")
|
||||
for row in PusatRegistration.objects.select_related("site").all():
|
||||
site = row.site
|
||||
site.pusat_code = row.code or ""
|
||||
site.pusat_active_site_id = row.active_site_id
|
||||
site.pusat_registered_at = row.registered_at
|
||||
site.save(
|
||||
update_fields=[
|
||||
"pusat_code",
|
||||
"pusat_active_site_id",
|
||||
"pusat_registered_at",
|
||||
"updated_at",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def noop_reverse(apps, schema_editor):
|
||||
raise RuntimeError("Cannot reverse pusat fields onto sites.")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("farms", "0018_site_id_numeric_suffix"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="site",
|
||||
name="pusat_code",
|
||||
field=models.SlugField(blank=True, default="", max_length=64),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="site",
|
||||
name="pusat_active_site_id",
|
||||
field=models.BigIntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="site",
|
||||
name="pusat_registered_at",
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
migrations.RunPython(forwards_copy_registrations, noop_reverse),
|
||||
migrations.DeleteModel(name="PusatRegistration"),
|
||||
]
|
||||
Reference in new issue
Block a user