Small cosmetic fix for the pie charts

We were showing "False X of Y" instead of "Used X of Y"

Change-Id: I8287ecdba7dc11d048a089f246a1b3437c0ace1e
This commit is contained in:
Victoria Martinez de la Cruz 2020-06-18 20:11:30 -03:00
parent 7b0ea8deff
commit 4e84942e0c
2 changed files with 9 additions and 6 deletions

View File

@ -13,6 +13,7 @@
import functools import functools
import sys import sys
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import horizon import horizon
@ -379,12 +380,13 @@ def get_context_data(self, **kwargs):
) )
for t in types: for t in types:
if t[0] in self.usage.limits and t[1] in self.usage.limits: if t[0] in self.usage.limits and t[1] in self.usage.limits:
text = pgettext_lazy('Label in the limit summary', 'Used')
context['charts'].append({ context['charts'].append({
'type': t[0], 'type': t[0],
'name': t[2], 'name': t[2],
'used': self.usage.limits[t[0]], 'used': self.usage.limits[t[0]],
'max': self.usage.limits[t[1]], 'max': self.usage.limits[t[1]],
'text': False, 'text': text
}) })
return context return context

View File

@ -48,6 +48,7 @@ class PieChartsTests(test.TestCase):
"max": 13, "max": 13,
"text": "fake_text", "text": "fake_text",
} }
text = translation.pgettext_lazy('Label in the limit summary', 'Used')
class ParentViewInstance(mock.MagicMock): class ParentViewInstance(mock.MagicMock):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -67,16 +68,16 @@ class PieChartsTests(test.TestCase):
existing_chart_name: { existing_chart_name: {
"name": existing_chart_name, "used": existing_chart["used"], "name": existing_chart_name, "used": existing_chart["used"],
"max": existing_chart["max"], "text": existing_chart["text"]}, "max": existing_chart["max"], "text": existing_chart["text"]},
"Shares": {"name": "Shares", "used": 1, "max": 6, "text": False}, "Shares": {"name": "Shares", "used": 1, "max": 6, "text": text},
"Share Storage": { "Share Storage": {
"name": "Share Storage", 'used': 2, "max": 7, "text": False}, "name": "Share Storage", 'used': 2, "max": 7, "text": text},
"Share Networks": { "Share Networks": {
"name": "Share Networks", "used": 3, "max": 8, "text": False}, "name": "Share Networks", "used": 3, "max": 8, "text": text},
"Share Snapshots": { "Share Snapshots": {
"name": "Share Snapshots", "used": 4, "max": 9, "text": False}, "name": "Share Snapshots", "used": 4, "max": 9, "text": text},
"Share Snapshots Storage": { "Share Snapshots Storage": {
"name": "Share Snapshots Storage", "used": 5, "max": 10, "name": "Share Snapshots Storage", "used": 5, "max": 10,
"text": False}, "text": text},
} }
for chart in charts: for chart in charts:
name = chart["name"].title() name = chart["name"].title()