Exemple #1
0
    def provision(self):
        ent = Enterprise()
        ent.bind(self.request.POST, True, 'ent')
        ent.save()
        ent.flush()

        comp = Company()
        comp.bind(self.request.POST, True, 'cmp')
        comp.enterprise_id = ent.enterprise_id
        comp.save()
        comp.flush()

        campaign = Campaign()
        campaign.name = comp.name + ' Default'
        campaign.company_id = comp.company_id
        campaign.save()
        campaign.flush()

        comp.default_campaign_id = campaign.campaign_id
        comp.save()
        comp.flush()

        user = Users()
        user.bind(self.request.POST, True, 'u')
        user.password = Users.encode_password('password')
        user.enterprise_id = ent.enterprise_id
        user.type = 'Admin'
        user.save()
        user.flush()

        site = Site()
        site.bind(self.request.POST, True, 'st')
        site.company = comp
        site.description = comp.name + ' Site'
        site.creator = user
        #site.template = Template.find_by_name('default')
        site.save()
        site.flush()

        return {
            'enterprise' : ent,
            'company' : comp,
            'campaign' : campaign,
            'user' : user,
            'site' : site,
            'done' : True
            }