Ejemplo n.º 1
0
    def updated_profile(self, user):
        user.username = self.username.data
        user.email = self.email.data

        if self.password.data:
            user.password = self.password.data
        if user.company_detail:
            company = user.company_detail
        else:
            company = Company()
            company.user_id = user.id

        if self.slug.data:
            company.slug = self.slug.data
        if self.location.data:
            company.location = self.location.data
        if self.site.data:
            company.site = self.site.data
        if self.logo.data:
            company.logo = self.logo.data
        if self.description.data:
            company.description = self.description.data
        if self.about.data:
            company.about = self.about.data

        db.session.add(user)
        db.session.add(company)
        db.session.commit()
Ejemplo n.º 2
0
    def update(self, company):
        company.name = self.name.data
        company.email = self.email.data
        company.mobile = self.mobile.data

        if self.password.data:
            company.password = self.password.data

        if company.company_detail:
            company_detail = company.company_detail
        else:
            company_detail = Company()
            company_detail.user_id = company.id
        company_detail.site = self.site.data
        company_detail.description = self.description.data
        db.session.add(company)
        db.session.add(company_detail)
        db.session.commit()