'Creates users, webapps and installed records. Outputs the receipts
and created records into the supplied directory.'

def create(self):

    created = {'users': [], 'webapps': [], 'installed': []}
    number = self.number
    stamp = str(time.time())
    for x in xrange(number):
        name = ('generate-receipt-%s-%s' % (stamp, x))
        user = UserProfile.objects.create(email=('%s@mozilla.com' % name))
        created['users'].append(user.pk)
    for x in xrange(number):
        name = ('generate-receipt-%s-%s' % (stamp, x))
        addon = Webapp.objects.create(name=name, manifest_url='http://a.com/m.webapp')
        created['webapps'].append(addon.pk)
    for x in xrange(number):
        installed = Installed.objects.create(addon_id=created['webapps'][x], user_id=created['users'][x])
        created['installed'].append(installed.pk)
        filename = self.filename(('%s.%s.receipt' % (created['webapps'][x], x)))
        open(filename, 'w').write(installed.receipt)
    open(self.filename('created.json'), 'w').write(json.dumps(created))
