from django.db import models
from django.contrib import admin
from DjangoUeditor.models import UEditorField

class User(models.Model):
      name=models.CharField(max_length=30)
      password=models.CharField(max_length=40)
      def __unicode__(self):
          return self.name

class BlogCategory(models.Model):
      userID=models.CharField(max_length=30)
      name=models.CharField(max_length=30,primary_key=True)
      num=models.IntegerField(max_length=10,default="0")
      def __unicode__(self):
        return self.name

class BlogPost(models.Model):
      title=models.CharField(max_length=150)
      body=models.TextField()
      tag=models.CharField(max_length=100)
      timestamp=models.DateTimeField()
      def __unicode__(self):
          return self.title
class BlogTable1(models.Model):
      userID=models.CharField(max_length=10)
      userName=models.CharField(max_length=30)
      title=models.CharField(max_length=150)
      body=UEditorField(width=600, height=300, toolbars="full")
      category=models.ForeignKey(BlogCategory,default="0")
      tag=models.CharField(max_length=100)
      timestamp=models.DateTimeField()
      readnum=models.CharField(max_length=10,default=0)
      commentnum=models.IntegerField(max_length=10,default=0)
      def __unicode__(self):
          return self.title
      
      class Meta:
          ordering = ['-timestamp']
class BlogComment(models.Model):
      uid=models.CharField(max_length=10)
      uname=models.CharField(max_length=30)
      bid=models.CharField(max_length=10)
      content=models.TextField()
      timestamp=models.DateTimeField()
      def __unicode__(self):
          return self.bid


admin.site.register(BlogCategory)
admin.site.register(BlogPost)
admin.site.register(BlogTable1)
admin.site.register(User)
admin.site.register(BlogComment)
# Create your models here.
