# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2017-10-03 09:12
from __future__ import unicode_literals
import datetime

from django.db import migrations

from bluebottle.utils.utils import FSMTransition, StatusDefinition


def mark_as_failed(apps, schema_editor):
    Order = apps.get_model('orders', 'Order')

    orders = Order.objects.filter(
        status=StatusDefinition.CREATED,
        created__lte=datetime.date.today() - datetime.timedelta(days=5)
    )

    orders.update(status=StatusDefinition.FAILED)


class Migration(migrations.Migration):

    dependencies = [
        ('orders', '0004_add_group_permissions'),
    ]

    operations = [
        migrations.RunPython(mark_as_failed)
    ]

@@ -155,16 +155,50 @@
 grations
+%0Afrom django.utils import timezone
 %0A%0Afrom b
@@ -449,27 +449,20 @@
 lte=
-datetime.date.today
+timezone.now
 () -

Use localized dates