2010-12-02 15:09:53 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import User
|
2010-12-09 05:06:17 +00:00
|
|
|
from codereview.dashboard.models import Repository
|
2010-12-13 05:33:04 +00:00
|
|
|
from codereview.browser import vcs
|
|
|
|
|
|
|
|
"""
|
|
|
|
Requirements:
|
|
|
|
|
|
|
|
i.
|
|
|
|
Must be able to review a changeset as a collection of blobs at a certain
|
|
|
|
revision, with diff information. Comments apply to any line of a unified diff
|
|
|
|
containing all context.
|
|
|
|
|
|
|
|
* Single revision plus parent revision
|
|
|
|
* At least one valid (modified) path
|
|
|
|
* Line based on diff with full context.
|
|
|
|
|
|
|
|
ii.
|
|
|
|
Must be able to review a blob or collection of blobs at a certain revision
|
|
|
|
without diff information. Comments apply to any line of raw blob text.
|
|
|
|
|
|
|
|
* Single revision
|
|
|
|
* At least one valid path
|
|
|
|
* Line based on raw path text
|
|
|
|
"""
|
2010-12-02 15:09:53 +00:00
|
|
|
|
|
|
|
class Review(models.Model):
|
|
|
|
author = models.ForeignKey(User)
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
2010-12-09 05:06:17 +00:00
|
|
|
description = models.TextField()
|
2010-12-13 05:33:04 +00:00
|
|
|
repo = models.ForeignKey(Repository)
|
|
|
|
ref = models.CharField(max_length=40)
|
|
|
|
parent = models.CharField(max_length=40)
|
2010-12-02 15:09:53 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return 'Review #{0}'.format(self.pk)
|
2010-12-13 05:33:04 +00:00
|
|
|
|
2010-12-02 15:09:53 +00:00
|
|
|
class Comment(models.Model):
|
2010-12-13 05:33:04 +00:00
|
|
|
review = models.ForeignKey(Review)
|
2010-12-02 15:09:53 +00:00
|
|
|
author = models.ForeignKey(User)
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
2010-12-13 05:33:04 +00:00
|
|
|
path = models.TextField()
|
|
|
|
line_a = models.IntegerField()
|
|
|
|
line_b = models.IntegerField(null=True)
|
2010-12-02 15:09:53 +00:00
|
|
|
text = models.TextField()
|