Commit 9ffd1dbd by Bach Dániel

dashboard: i18n for graphs

parent ccbce20a
...@@ -23,6 +23,7 @@ import requests ...@@ -23,6 +23,7 @@ import requests
from django.conf import settings from django.conf import settings
from django.core.exceptions import PermissionDenied, SuspiciousOperation from django.core.exceptions import PermissionDenied, SuspiciousOperation
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.utils.translation import ugettext_lazy as _
from django.views.generic import View from django.views.generic import View
from braces.views import LoginRequiredMixin, SuperuserRequiredMixin from braces.views import LoginRequiredMixin, SuperuserRequiredMixin
...@@ -162,8 +163,8 @@ class NodeListGraphView(SuperuserRequiredMixin, GraphViewBase): ...@@ -162,8 +163,8 @@ class NodeListGraphView(SuperuserRequiredMixin, GraphViewBase):
class Ram(object): class Ram(object):
metric_name = "memory.usage" metric_name = "memory.usage"
title = "RAM usage (%)" title = _("RAM usage (%)")
label = "RAM usage (%)" label = _("RAM usage (%)")
def get_minmax(self): def get_minmax(self):
return (0, 105) return (0, 105)
...@@ -174,8 +175,8 @@ register_graph(Ram, 'memory', NodeGraphView) ...@@ -174,8 +175,8 @@ register_graph(Ram, 'memory', NodeGraphView)
class Cpu(object): class Cpu(object):
metric_name = "cpu.percent" metric_name = "cpu.percent"
title = "CPU usage (%)" title = _("CPU usage (%)")
label = "CPU usage (%)" label = _("CPU usage (%)")
def get_minmax(self): def get_minmax(self):
if isinstance(self.obj, Node): if isinstance(self.obj, Node):
...@@ -188,7 +189,7 @@ register_graph(Cpu, 'cpu', NodeGraphView) ...@@ -188,7 +189,7 @@ register_graph(Cpu, 'cpu', NodeGraphView)
class VmNetwork(object): class VmNetwork(object):
title = "Network" title = _("Network")
def get_minmax(self): def get_minmax(self):
return (0, None) return (0, None)
...@@ -211,7 +212,7 @@ register_graph(VmNetwork, 'network', VmGraphView) ...@@ -211,7 +212,7 @@ register_graph(VmNetwork, 'network', VmGraphView)
class NodeNetwork(object): class NodeNetwork(object):
title = "Network" title = _("Network")
def get_minmax(self): def get_minmax(self):
return (0, None) return (0, None)
...@@ -227,8 +228,8 @@ register_graph(NodeNetwork, 'network', NodeGraphView) ...@@ -227,8 +228,8 @@ register_graph(NodeNetwork, 'network', NodeGraphView)
class NodeVms(object): class NodeVms(object):
metric_name = "vmcount" metric_name = "vmcount"
title = "Instance count" title = _("Instance count")
label = "instance count" label = _("instance count")
def get_minmax(self): def get_minmax(self):
return (0, None) return (0, None)
...@@ -237,7 +238,7 @@ register_graph(NodeVms, 'vm', NodeGraphView) ...@@ -237,7 +238,7 @@ register_graph(NodeVms, 'vm', NodeGraphView)
class NodeAllocated(object): class NodeAllocated(object):
title = "Allocated memory (bytes)" title = _("Allocated memory (bytes)")
def get_target(self): def get_target(self):
prefix = self.obj.metric_prefix prefix = self.obj.metric_prefix
...@@ -257,7 +258,7 @@ register_graph(NodeAllocated, 'alloc', NodeGraphView) ...@@ -257,7 +258,7 @@ register_graph(NodeAllocated, 'alloc', NodeGraphView)
class NodeListAllocated(object): class NodeListAllocated(object):
title = "Allocated memory (bytes)" title = _("Allocated memory (bytes)")
def get_target(self): def get_target(self):
nodes = self.obj nodes = self.obj
...@@ -277,7 +278,7 @@ register_graph(NodeListAllocated, 'alloc', NodeListGraphView) ...@@ -277,7 +278,7 @@ register_graph(NodeListAllocated, 'alloc', NodeListGraphView)
class NodeListVms(object): class NodeListVms(object):
title = "Instance count" title = _("Instance count")
def get_target(self): def get_target(self):
vmcount = ','.join('%s.vmcount' % n.metric_prefix for n in self.obj) vmcount = ','.join('%s.vmcount' % n.metric_prefix for n in self.obj)
......
...@@ -31,7 +31,7 @@ from django.contrib.auth.views import redirect_to_login ...@@ -31,7 +31,7 @@ from django.contrib.auth.views import redirect_to_login
from django.db.models import Q from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, View from django.views.generic import DetailView, View
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment