Exemplo n.º 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
            }
Exemplo n.º 2
0
    def save(self):
        comp = Company.load(self.request.POST.get('company_id'))
        if not comp:
            comp = Company()
        comp.bind(self.request.POST)
        comp.save()
        comp.flush()
        #if not os.path.isdir(comp.web_full_directory):
        #    comp.create_dir_structure()
        comp.clear_attributes()
        for i in range(10):
            attr_name = self.request.POST.get('attr_name[%d]' % i)
            attr_value = self.request.POST.get('attr_value[%d]' % i)
            if attr_name and attr_value:
                comp.set_attr(attr_name, attr_value)

        self.request.session.flash('Successfully saved %s.' % comp.name)
        return HTTPFound('/crm/company/edit/%s' % comp.company_id)