def create_response(self):
     if Feature.objects.filter(name=self.name).count() > 0:
         raise AsyncHandlerError("Feature '%s' already exists, and likely already "
                                 "in this Software Plan Version." % self.name)
     new_feature, _ = Feature.objects.get_or_create(
         name=self.name,
         feature_type=self.rate_type,
     )
     return fmt_feature_rate_dict(new_feature)
 def create_response(self):
     if Feature.objects.filter(name=self.name).count() > 0:
         raise AsyncHandlerError("Feature '%s' already exists, and likely already "
                                 "in this Software Plan Version." % self.name)
     new_feature, _ = Feature.objects.get_or_create(
         name=self.name,
         feature_type=self.rate_type,
     )
     return fmt_feature_rate_dict(new_feature)
Exemple #3
0
 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)
Exemple #4
0
 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:
         feature = Feature.objects.get(id=self.rate_id)
         return fmt_feature_rate_dict(feature)
     except Feature.DoesNotExist:
         raise AsyncHandlerError("could not find an existing feature")
 def apply_response(self):
     try:
         feature = Feature.objects.get(id=self.rate_id)
         return fmt_feature_rate_dict(feature)
     except Feature.DoesNotExist:
         raise AsyncHandlerError("could not find an existing feature")