fixup bootstrap script, make Product.slug unique
This commit is contained in:
parent
e95cc5ea93
commit
77141e7931
20
src/shop/migrations/0036_auto_20170319_2155.py
Normal file
20
src/shop/migrations/0036_auto_20170319_2155.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.5 on 2017-03-19 20:55
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('shop', '0035_auto_20170222_1629'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(unique=True),
|
||||||
|
),
|
||||||
|
]
|
20
src/shop/migrations/0037_auto_20170319_2204.py
Normal file
20
src/shop/migrations/0037_auto_20170319_2204.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.5 on 2017-03-19 21:04
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('shop', '0036_auto_20170319_2155'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(max_length=100, unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -253,7 +253,7 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
||||||
)
|
)
|
||||||
|
|
||||||
name = models.CharField(max_length=150)
|
name = models.CharField(max_length=150)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField(unique=True, max_length=100)
|
||||||
|
|
||||||
price = models.IntegerField(
|
price = models.IntegerField(
|
||||||
help_text=_('Price of the product (in DKK, including VAT).')
|
help_text=_('Price of the product (in DKK, including VAT).')
|
||||||
|
|
|
@ -9,6 +9,7 @@ from villages.models import Village
|
||||||
from program.models import EventType, Event, EventInstance, Speaker, EventLocation
|
from program.models import EventType, Event, EventInstance, Speaker, EventLocation
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from allauth.account.models import EmailAddress
|
from allauth.account.models import EmailAddress
|
||||||
|
from django.utils.text import slugify
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -174,10 +175,18 @@ class Command(BaseCommand):
|
||||||
name='Transportation',
|
name='Transportation',
|
||||||
slug='transportation'
|
slug='transportation'
|
||||||
)
|
)
|
||||||
merchendise = ProductCategory.objects.create(
|
merchandise = ProductCategory.objects.create(
|
||||||
name='Merchandise',
|
name='Merchandise',
|
||||||
slug='merchandise'
|
slug='merchandise'
|
||||||
)
|
)
|
||||||
|
tickets = ProductCategory.objects.create(
|
||||||
|
name='Tickets',
|
||||||
|
slug='tickets'
|
||||||
|
)
|
||||||
|
villages = ProductCategory.objects.create(
|
||||||
|
name='Villages',
|
||||||
|
slug='villages'
|
||||||
|
)
|
||||||
|
|
||||||
NewsItem.objects.create(
|
NewsItem.objects.create(
|
||||||
title='unpublished news item',
|
title='unpublished news item',
|
||||||
|
@ -1015,38 +1024,95 @@ programming for a danish startup.
|
||||||
)
|
)
|
||||||
|
|
||||||
self.output("Creating products for {}...".format(year))
|
self.output("Creating products for {}...".format(year))
|
||||||
|
name='PROSA bus transport (PROSA members only)'
|
||||||
Product.objects.create(
|
Product.objects.create(
|
||||||
|
name=name,
|
||||||
category=transportation,
|
category=transportation,
|
||||||
name='PROSA bus transport (open for everyone)',
|
|
||||||
slug='prosa-bus',
|
|
||||||
price=125,
|
price=125,
|
||||||
description='PROSA is sponsoring a bustrip from Copenhagen to the venue and back.',
|
description='PROSA is sponsoring a bustrip from Copenhagen to the venue and back.',
|
||||||
available_in=(
|
available_in=(
|
||||||
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
||||||
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
Product.objects.create(
|
|
||||||
category=transportation,
|
|
||||||
name='PROSA bus transport (open for everyone)',
|
name='PROSA bus transport (open for everyone)',
|
||||||
slug='prosa-bus',
|
Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
category=transportation,
|
||||||
price=125,
|
price=125,
|
||||||
description='PROSA is sponsoring a bustrip from Copenhagen to the venue and back.',
|
description='PROSA is sponsoring a bustrip from Copenhagen to the venue and back.',
|
||||||
available_in=(
|
available_in=(
|
||||||
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
||||||
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
Product.objects.create(
|
|
||||||
category=merchendise,
|
|
||||||
name='T-shirt (large)',
|
name='T-shirt (large)',
|
||||||
slug='t-shirt-large',
|
Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
category=merchandise,
|
||||||
price=160,
|
price=160,
|
||||||
description='Get a nice t-shirt',
|
description='Get a nice t-shirt',
|
||||||
available_in=(
|
available_in=(
|
||||||
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
timezone.datetime(year, 4, 30, 11, 0, tzinfo=timezone.utc),
|
||||||
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
timezone.datetime(year, 10, 30, 11, 30, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
name='Village tent 3x3 meters, no floor'
|
||||||
|
tent1 = Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
description='A description of the tent goes here',
|
||||||
|
price=3325,
|
||||||
|
category=villages,
|
||||||
|
available_in=(
|
||||||
|
timezone.datetime(year, 6, 1, 12, 0, tzinfo=timezone.utc),
|
||||||
|
timezone.datetime(year, 8, 20, 12, 0, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
|
),
|
||||||
|
|
||||||
|
name='Village tent 3x3 meters, with floor'
|
||||||
|
tent2 = Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
description='A description of the tent goes here',
|
||||||
|
price=3675,
|
||||||
|
category=villages,
|
||||||
|
available_in=(
|
||||||
|
timezone.datetime(year, 6, 1, 12, 0, tzinfo=timezone.utc),
|
||||||
|
timezone.datetime(year, 8, 20, 12, 0, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
|
)
|
||||||
|
|
||||||
|
name='Standard ticket'
|
||||||
|
ticket1 = Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
description='A ticket',
|
||||||
|
price=1200,
|
||||||
|
category=tickets,
|
||||||
|
available_in=(
|
||||||
|
timezone.datetime(year, 6, 1, 12, 0, tzinfo=timezone.utc),
|
||||||
|
timezone.datetime(year, 8, 20, 12, 0, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
|
)
|
||||||
|
|
||||||
|
name='Hacker ticket'
|
||||||
|
ticket2 = Product.objects.create(
|
||||||
|
name=name,
|
||||||
|
description='Another ticket',
|
||||||
|
price=1337,
|
||||||
|
category=tickets,
|
||||||
|
available_in=(
|
||||||
|
timezone.datetime(year, 6, 1, 12, 0, tzinfo=timezone.utc),
|
||||||
|
timezone.datetime(year, 8, 20, 12, 0, tzinfo=timezone.utc),
|
||||||
|
),
|
||||||
|
slug='%s-%s' % (camp.slug, slugify(name)),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.output("Creating infocategories for {}...".format(year))
|
self.output("Creating infocategories for {}...".format(year))
|
||||||
|
@ -1175,6 +1241,7 @@ Please note that sleeping in the parking lot is not permitted. If you want to sl
|
||||||
description='This village is representing TheCamp.dk, an annual danish tech camp held in July. The official subjects for this event is open source software, network and security. In reality we are interested in anything from computers to illumination soap bubbles and irish coffee'
|
description='This village is representing TheCamp.dk, an annual danish tech camp held in July. The official subjects for this event is open source software, network and security. In reality we are interested in anything from computers to illumination soap bubbles and irish coffee'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.output("marking 2016 as read_only...")
|
||||||
camp2016.read_only = True
|
camp2016.read_only = True
|
||||||
camp2016.save()
|
camp2016.save()
|
||||||
self.output("done!")
|
self.output("done!")
|
||||||
|
|
Loading…
Reference in a new issue