aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@animus.robocracy.org>2008-08-11 20:45:15 -0700
committerBryan Newbold <bnewbold@animus.robocracy.org>2008-08-11 20:45:15 -0700
commit6a22baa306a72557698d64ac6c09842bed81f66b (patch)
tree137f5d9fb1ef3bc834ee4e037ca2e33f0f4c384f
parent62dcf136d5b71c0b4d5744ec3551ce82edcc2a94 (diff)
downloadbnewnet-6a22baa306a72557698d64ac6c09842bed81f66b.tar.gz
bnewnet-6a22baa306a72557698d64ac6c09842bed81f66b.zip
more changes, works ok. TODO: comments for git_wiki, redo git_browse...
-rw-r--r--bn_django/git_browse/models.py47
-rw-r--r--bn_django/git_wiki/models.py39
-rw-r--r--bn_django/git_wiki/templates/git_wiki/item.html5
-rw-r--r--bn_django/photos/models.py51
-rw-r--r--bn_django/urls.py6
5 files changed, 91 insertions, 57 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
index e805199..5241638 100644
--- a/bn_django/git_browse/models.py
+++ b/bn_django/git_browse/models.py
@@ -1,5 +1,6 @@
from django.db import models
from django.conf import settings
+from django.utils.translation import ugettext as _
try:
GITCOMMAND = settings.GITCOMMAND
@@ -19,12 +20,12 @@ class Repository(models.Model):
# path = models.FilePathField("relative path to repository", \
# path=GITBROWSE_BASE,recursive=True,match="\.git$",unique=True, \
# blank=False)
- path = models.CharField("path to git dir", maxlength=386, unique=True,\
+ path = models.CharField("path to git dir", max_length=386, unique=True,\
blank=False, default="/srv/git/")
- name = models.CharField(_("name"), maxlength=80, unique=True)
+ name = models.CharField(_("name"), max_length=80, unique=True)
slug = models.SlugField("short description of repo", unique=True,\
blank=False)
- git_version = models.CharField(_("git version"), maxlength=100, \
+ git_version = models.CharField(_("git version"), max_length=100, \
default="git version 1.4.4", blank=True, \
help_text="Output of \'git --version\'")
@@ -91,10 +92,10 @@ class Repository(models.Model):
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)
+ mode = models.CharField("file mode/permissions", blank=False,max_length=4)
+ path = models.CharField("relative path from repo base", max_length=512)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", max_length=128,blank=False)
type = 'tree'
class Admin:
@@ -149,11 +150,11 @@ def tree_from_str(s):
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)
- size = models.IntegerField("filesize in byte", maxlength=128,blank=False)
+ mode = models.CharField("file mode/permissions", blank=False,max_length=4)
+ path = models.CharField("relative path from repo base", max_length=512)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", max_length=128,blank=False)
+ size = models.IntegerField("filesize in byte", max_length=128,blank=False)
contents = models.TextField("ASCII contents of the file")
type='blob'
@@ -188,20 +189,20 @@ def blob_from_str(s):
class Commit(models.Model):
repo = models.ForeignKey(Repository)
- id = models.CharField("hash", maxlength=40,blank=False,primary_key=True)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
rawdiff = models.TextField("ASCII contents of full commit diff")
commit_date = models.DateField("Date of commit to repository")
author_date = models.DateField("Date commit was writen/created")
- author = models.CharField("Name of commit author", maxlength=96)
+ author = models.CharField("Name of commit author", max_length=96)
author_email = models.CharField("Email address of commit author", \
- maxlength=196)
- committer = models.CharField("Name of committer", maxlength=96)
+ max_length=196)
+ committer = models.CharField("Name of committer", max_length=96)
committer_email = models.CharField("Email address of committer", \
- maxlength=196)
+ max_length=196)
comment = models.TextField("Notes on the commit")
- parenthash = models.CharField("parent's hash", maxlength=40)
+ parenthash = models.CharField("parent's hash", max_length=40)
#TODO: parent = models.ForeignKey()
- treehash = models.CharField("tree object's hash", maxlength=40)
+ treehash = models.CharField("tree object's hash", max_length=40)
tree = models.ForeignKey(Tree)
type='commit'
@@ -251,3 +252,11 @@ class Commit(models.Model):
else:
self.comment = '(none)'
return
+
+from django.contrib import admin
+
+admin.site.register(Repository)
+admin.site.register(Tree)
+admin.site.register(Blob)
+admin.site.register(Commit)
+
diff --git a/bn_django/git_wiki/models.py b/bn_django/git_wiki/models.py
index 2614739..2fe841f 100644
--- a/bn_django/git_wiki/models.py
+++ b/bn_django/git_wiki/models.py
@@ -10,10 +10,10 @@ if ADMIN_URL[-1] == '/':
ADMIN_URL=ADMIN_URL[:-1]
class Tree(models.Model):
- 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)
+ mode = models.CharField("file mode/permissions", blank=False,max_length=4)
+ path = models.CharField("relative path from repo base", max_length=512)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", max_length=128,blank=False)
type = 'tree'
def slug(self):
#TODO: secure this
@@ -64,11 +64,11 @@ class Tree(models.Model):
class Item(models.Model):
- 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)
- size = models.IntegerField("filesize in byte", maxlength=128,blank=False)
+ mode = models.CharField("file mode/permissions", blank=False,max_length=4)
+ path = models.CharField("relative path from repo base", max_length=512)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
+ name = models.CharField("name of dir", max_length=128,blank=False)
+ size = models.IntegerField("filesize in byte", max_length=128,blank=False)
contents = models.TextField("ASCII contents of the file")
type='blob'
def slug(self):
@@ -109,20 +109,20 @@ class Item(models.Model):
return open(str(GITWIKI_DIR + '/objects/' + self.id[:2] + '/' + self.id[2:]),'r')
class Commit(models.Model):
- id = models.CharField("hash", maxlength=40,blank=False,primary_key=True)
+ id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
rawdiff = models.TextField("ASCII contents of full commit diff")
commit_date = models.DateField("Date of commit to repository")
author_date = models.DateField("Date commit was writen/created")
- author = models.CharField("Name of commit author", maxlength=96)
+ author = models.CharField("Name of commit author", max_length=96)
author_email = models.CharField("Email address of commit author",\
- maxlength=196)
- committer = models.CharField("Name of committer", maxlength=96)
+ max_length=196)
+ committer = models.CharField("Name of committer", max_length=96)
committer_email = models.CharField("Email address of committer", \
- maxlength=196)
+ max_length=196)
comment = models.TextField("Notes on the commit")
- parenthash = models.CharField("parent's hash", maxlength=40)
+ parenthash = models.CharField("parent's hash", max_length=40)
#TODO: parent = models.ForeignKey()
- treehash = models.CharField("tree object's hash", maxlength=40)
+ treehash = models.CharField("tree object's hash", max_length=40)
tree = models.ForeignKey(Tree)
type='commit'
@@ -266,3 +266,10 @@ def shortlog(hash=None,tree=None):
logobj['shortdescription'] = logobj['description'][:128]
shortlog.append(logobj)
return shortlog
+
+from django.contrib import admin
+
+admin.site.register(Tree)
+admin.site.register(Item)
+admin.site.register(Commit)
+
diff --git a/bn_django/git_wiki/templates/git_wiki/item.html b/bn_django/git_wiki/templates/git_wiki/item.html
index 51680ef..98f1647 100644
--- a/bn_django/git_wiki/templates/git_wiki/item.html
+++ b/bn_django/git_wiki/templates/git_wiki/item.html
@@ -12,7 +12,7 @@
{% block gitwiki %}
&nbsp;
-{{ doc.html_body }}
+{{ doc.html_body|safe }}
<br /><hr />
<h3>Meta</h3>
<b>Item name:</b>
@@ -29,6 +29,8 @@
<br />
{% endblock %}
+{% comment %}
+BROKEN, comments need char type primary keys
{% block commentary %}
<div class="content" id="commentary">
{% load comments %}
@@ -46,3 +48,4 @@ They will be lost if the item is updated.</em></p>
{% include "comment_list" %}
</div>
{% endblock %}
+{% endcomment %}
diff --git a/bn_django/photos/models.py b/bn_django/photos/models.py
index 925f91b..e81ee3c 100644
--- a/bn_django/photos/models.py
+++ b/bn_django/photos/models.py
@@ -1,5 +1,5 @@
from django.db import models
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ugettext as _
import django.contrib.auth.models as auth
from django.conf import settings
from django.dispatch import dispatcher
@@ -30,8 +30,8 @@ if ADMIN_URL[-1] == '/':
# Create your models here.
class Gallery(models.Model):
- title = models.CharField(_("title"), maxlength=80)
- slug = models.SlugField(prepopulate_from=("title",))
+ title = models.CharField(_("title"), max_length=80)
+ slug = models.SlugField()
date = models.DateField(_("publication date"), auto_now_add=True)
created = models.ForeignKey(auth.User,
verbose_name=_("gallery created by")
@@ -54,6 +54,7 @@ class Gallery(models.Model):
class Admin:
ordering = ['date']
+ prepopulated_fields = {'slug': 'title'}
def __str__(self):
return self.title
@@ -78,10 +79,10 @@ class Photo(models.Model):
# import os, os.path, Image
image = models.ImageField(_("Photograph"),
upload_to= STOCKPHOTO_BASE + "/%Y/%m/%d/")
- title = models.CharField(_("title"), maxlength=80)
+ title = models.CharField(_("title"), max_length=80)
desc = models.TextField(_("description"), blank=True)
gallery = models.ForeignKey(Gallery)
- photographer = models.CharField(_("photographer"), maxlength=80,
+ photographer = models.CharField(_("photographer"), max_length=80,
blank=True)
date = models.DateField(_("date photographed"), blank=True, null=True)
extra = models.TextField(_("any extra information about the photo"),
@@ -128,14 +129,14 @@ class Photo(models.Model):
def thumbpath(self):
"""Path to the thumbnail
"""
- photobase = self.image[len(STOCKPHOTO_BASE)+1:]
+ photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
return os.path.join( settings.MEDIA_ROOT, STOCKPHOTO_BASE,
"cache", "thumbs", photobase)
def thumburl(self):
"""URL to the thumbnail
"""
- photobase = self.image[len(STOCKPHOTO_BASE)+1:]
+ photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
if settings.MEDIA_URL.endswith('/'):
return settings.MEDIA_URL + STOCKPHOTO_BASE + \
"/cache/thumbs/" + photobase
@@ -144,12 +145,12 @@ class Photo(models.Model):
def disppath(self):
- photobase = self.image[len(STOCKPHOTO_BASE)+1:]
+ photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
return os.path.join( settings.MEDIA_ROOT, STOCKPHOTO_BASE,
"cache", photobase)
def dispurl(self):
- photobase = self.image[len(STOCKPHOTO_BASE)+1:]
+ photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
if settings.MEDIA_URL.endswith('/'):
return settings.MEDIA_URL + STOCKPHOTO_BASE + "/cache/" \
+ photobase
@@ -157,19 +158,19 @@ class Photo(models.Model):
"/cache/" + photobase
def fullpath(self):
- if self.image.startswith(os.path.sep):
- return self.image
- return os.path.join(settings.MEDIA_ROOT, self.image)
+ if self.image.name.startswith(os.path.sep):
+ return self.image.name
+ return os.path.join(settings.MEDIA_ROOT, self.image.name)
def fullurl(self):
- if self.image.startswith(os.path.sep):
+ if self.image.name.startswith(os.path.sep):
# Shouldn't happen anymore
return (settings.MEDIA_URL +
- self.image[len(settings.MEDIA_ROOT):])
+ self.image.name[len(settings.MEDIA_ROOT):])
else:
if settings.MEDIA_URL.endswith('/'):
- return settings.MEDIA_URL + self.image
- return settings.MEDIA_URL + '/' + self.image
+ return settings.MEDIA_URL + self.image.name
+ return settings.MEDIA_URL + '/' + self.image.name
def next(self):
@@ -280,7 +281,17 @@ def delete_thumbnails(sender, instance, signal, *args, **kwargs):
"""
instance.delete_thumbnails()
-dispatcher.connect(build_display_images, signal=signals.post_save,
- sender=Photo)
-dispatcher.connect(delete_thumbnails, signal=signals.pre_delete,
- sender=Photo)
+signals.post_save.connect(build_display_images, sender=Photo)
+signals.pre_delete.connect(delete_thumbnails, sender=Photo)
+
+#dispatcher.connect(build_display_images, signal=signals.post_save,
+# sender=Photo)
+#dispatcher.connect(delete_thumbnails, signal=signals.pre_delete,
+# sender=Photo)
+
+
+from django.contrib import admin
+
+admin.site.register(Photo)
+admin.site.register(Gallery)
+
diff --git a/bn_django/urls.py b/bn_django/urls.py
index 7f602e2..f37eca0 100644
--- a/bn_django/urls.py
+++ b/bn_django/urls.py
@@ -1,8 +1,11 @@
from django.conf.urls.defaults import *
from photos.models import Photo
from django.contrib.comments.models import Comment,FreeComment
+from django.contrib import admin
import git_wiki.models
+admin.autodiscover()
+
urlpatterns = patterns('',
# Example:
# (r'^bn_django/', include('bn_django.foo.urls')),
@@ -35,7 +38,8 @@ urlpatterns = patterns('',
(r'^search/', include('bn_django.search.urls')),
# Uncomment this for admin:
- (r'^admin/', include('django.contrib.admin.urls')),
+ (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ (r'^admin/(.*)', admin.site.root),
(r'^comments/', include('django.contrib.comments.urls.comments')),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',