# 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
        verbose_name = '장/절'
        verbose_name_plural = '장/절(들)'

    def __str__(self):
        return "{} {}{}".format(
            self.parent_chapter if self.parent_chapter else self.rule,
            "제{}".format(self.num) if self.num else "",
            get_verbose(CHAPTER_TYPE, self.chapter_type))

    @property
    def d_chapters(self):
        return self.child_chapters.all()

    @property
    def d_articles(self):
        return self.articles.all()

    @property
    def d_clauses(self):
        return self.clauses.filter(
            article=None)

    def get_root_chapter(self):
        if not self.parent_chapter:
            return self
        return self.parent_chapter.get_root_chapter()

    def get_revision_url(self):
        if self.chapter_type == CHAPTER_TYPE['PREAMBLE'][0]:
            return '/revision/preamble'

# 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

        verbose_name = '장/절'
        verbose_name_plural = '장/절(들)'

    def __str__(self):
        return "{} {}{}".format(
            self.parent_chapter if self.parent_chapter else self.rule,
            "제{}".format(self.num) if self.num else "",
            get_verbose(CHAPTER_TYPE, self.chapter_type))

    @property
    def d_chapters(self):
        return self.child_chapters.all()

    @property
    def d_articles(self):
        return self.articles.all()

    @property
    def d_clauses(self):
        return self.clauses.filter(
            article=None)

    def get_root_chapter(self):
        if not self.parent_chapter:
            return self
        return self.parent_chapter.get_root_chapter()

    def get_revision_url(self):
        if self.chapter_type == CHAPTER_TYPE['PREAMBLE'][0]:
            return '/revision/preamble'

        if self.chapter_type == CHAPTER_TYPE['CHAPTER'][0]: