# coding=utf-8

from django.db import models

class Config(models.Model):
    KEY_CONSIGNEE_NAME = "consignee_name"       # 收货人姓名
    KEY_CONSIGNEE_TEL = "consignee_tel"         # 收货人电话
    GODOWNENTRY_PROCESS = "godownentry_process"         # 1简易流程，0标准流程

    property = models.CharField(max_length=100, verbose_name=u'属性')
    value = models.TextField(verbose_name=u'值')

    class Meta:
        db_table = "system_config"
        verbose_name = u"基础设置"
        index_together = (
            'property',
        )
        default_permissions = ()
        permissions = (
            ("edit_config", u"修改"),
        )

    @staticmethod
    def getConsigneeName():
        try:
            row = Config.objects.get(property=Config.KEY_CONSIGNEE_NAME)
            return row.value
        except:
            return ""

    @staticmethod
    def getConsigneeTel():
        try:
            row = Config.objects.get(property=Config.KEY_CONSIGNEE_TEL)
            return row.value
        except:
            return ""

    @staticmethod
    def getValue(property):
        try:
            row = Config.objects.get(property=property)
            return row.value
        except:
            return ""
