<commit_before>from django.db import models

class Cafe(models.Model):
    slug = models.SlugField()
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    address = models.CharField(max_length=200)
    #hours
    phone = models.CharField(max_length=10)
    url = models.URLField(max_length=200)
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)
 
    class Meta:
        ordering = ['name',]

class Roaster(models.Model):
    slug = models.SlugField()
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    address = models.CharField(max_length=200)
    # TODO: Hours
    phone = models.CharField(max_length=10)
    url = models.URLField(max_length=200)
    description = models.TextField()
    photo_url = models.URLField(max_length=200)
    video_url = models.URLField(max_length=200)
    cafes = models.ManyToManyField('Cafe')
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)

    class Meta:
        ordering = ['name',]
        get_latest_by = 'created_at'

class Roast(models.Model):
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    roaster = models.ForeignKey('Roaster')
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)
    
    class Meta:
        ordering = ['name',]

<commit_msg>Add model unicode methods; populate slug field on save.<commit_after>from django.db import models
from django.template.defaultfilters import slugify

class Cafe(models.Model):
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    slug = models.SlugField()
    address = models.CharField(max_length=200)
    #hours
    phone = models.CharField(max_length=10)
    url = models.URLField(max_length=200)
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)
 
    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = slugify(self.name)

        super(Cafe, self).save(*args, **kwargs)

    class Meta:
        ordering = ['name',]

class Roaster(models.Model):
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    slug = models.SlugField()
    address = models.CharField(max_length=200)
    # TODO: Hours
    phone = models.CharField(max_length=10)
    url = models.URLField(max_length=200)
    description = models.TextField()
    photo_url = models.URLField(max_length=200)
    video_url = models.URLField(max_length=200)
    cafes = models.ManyToManyField('Cafe')
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = slugify(self.name)

        super(Roaster, self).save(*args, **kwargs)

    class Meta:
        ordering = ['name',]
        get_latest_by = 'created_at'

class Roast(models.Model):
    name = models.CharField(max_length=200, unique=True, db_index=True,
            blank=False)
    roaster = models.ForeignKey('Roaster')
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)
    modified_at = models.DateTimeField(auto_now=True, db_index=True)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ['name',]


{'fraction_non_alphanumeric': 0.11378671606245039, 'fraction_numerical': 0.016406456734585868, 'mean_word_length': 3.5985401459854014, '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': '7365197', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1219, 'n_words': 220}