mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 19:40:27 +01:00
Add tests to repository
This commit is contained in:
50
tests/python/models.py
Normal file
50
tests/python/models.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib import admin
|
||||
from string import join
|
||||
from settings import MEDIA_ROOT
|
||||
|
||||
class Forum(models.Model):
|
||||
title = models.CharField(max_length=60)
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
class Thread(models.Model):
|
||||
title = models.CharField(max_length=60)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
creator = models.ForeignKey(User, blank=True, null=True)
|
||||
forum = models.ForeignKey(Forum)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.creator) + " - " + self.title
|
||||
|
||||
class Post(models.Model):
|
||||
title = models.CharField(max_length=60)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
creator = models.ForeignKey(User, blank=True, null=True)
|
||||
thread = models.ForeignKey(Thread)
|
||||
body = models.TextField(max_length=10000)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s - %s - %s" % (self.creator, self.thread, self.title)
|
||||
|
||||
def short(self):
|
||||
return u"%s - %s\n%s" % (self.creator, self.title, self.created.strftime("%b %d, %I:%M %p"))
|
||||
short.allow_tags = True
|
||||
|
||||
### Admin
|
||||
|
||||
class ForumAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
class ThreadAdmin(admin.ModelAdmin):
|
||||
list_display = ["title", "forum", "creator", "created"]
|
||||
list_filter = ["forum", "creator"]
|
||||
|
||||
class PostAdmin(admin.ModelAdmin):
|
||||
search_fields = ["title", "creator"]
|
||||
list_display = ["title", "thread", "creator", "created"]
|
||||
|
||||
admin.site.register(Forum, ForumAdmin)
|
||||
admin.site.register(Thread, ThreadAdmin)
|
||||
admin.site.register(Post, PostAdmin)
|
||||
Reference in New Issue
Block a user