#!/usr/bin/env python
from wsgi import *
from django.contrib.auth.models import User


print("get or create admin user")
u, created = User.objects.get_or_create(username="admin")
if created or u.password == "":
    u.set_password("password")
    u.is_superuser = True
    u.is_staff = True
    u.save()
    print("Created the admin user")
else:
    print(u)
    print("Admin already created")

print("Check site")
from django.contrib.sites.models import Site

site = Site.objects.get(pk=1)
if site.name != "dotcloud":
    print("site name is wrong it is {0}. fixing it".format(site.name))
    site.name = "dotcloud"
    site.domain = "pbpstore-johncosta.dotcloud.com"
    site.save()
print("done fixing the site")
