Example #1
0
 def update(self):
     try:
         get_plan = Plan.get(name=self.name)
         plan = Plan.update(
             name=self.name, price=self.price,
             quantity=self.quantity).where(Plan.name == get_plan.name)
         plan.execute()
         return {"message": "Plan updated successfully"}
     except Plan.DoesNotExist:
         if Plan.DoesNotExist:
             return {"message": "Plan does not exist"}
Example #2
0
    def create(self):
        try:
            plan = Plan.get(id=self.plan)
            customer = Customer.create(name=self.name,
                                       password=self.password,
                                       email_address=self.email,
                                       plan=plan.id,
                                       renewal_date=self.renewal_date)
            customer.save()
        except IntegrityError:

            return {"message": "Customer already exist"}
        else:
            return {"message": "Account created successfully"}
Example #3
0
 def upgrade(self):
     try:
         customer = Customer.get(email_address=self.email)
         plan = Plan.get(id=self.plan)
     except (
             Customer.DoesNotExist,
             Plan.DoesNotExist,
     ):
         if Customer.DoesNotExist:
             return {"message": "Customer does not exist"}
         if Plan.DoesNotExist:
             return {"message": "Plan does not exist"}
     else:
         customer = Customer.update(
             plan=plan.id, renewal_date=self.renewal_date).where(
                 Customer.email_address == self.email)
         customer.execute()
         return {"message": "Your plan has been upgraded Successfully"}