aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django/git_browse/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django/git_browse/models.py')
-rw-r--r--bn_django/git_browse/models.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
index 93a22b3..765fe02 100644
--- a/bn_django/git_browse/models.py
+++ b/bn_django/git_browse/models.py
@@ -33,3 +33,49 @@ class Repository(models.Model):
return "/code/%s/" % self.slug
def get_admin_url(self):
return "%s/code/repository/%s/" % (ADMIN_URL, self.slug)
+
+class Tree(models.Model):
+ repo = models.ForeignKey(Repository)
+ mode = models.CharField("file mode/permissions", blank=False,maxlength=4)
+ path = models.CharField("relative path from repo base", maxlength=512)
+ id = models.CharField("hash", maxlength=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", maxlength=128,blank=False)
+ type = 'tree'
+
+ class Admin:
+ ordering = ['repo','path']
+
+ def __str__(self):
+ return self.name
+ def get_absolute_url(self):
+ return "/code/%s/%s" % (self.repo.slug, self.hash)
+ def get_admin_url(self):
+ return "%s/code/tree/%s/" % (ADMIN_URL, self.id)
+
+def tree_from_str(s):
+ s = s.split();
+ if len(s) != 4: return
+ return Tree(mode=s[0],id=s[2],name=s[3])
+
+class Blob(models.Model):
+ repo = models.ForeignKey(Repository)
+ mode = models.CharField("file mode/permissions", blank=False,maxlength=4)
+ path = models.CharField("relative path from repo base", maxlength=512)
+ id = models.CharField("hash", maxlength=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", maxlength=128,blank=False)
+ type='blob'
+
+ class Admin:
+ ordering = ['repo','path']
+
+ def __str__(self):
+ return self.name
+ def get_absolute_url(self):
+ return "/code/%s/%s" % (self.repo.slug, self.hash)
+ def get_admin_url(self):
+ return "%s/code/tree/%s/" % (ADMIN_URL, self.id)
+
+def blob_from_str(s):
+ s = s.split();
+ if len(s) != 4: return
+ return Blob(mode=s[0],id=s[2],name=s[3])