def create_response(self): if SoftwareProduct.objects.filter(name=self.name).count() > 0: raise AsyncHandlerError( "Product '%s' already exists, and likely already " "in this Software Plan Version." % self.name) new_product, _ = SoftwareProduct.objects.get_or_create( name=self.name, product_type=self.rate_type) return fmt_product_rate_dict(new_product)
def create_response(self): if SoftwareProduct.objects.filter(name=self.name).count() > 0: raise AsyncHandlerError("Product '%s' already exists, and likely already " "in this Software Plan Version." % self.name) new_product, _ = SoftwareProduct.objects.get_or_create( name=self.name, product_type=self.rate_type ) return fmt_product_rate_dict(new_product)
def software_plan_version_form(self): plan_version = self.plan.get_version() initial = { 'feature_rates': json.dumps([fmt_feature_rate_dict(r.feature, r) for r in plan_version.feature_rates.all()] if plan_version else []), 'product_rates': json.dumps([fmt_product_rate_dict(r.product, r) for r in plan_version.product_rates.all()] if plan_version else []), 'role_slug': plan_version.role.slug if plan_version else None, } if self.request.method == 'POST' and 'update_version' in self.request.POST: return SoftwarePlanVersionForm(self.plan, self.plan.get_version(), self.request.POST, initial=initial) return SoftwarePlanVersionForm(self.plan, self.plan.get_version(), initial=initial)
def software_plan_version_form(self): plan_version = self.plan.get_version() if self.request.method == 'POST' and 'update_version' in self.request.POST: return SoftwarePlanVersionForm(self.plan, plan_version, self.request.POST) initial = { 'feature_rates': json.dumps([fmt_feature_rate_dict(r.feature, r) for r in plan_version.feature_rates.all()] if plan_version else []), 'product_rates': json.dumps( [fmt_product_rate_dict(plan_version.product_rate.name, plan_version.product_rate)] if plan_version else [] ), 'role_slug': plan_version.role.slug if plan_version else None, } return SoftwarePlanVersionForm(self.plan, plan_version, initial=initial)
def apply_response(self): try: product = SoftwareProduct.objects.get(id=self.rate_id) return fmt_product_rate_dict(product) except SoftwareProduct.DoesNotExist: raise AsyncHandlerError("could not find an existing product")
def create_response(self): if SoftwareProductRate.objects.filter(name=self.name).exists(): raise AsyncHandlerError( "Product rate '%s' already exists, and likely already " "in this Software Plan Version." % self.name) return fmt_product_rate_dict(self.name)
def create_response(self): if SoftwareProductRate.objects.filter(name=self.name).exists(): raise AsyncHandlerError("Product rate '%s' already exists, and likely already " "in this Software Plan Version." % self.name) return fmt_product_rate_dict(self.name)