Skip to content
Browse files

added labels to servers

  • Loading branch information...
1 parent 0d605f8 commit 26e747fb946636170e4c3522c8e7d8bfd7789bde @WoLpH WoLpH committed with Mar 23, 2012
View
1 src/redisboard/admin.py
@@ -17,6 +17,7 @@ class Media:
list_display = (
'__unicode__', 'status', 'memory', 'clients', 'details', 'tools'
)
+ ordering = ('hostname', 'port')
def status(self, obj):
return obj.stats['status']
status.long_description = _("Status")
View
34 src/redisboard/migrations/0005_auto__add_field_redisserver_label.py
@@ -0,0 +1,34 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'RedisServer.label'
+ db.add_column('redisboard_redisserver', 'label', self.gf('django.db.models.fields.CharField')(default='', max_length=50, blank=True))
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'RedisServer.label'
+ db.delete_column('redisboard_redisserver', 'label')
+
+
+ models = {
+ 'redisboard.redisserver': {
+ 'Meta': {'unique_together': "(('hostname', 'port'),)", 'object_name': 'RedisServer'},
+ 'hostname': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'label': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
+ 'port': ('django.db.models.fields.IntegerField', [], {'default': '6379', 'null': 'True', 'blank': 'True'}),
+ 'sampling_size': ('django.db.models.fields.IntegerField', [], {'default': '200'}),
+ 'sampling_threshold': ('django.db.models.fields.IntegerField', [], {'default': '1000'})
+ }
+ }
+
+ complete_apps = ['redisboard']
View
19 src/redisboard/models.py
@@ -42,6 +42,13 @@ class Meta:
("can_inspect", "Can inspect redis servers"),
)
+ label = models.CharField(
+ _('Label'),
+ max_length=50,
+ default='',
+ blank=True,
+ )
+
hostname = models.CharField(
_("Hostname"),
max_length = 250,
@@ -126,6 +133,14 @@ def stats(self):
def __unicode__(self):
+ if self.label:
+ label = '%s (%%s)' % self.label
+ else:
+ label = '%s'
+
if self.port:
- return "%s:%s" % (self.hostname, self.port)
- return self.hostname
+ label = label % ('%s:%s' % (self.hostname, self.port))
+ else:
+ label = label % self.hostname
+
+ return label

0 comments on commit 26e747f

Please sign in to comment.
Something went wrong with that request. Please try again.