# Path: shortener/links/validators.py
# def validate_five_characters(value):
#     if len(value) < 5:
#         msg = u"Custom identifiers must have at least 5 characters"
#         raise ValidationError(msg)


from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.utils.baseconv import base64
from django.utils.translation import ugettext_lazy as _
from amazonify import amazonify
from model_utils.models import TimeStampedModel
from .validators import validate_five_characters
    @property
    def count(self):
        return self.linklog_set.count()

    def log(self, request):
        self.linklog_set.create_from_request(
            link=self,
            request=request
        )

    def get_identifier_url(self):
        try:
            return reverse("links:redirect", kwargs={'identifier': self.identifier})
        except NoReverseMatch:
            return 'NADA'

    @property
    def tiny(self):
        return base64.encode(self.pk)

    def get_tiny_url(self):
        return reverse("links:redirect", kwargs={'identifier': self.tiny})

    def amazonify(self):
        url = self.original_url
        if url.startswith(
            ("https://amazon.",
                "http://amazon.",
                "http://amzn.",
                "https://amzn.",

# Path: shortener/links/validators.py
# def validate_five_characters(value):
#     if len(value) < 5:
#         msg = u"Custom identifiers must have at least 5 characters"
#         raise ValidationError(msg)


# Path: shortener/links/models.py
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.utils.baseconv import base64
from django.utils.translation import ugettext_lazy as _
from amazonify import amazonify
from model_utils.models import TimeStampedModel
from .validators import validate_five_characters

    @property
    def count(self):
        return self.linklog_set.count()

    def log(self, request):
        self.linklog_set.create_from_request(
            link=self,
            request=request
        )

    def get_identifier_url(self):
        try:
            return reverse("links:redirect", kwargs={'identifier': self.identifier})
        except NoReverseMatch:
            return 'NADA'

    @property
    def tiny(self):
        return base64.encode(self.pk)

    def get_tiny_url(self):
        return reverse("links:redirect", kwargs={'identifier': self.tiny})

    def amazonify(self):
        url = self.original_url
        if url.startswith(
            ("https://amazon.",
                "http://amazon.",
                "http://amzn.",
                "https://amzn.",

                "https://www.amazon.",