<commit_before>from django.db import models

from entropy.mixins import LinkURLMixin, TitleMixin, EnabledMixin, SlugMixin
from images.mixins import ImageMixin


class Link(LinkURLMixin, ImageMixin):
    '''
    Admin defined link for use in menus and about the site.
    '''

    # url
    # gfk

    title = models.CharField(max_length=255)

    class Meta:
        verbose_name = 'Link URL'
        verbose_name_plural = "Re-useable Link URLs for Menu's"

    def __unicode__(self):
        if self.url:
            return u'%s (%s)' % (self.title, self.url)
        else:
            return u'%s' % self.title

    def get_url(self):
        '''
        Return the custom url or get_abs url
        '''
        # If a URL is specified, use that first
        if self.url:
            return self.url

        if self.content_type:

            if self.object_id:
                try:
                    obj = self.content_object
                except AttributeError:
                    return '' # raise a validation error

                if obj is None:
                    return ''

                return obj.get_absolute_url()
            else:
                try:
                    return self.content_type.model_class().get_list_url()
                except AttributeError:
                    return '' # raise a validation error

        return '' # raise a validation error

    def get_content_type(self):
        if self.content_type:
            return self.content_type.model
        return None


# class MenuInstance(models.Model):
#     '''
#     An instantiation of a Menu on a given Platform and Position
#
#     Menu's display in their given Position across all Links.
#     '''
#
#     platforms = models.ManyToManyField(
#         'channels.Channel')
#
#     position = models.ForeignKey(
#         'positions.Position')


class Menu(EnabledMixin, SlugMixin, TitleMixin):
    '''
    An ordered collection of Links
    '''
    # title
    # short_title
    # slug
    # enabled
    
    class Meta:
        verbose_name = 'Menu'
        verbose_name_plural = "Menu's with Link URLs"


class MenuItem(models.Model):
    menu = models.ForeignKey('Menu', related_name='items')
    link = models.ForeignKey('Link', related_name='links')
    order = models.PositiveIntegerField(default=0)<commit_msg>verbose name<commit_after>from django.db import models

from entropy.mixins import LinkURLMixin, TitleMixin, EnabledMixin, SlugMixin
from images.mixins import ImageMixin


class Link(LinkURLMixin, ImageMixin):
    '''
    Admin defined link for use in menus and about the site.
    '''

    # url
    # gfk

    title = models.CharField(max_length=255)

    class Meta:
        verbose_name = 'Link URL'
        verbose_name_plural = "Link URLs (Re-useable for Menu's)"

    def __unicode__(self):
        if self.url:
            return u'%s (%s)' % (self.title, self.url)
        else:
            return u'%s' % self.title

    def get_url(self):
        '''
        Return the custom url or get_abs url
        '''
        # If a URL is specified, use that first
        if self.url:
            return self.url

        if self.content_type:

            if self.object_id:
                try:
                    obj = self.content_object
                except AttributeError:
                    return '' # raise a validation error

                if obj is None:
                    return ''

                return obj.get_absolute_url()
            else:
                try:
                    return self.content_type.model_class().get_list_url()
                except AttributeError:
                    return '' # raise a validation error

        return '' # raise a validation error

    def get_content_type(self):
        if self.content_type:
            return self.content_type.model
        return None


# class MenuInstance(models.Model):
#     '''
#     An instantiation of a Menu on a given Platform and Position
#
#     Menu's display in their given Position across all Links.
#     '''
#
#     platforms = models.ManyToManyField(
#         'channels.Channel')
#
#     position = models.ForeignKey(
#         'positions.Position')


class Menu(EnabledMixin, SlugMixin, TitleMixin):
    '''
    An ordered collection of Links
    '''
    # title
    # short_title
    # slug
    # enabled
    
    class Meta:
        verbose_name = 'Menu'
        verbose_name_plural = "Menu's (with Link URLs)"


class MenuItem(models.Model):
    menu = models.ForeignKey('Menu', related_name='items')
    link = models.ForeignKey('Link', related_name='links')
    order = models.PositiveIntegerField(default=0)
{'fraction_non_alphanumeric': 0.0880395104144299, 'fraction_numerical': 0.0017178441056474125, 'mean_word_length': 1.9148936170212767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303581', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1264, 'n_words': 366}