<commit_before>from django.db import models
from django.core.urlresolvers import reverse
from pylinks.main.models import DatedModel


class Category(DatedModel):
    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(help_text='Text for the URL')
    description = models.TextField(null=True)

    def get_absolute_url(self):
        return reverse('category_links', kwargs={'slug': self.slug})

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ('title',)
        verbose_name_plural = 'categories'


class Link(DatedModel):
    title = models.CharField(max_length=200)
    url = models.URLField(verbose_name='URL', blank=True,
            default=None, null=True,
            help_text='URL to link to. Leave blank if uploading a file.')
    file = models.FileField(upload_to='links', blank=True,
            null=True, default=None, max_length=500,
            help_text='A file to be uploaded and linked to instead ' \
            + 'of the URL.')
    category = models.ForeignKey(Category, null=True, related_name='links')
    description = models.TextField(null=True,
            help_text='Description of the link or file contents')
    visits = models.IntegerField(default=0, editable=False,
            help_text='Number of visitors who clicked on this link')

    def get_absolute_url(self):
        return reverse('track_link', args=(self.id,))

    def __unicode__(self):
        return self.title
<commit_msg>Fix link URLs before saving<commit_after>from django.db import models
from django.core.urlresolvers import reverse
from pylinks.main.models import DatedModel


class Category(DatedModel):
    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(help_text='Text for the URL')
    description = models.TextField(null=True)

    def get_absolute_url(self):
        return reverse('category_links', kwargs={'slug': self.slug})

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ('title',)
        verbose_name_plural = 'categories'


class Link(DatedModel):
    title = models.CharField(max_length=200)
    url = models.URLField(verbose_name='URL', blank=True,
            default=None, null=True,
            help_text='URL to link to. Leave blank if uploading a file.')
    file = models.FileField(upload_to='links', blank=True,
            null=True, default=None, max_length=500,
            help_text='A file to be uploaded and linked to instead ' \
            + 'of the URL.')
    category = models.ForeignKey(Category, null=True, related_name='links')
    description = models.TextField(null=True,
            help_text='Description of the link or file contents')
    visits = models.IntegerField(default=0, editable=False,
            help_text='Number of visitors who clicked on this link')

    def get_absolute_url(self):
        if self.id:
            return reverse('track_link', args=(self.id,))
        elif self.file:
            return self.file.url
        elif self.url:
            return self.url
        else:
            return None

    def __unicode__(self):
        return self.title

{'fraction_non_alphanumeric': 0.10227272727272728, 'fraction_numerical': 0.006313131313131313, 'mean_word_length': 3.0524296675191818, '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': '1424773', 'n_tokens_mistral': 925, 'n_tokens_neox': 897, 'n_words': 237}