Skip to content

Commit

Permalink
Add new fields to Channel model (#11713)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadewu committed Feb 6, 2023
1 parent 9568da5 commit d8852ab
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
23 changes: 23 additions & 0 deletions saleor/channel/migrations/0006_order_settings_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.16 on 2022-12-08 09:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("channel", "0005_channel_allocation_strategy"),
]

operations = [
migrations.AddField(
model_name="channel",
name="automatically_confirm_all_new_orders",
field=models.BooleanField(default=True, null=True),
),
migrations.AddField(
model_name="channel",
name="automatically_fulfill_non_shippable_gift_card",
field=models.BooleanField(default=True, null=True),
),
]
29 changes: 29 additions & 0 deletions saleor/channel/migrations/0007_order_settings_per_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.db import migrations


def set_order_settings(apps, schema_editor):
SiteSettings = apps.get_model("site", "SiteSettings")
Channel = apps.get_model("channel", "Channel")

site_settings = SiteSettings.objects.first()

Channel.objects.update(
automatically_confirm_all_new_orders=(
site_settings.automatically_confirm_all_new_orders
),
automatically_fulfill_non_shippable_gift_card=(
site_settings.automatically_fulfill_non_shippable_gift_card
),
)


class Migration(migrations.Migration):

dependencies = [
("channel", "0006_order_settings_fields"),
("site", "0032_gift_card_settings"),
]

operations = [
migrations.RunPython(set_order_settings, migrations.RunPython.noop),
]
5 changes: 5 additions & 0 deletions saleor/channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class Channel(models.Model):
choices=AllocationStrategy.CHOICES,
default=AllocationStrategy.PRIORITIZE_SORTING_ORDER,
)
automatically_confirm_all_new_orders = models.BooleanField(default=True, null=True)
automatically_fulfill_non_shippable_gift_card = models.BooleanField(
default=True,
null=True,
)

class Meta:
ordering = ("slug",)
Expand Down

0 comments on commit d8852ab

Please sign in to comment.