# Path: apps/rule/const.py
# def get_choices(type_set):
#     return list(type_set.values())
# 
# def get_verbose(type_set, name):
#     value_dict = dict(list(type_set.values()))
#     return value_dict[name]
# 
# RULE_TYPE = {
#     'CONSTITUTION': ('CONST', _('회칙')),
#     'BYLAW': ('BYLAW', _('세칙')),
#     'RULE': ('RULE', _('규칙')),
#     'ETC': ('ETC', _('기타규정')),
# }
# 
# CHAPTER_TYPE = {
#     'PREAMBLE': ('PRE', _('전문')),
#     'CHAPTER': ('CHAP', _('장')),
#     'SECTION': ('SEC', _('절')),
#     'SUPPLEMENT': ('SUPPL', _('부칙')),
# }
# 
# REVISION_TYPE = {
#     'ESTABLISH': ('ESTAB', _('제정')),
#     'PARTIALLY': ('PART', _('일부개정')),
#     'FULLY': ('FULL', _('전부개정')),
# }


from django.db import models
from django.utils.translation import ugettext as _
from apps.rule.const import get_choices, get_verbose, RULE_TYPE, CHAPTER_TYPE, REVISION_TYPE
from itertools import chain
    def __str__(self):
        first = self.rules.first()
        if first:
            return first.name
        return _('(비어있음)')

    def get_absolute_url(self):
        return '/usc/rule/{}'.format(self.slug)


class Rule(models.Model):
    """
    규정.
    """

    rule_set = models.ForeignKey(
        RuleSet,
        related_name='rules',
        verbose_name=_('규정세트'))

    name = models.CharField(
        _('규정명'),
        max_length=64)

    rule_type = models.CharField(
        _('종류'),
        max_length=8, choices=get_choices(RULE_TYPE))

    @property
    def rule_type_v(self):

# Path: apps/rule/const.py
# def get_choices(type_set):
#     return list(type_set.values())
# 
# def get_verbose(type_set, name):
#     value_dict = dict(list(type_set.values()))
#     return value_dict[name]
# 
# RULE_TYPE = {
#     'CONSTITUTION': ('CONST', _('회칙')),
#     'BYLAW': ('BYLAW', _('세칙')),
#     'RULE': ('RULE', _('규칙')),
#     'ETC': ('ETC', _('기타규정')),
# }
# 
# CHAPTER_TYPE = {
#     'PREAMBLE': ('PRE', _('전문')),
#     'CHAPTER': ('CHAP', _('장')),
#     'SECTION': ('SEC', _('절')),
#     'SUPPLEMENT': ('SUPPL', _('부칙')),
# }
# 
# REVISION_TYPE = {
#     'ESTABLISH': ('ESTAB', _('제정')),
#     'PARTIALLY': ('PART', _('일부개정')),
#     'FULLY': ('FULL', _('전부개정')),
# }


# Path: apps/rule/models/rules.py
from django.db import models
from django.utils.translation import ugettext as _
from apps.rule.const import get_choices, get_verbose, RULE_TYPE, CHAPTER_TYPE, REVISION_TYPE
from itertools import chain

    def __str__(self):
        first = self.rules.first()
        if first:
            return first.name
        return _('(비어있음)')

    def get_absolute_url(self):
        return '/usc/rule/{}'.format(self.slug)


class Rule(models.Model):
    """
    규정.
    """

    rule_set = models.ForeignKey(
        RuleSet,
        related_name='rules',
        verbose_name=_('규정세트'))

    name = models.CharField(
        _('규정명'),
        max_length=64)

    rule_type = models.CharField(
        _('종류'),
        max_length=8, choices=get_choices(RULE_TYPE))

    @property
    def rule_type_v(self):

        return get_verbose(RULE_TYPE, self.rule_type)