add feed in / out button page and also button to redirect to button page
This commit is contained in:
1 parent
07b8e2dc25
commit
b86bd7a2f4
17 files changed
+719
-28
No files matched your search
@@ -0,0 +1,15 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("farms", "0012_cycle_feed_initial_balance_date"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="kandang",
|
||||
name="feed_in_button_url",
|
||||
field=models.URLField(blank=True, default="", max_length=500),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def migrate_single_url_to_list(apps, schema_editor):
|
||||
Kandang = apps.get_model("farms", "Kandang")
|
||||
for kandang in Kandang.objects.exclude(feed_in_button_url="").exclude(feed_in_button_url__isnull=True):
|
||||
url = (kandang.feed_in_button_url or "").strip()
|
||||
if url:
|
||||
kandang.feed_in_button_urls = [{"label": "", "url": url}]
|
||||
kandang.save(update_fields=["feed_in_button_urls"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("farms", "0013_kandang_feed_in_button_url"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="kandang",
|
||||
name="feed_in_button_urls",
|
||||
field=models.JSONField(blank=True, default=list),
|
||||
),
|
||||
migrations.RunPython(migrate_single_url_to_list, migrations.RunPython.noop),
|
||||
migrations.RemoveField(
|
||||
model_name="kandang",
|
||||
name="feed_in_button_url",
|
||||
),
|
||||
]
|
||||
Reference in new issue
Block a user