bug fixing
This commit is contained in:
parent
88a7d39f73
commit
9019084cca
5 changed files with 25 additions and 6 deletions
|
@ -20,7 +20,7 @@ class FlavorPriceUseCase(PricingUseCase):
|
|||
def get(self, request, id):
|
||||
data = super().get(request, id)
|
||||
try:
|
||||
flavor = api.nova.flavor_get(request, d['flavor_id'])
|
||||
flavor = api.nova.flavor_get(request, data['flavor_id'])
|
||||
data["name"] = flavor.name
|
||||
except Exception:
|
||||
data["name"] = 'Invalid Flavor'
|
||||
|
|
|
@ -13,7 +13,6 @@ class InvoiceUseCase:
|
|||
response = yuyu_client.get(request, f"invoice/simple_list/?tenant_id={tenant_id}")
|
||||
data = response.json()
|
||||
|
||||
print(data)
|
||||
for d in data:
|
||||
zero_money = Money(amount=0, currency=d['subtotal_currency'])
|
||||
d['start_date'] = dateutil.parser.isoparse(d['start_date'])
|
||||
|
|
|
@ -9,13 +9,19 @@ class VolumePriceUseCase(PricingUseCase):
|
|||
data = list(super().list(request))
|
||||
|
||||
for d in data:
|
||||
d["name"] = api.cinder.volume_type_get(request, d['volume_type_id']).name
|
||||
try:
|
||||
d["name"] = api.cinder.volume_type_get(request, d['volume_type_id']).name
|
||||
except Exception:
|
||||
d["name"] = 'Invalid Volume'
|
||||
|
||||
return data
|
||||
|
||||
def get(self, request, id):
|
||||
data = super().get(request, id)
|
||||
data["name"] = api.cinder.volume_type_get(request, data['volume_type_id']).name
|
||||
try:
|
||||
data["name"] = api.cinder.volume_type_get(request, data['volume_type_id']).name
|
||||
except Exception:
|
||||
data["name"] = 'Invalid Volume'
|
||||
return data
|
||||
|
||||
def has_missing_price(self, request):
|
||||
|
|
|
@ -12,6 +12,8 @@ class BaseCreatePrice(tables.LinkAction):
|
|||
def allowed(self, request, datum):
|
||||
if self.single_data and len(self.table.data) >= 1:
|
||||
self.classes = [c for c in self.classes] + ['hidden']
|
||||
else:
|
||||
self.classes = [c for c in self.classes if c != 'hidden']
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -50,12 +50,18 @@ class IndexView(tables.MultiTableView):
|
|||
context['invoice'] = self.request.invoice
|
||||
return context
|
||||
|
||||
def _get_flavor_name(self, flavor_id):
|
||||
try:
|
||||
return api.nova.flavor_get(self.request, flavor_id).name
|
||||
except Exception:
|
||||
return 'Invalid Flavor'
|
||||
|
||||
def get_instance_cost_data(self):
|
||||
try:
|
||||
datas = map(lambda x: {
|
||||
"id": x['id'],
|
||||
"name": x['name'],
|
||||
"flavor": api.nova.flavor_get(self.request, x['flavor_id']).name,
|
||||
"flavor": self._get_flavor_name(x['flavor_id']),
|
||||
"usage": timesince(
|
||||
dateutil.parser.isoparse(x['start_date']),
|
||||
dateutil.parser.isoparse(x['adjusted_end_date'])
|
||||
|
@ -70,6 +76,12 @@ class IndexView(tables.MultiTableView):
|
|||
|
||||
return []
|
||||
|
||||
def _get_volume_name(self, volume_type_id):
|
||||
try:
|
||||
return api.cinder.volume_type_get(self.request, volume_type_id).name
|
||||
except Exception:
|
||||
return 'Invalid Volume'
|
||||
|
||||
def get_volume_cost_data(self):
|
||||
try:
|
||||
datas = map(lambda x: {
|
||||
|
@ -79,7 +91,7 @@ class IndexView(tables.MultiTableView):
|
|||
dateutil.parser.isoparse(x['start_date']),
|
||||
dateutil.parser.isoparse(x['adjusted_end_date'])
|
||||
),
|
||||
'type': api.cinder.volume_type_get(self.request, x['volume_type_id']).name,
|
||||
'type': self._get_volume_name(x['volume_type_id']),
|
||||
'size': x['space_allocation_gb'],
|
||||
"cost": Money(amount=x['price_charged'], currency=x['price_charged_currency'])
|
||||
}, self.request.invoice.get('volumes', []))
|
||||
|
|
Loading…
Add table
Reference in a new issue