Add in the ability to add links to stores/chains.

This commit is contained in:
2013-04-03 23:14:14 +01:00
parent 850027f50d
commit f30f53204a
10 changed files with 401 additions and 7 deletions

View File

@@ -3,7 +3,8 @@ import requests
from StringIO import StringIO
from django.db import transaction
from django.core.management.base import BaseCommand, CommandError
from stores.models import Country, County, Address, Store
from stores.models import Country, County, Address, Store, Link, LinkType
from django.contrib.contenttypes.models import ContentType
class Command(BaseCommand):
@@ -40,6 +41,10 @@ class Command(BaseCommand):
if website:
store.store_type = Store.STORE_TYPE_BOTH
store.save()
if twitter:
Link(object_id=store.pk, object_type=ContentType.objects.get_for_model(store.__class__), account_type=LinkType.objects.get(name='Twitter'), account_name=twitter.split('/')[-1]).save()
#if facebook:
# Link(object_id=store.pk, object_type=ContentType.objects.get_for_model(store.__class__), account_type=LinkType.objects.get(name='Facebook'), account_name=facebook).save()
self.stdout.write("Done\n")
f.close()