from django.db import models

from cyder.base.mixins import ObjectUrlMixin
from cyder.base.models import BaseModel
from cyder.cydhcp.keyvalue.models import KeyValue


class System(BaseModel, ObjectUrlMixin):
    name = models.CharField(max_length=255, unique=False)

    search_fields = ('name',)
    display_fields = ('name', 'pk')

    def __str__(self):
        return "{0} : {1}".format(*(str(getattr(self, f))
                                    for f in self.display_fields))

    class Meta:
        db_table = 'system'

    def details(self):
        """For tables."""
        data = super(System, self).details()
        data['data'] = [
            ('Name', 'name', self),
        ]
        return data

    @staticmethod
    def eg_metadata():
        """EditableGrid metadata."""
        return {'metadata': [
            {'name': 'name', 'datatype': 'string', 'editable': True},
        ]}


class SystemKeyValue(KeyValue):

    system = models.ForeignKey(System, null=False)

    class Meta:
        db_table = 'system_key_value'
        unique_together = ('key', 'value', 'system')

@@ -108,16 +108,59 @@
 seModel%0A
+from cyder.base.helpers import get_display%0A
 from cyd
@@ -366,13 +366,8 @@
 me',
- 'pk'
 )%0A%0A 
@@ -407,116 +407,24 @@
 urn 
-%22%7B0%7D : %7B1%7D%22.format(*(str(getattr(self, f))%0A                                    for f in self.display_fields)
+get_display(self
 )%0A%0A 

Revert system names to normal