fix - return none on get stat on quota
This commit is contained in:
@@ -544,7 +544,11 @@ class Quota(BaseModel):
|
||||
org = self.registerer_organization
|
||||
stat = OrganizationQuotaStats.objects.filter(
|
||||
quota=self,
|
||||
organization=org
|
||||
)
|
||||
# first quota created is none stat on attribute & broker value table
|
||||
if stat.stat_type == 'quota':
|
||||
return None
|
||||
return stat.first() if stat.exists() else None
|
||||
|
||||
def soft_delete(self):
|
||||
|
||||
@@ -87,7 +87,7 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
|
||||
attributes_value_list = []
|
||||
if 'price_attributes_data' in request.data.keys():
|
||||
for attr in request.data['price_attributes_data']:
|
||||
attr.update({'quota': quota.id, 'org_quota_stat': quota.org_quota_stats.all().first().id})
|
||||
attr.update({'quota': quota.id})
|
||||
attributes = CustomOperations().custom_create(
|
||||
request=request,
|
||||
view=product_api.AttributeValueViewSet(),
|
||||
@@ -99,7 +99,7 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
|
||||
broker_data_list = []
|
||||
if 'broker_data' in request.data.keys():
|
||||
for broker in request.data['broker_data']:
|
||||
broker.update({'quota': quota.id, 'org_quota_stat': quota.org_quota_stats.all().first().id})
|
||||
broker.update({'quota': quota.id})
|
||||
broker_value = CustomOperations().custom_create(
|
||||
request=request,
|
||||
view=QuotaBrokerValueViewSet(),
|
||||
|
||||
Reference in New Issue
Block a user