Source

noodle-bucket / mercurial_data / models.py

Full commit
from django.db import models


class Repository(models.Model):
    """A Mercurial repository on BitBucket."""
    
    user_name = models.CharField(
        max_length=100
    )
    repo_name = models.CharField(
        max_length=200
    )
    parent = models.ForeignKey(
        'self', null=True, blank=True
    )
    refreshed = models.DateTimeField(
        null=True, blank=True
    )
    description = models.TextField(
        blank=True, null=True
    )
    
    created = models.DateTimeField(editable=False, auto_now_add=True)
    updated = models.DateTimeField(editable=False, auto_now=True)
    
    class Meta:
        ordering = ['-created']
        verbose_name_plural = "repositories"
    
    
    def __unicode__(self):
        return u"%s/%s" % (self.user_name, self.repo_name)
    


class Changeset(models.Model):
    """A single changeset in a repository."""
    
    repo = models.ForeignKey(Repository)
    cset_hash = models.CharField(
        max_length=40,
        verbose_name="hash"
    )
    cset_parent = models.CharField(
        max_length=40,
        verbose_name="parent"
    )
    cset_branch = models.CharField(
        max_length=100
    )
    cset_author = models.CharField(
        max_length=150,
        verbose_name="author"
    )
    cset_date = models.DateTimeField(
        verbose_name="date"
    )
    cset_message = models.TextField(
        blank=True, null=True,
        verbose_name="message"
    )
    
    created = models.DateTimeField(editable=False, auto_now_add=True)
    updated = models.DateTimeField(editable=False, auto_now=True)
    
    class Meta:
        pass
    
    def __unicode__(self):
        return u"%s@%s" % (self.repo, self.cset_hash)