# Path: minent/utils.py
# def normalize(text):
# def signature(text):
# def htmlize(text):
# def normalize_query(terms):
# def memoized(fget):
#     def fget_memoized(self):
#     def __init__(self, wall_clock=True):
#     def __enter__(self):
#     def __exit__(self, type, value, tb):
#     def __str__(self):
# def timeit(func, wall_clock=True):
#     def timer_wrapper(*args, **kwargs):
# def humanizedelta(*args, **kwargs):
# class Timer(object):
# 
# Path: tagging/managers.py
# class TagManager(models.Manager):
# 
#     def tag(self, tag, defaults=None):
#         """
#         Looks up a tag by name (e.g. a helper method for get) or creates it
#         with the given defaults. This method enforces tag case insensitivity
#         and should be used over `get_or_create`.
#         """
#         try:
#             return self.get(slug=slugify(tag)), False
#         except self.model.DoesNotExist:
#             if defaults is None:
#                 defaults = {}
#             return self.create(text=tag, **defaults), True
# 
#     def to_csv(self):
#         """
#         QuerySet methods must be mirrored on the Manager.
#         """
#         return self.get_queryset().to_csv()
# 
#     def lexical_ordering(self):
#         """
#         Returns a case-insensitive lexical ordering of the tags.
#         """
#         return self.get_queryset().lexical_ordering()
# 
#     def get_queryset(self):
#         """
#         Return a TagQuerySet instead of the standard queryset.
#         """
#         return TagQuerySet(self.model, using=self._db)


from django.db import models
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
from minent.utils import nullable, notnullable
from tagging.managers import TagManager
from slugify import slugify
# Models for the tagging app
#
# Author:   Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created:  Wed Jul 06 15:34:02 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: models.py [c5d00aa] benjamin@bengfort.com $

"""
Models for the tagging app
"""

##########################################################################
## Imports
##########################################################################


##########################################################################
## Question Tags
##########################################################################

class Tag(TimeStampedModel):

    text        = models.CharField(max_length=100, unique=True)
    slug        = AutoSlugField(populate_from='text', slugify=slugify, unique=True)
    description = models.CharField(max_length=255, **nullable)
    creator     = models.ForeignKey('auth.User', related_name='tags')
    is_synonym  = models.BooleanField(default=False)

# Path: minent/utils.py
# def normalize(text):
# def signature(text):
# def htmlize(text):
# def normalize_query(terms):
# def memoized(fget):
#     def fget_memoized(self):
#     def __init__(self, wall_clock=True):
#     def __enter__(self):
#     def __exit__(self, type, value, tb):
#     def __str__(self):
# def timeit(func, wall_clock=True):
#     def timer_wrapper(*args, **kwargs):
# def humanizedelta(*args, **kwargs):
# class Timer(object):
# 
# Path: tagging/managers.py
# class TagManager(models.Manager):
# 
#     def tag(self, tag, defaults=None):
#         """
#         Looks up a tag by name (e.g. a helper method for get) or creates it
#         with the given defaults. This method enforces tag case insensitivity
#         and should be used over `get_or_create`.
#         """
#         try:
#             return self.get(slug=slugify(tag)), False
#         except self.model.DoesNotExist:
#             if defaults is None:
#                 defaults = {}
#             return self.create(text=tag, **defaults), True
# 
#     def to_csv(self):
#         """
#         QuerySet methods must be mirrored on the Manager.
#         """
#         return self.get_queryset().to_csv()
# 
#     def lexical_ordering(self):
#         """
#         Returns a case-insensitive lexical ordering of the tags.
#         """
#         return self.get_queryset().lexical_ordering()
# 
#     def get_queryset(self):
#         """
#         Return a TagQuerySet instead of the standard queryset.
#         """
#         return TagQuerySet(self.model, using=self._db)


# Path: tagging/models.py
from django.db import models
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
from minent.utils import nullable, notnullable
from tagging.managers import TagManager
from slugify import slugify

# Models for the tagging app
#
# Author:   Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created:  Wed Jul 06 15:34:02 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: models.py [c5d00aa] benjamin@bengfort.com $

"""
Models for the tagging app
"""

##########################################################################
## Imports
##########################################################################


##########################################################################
## Question Tags
##########################################################################

class Tag(TimeStampedModel):

    text        = models.CharField(max_length=100, unique=True)
    slug        = AutoSlugField(populate_from='text', slugify=slugify, unique=True)
    description = models.CharField(max_length=255, **nullable)
    creator     = models.ForeignKey('auth.User', related_name='tags')
    is_synonym  = models.BooleanField(default=False)

    head_word   = models.ForeignKey('self', related_name='synonyms', **nullable)