#!/usr/bin/env python
# -*- coding: utf-8 -*-

"Link Class mapping to SQL table"

from django.db import models
from django.utils.html import format_html
from labman2.data.subdata.ReST.models import ReST
#from labman2.data.models import rest_to_html


#==============================================================================
# A numerical value, e.g. a universal constant or a simple measurement
class NumValue(ReST):
    "A simple numeric data entry"


    num_value = models.FloatField(null=True, blank=True,
                                  help_text="Use style like 1.234e-5")

    def __unicode__(self):
        try:
            return format_html(u'{0}: {1}',
                           str(self.num_value),
                           ReST.__unicode__(self))
        except StandardError as err:
            print "NumValue.__unicode__", err
            return u'%s: %s' % (str(self.num_value), u"ReST.__unicode__(self)")

    def show_details(self):
        'Return a list of the fields for detailed view'

        info_dict = [('NumValue', str(self.num_value))]
        info_dict.extend(ReST.show_details(self))
        return info_dict
