|
|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
from django.db import models
|
|
|
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
# from django.template.defaultfilters import slugify
|
|
|
|
|
from uuslug import slugify
|
|
|
|
|
from DjangoBlog.spider_notify import sipder_notify
|
|
|
|
|
from DjangoBlog.spider_notify import spider_notify
|
|
|
|
|
from django.contrib.sites.models import Site
|
|
|
|
|
from DjangoBlog.utils import cache_decorator
|
|
|
|
|
from DjangoBlog.utils import cache_decorator, logger
|
|
|
|
|
from django.utils.functional import cached_property
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaseModel(models.Model):
|
|
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
|
super().save(*args, **kwargs)
|
|
|
|
|
@ -15,10 +15,10 @@ class BaseModel(models.Model):
|
|
|
|
|
if 'update_fields' in kwargs and len(kwargs['update_fields']) == 1 and kwargs['update_fields'][0] == 'views':
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
notify = sipder_notify()
|
|
|
|
|
notify_url = self.get_full_url()
|
|
|
|
|
notify.baidu_notify(notify_url)
|
|
|
|
|
spider_notify.baidu_notify(notify_url)
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
logger.error("notify sipder", ex)
|
|
|
|
|
print(ex)
|
|
|
|
|
|
|
|
|
|
def get_full_url(self):
|
|
|
|
|
@ -44,7 +44,7 @@ class Article(BaseModel):
|
|
|
|
|
('a', '文章'),
|
|
|
|
|
('p', '页面'),
|
|
|
|
|
)
|
|
|
|
|
title = models.CharField('标题', max_length=200)
|
|
|
|
|
title = models.CharField('标题', max_length=200, unique=True)
|
|
|
|
|
body = models.TextField('正文')
|
|
|
|
|
created_time = models.DateTimeField('创建时间', auto_now_add=True)
|
|
|
|
|
last_mod_time = models.DateTimeField('修改时间', auto_now=True)
|
|
|
|
|
@ -196,7 +196,7 @@ class BlogPage(models.Model):
|
|
|
|
|
|
|
|
|
|
class Category(BaseModel):
|
|
|
|
|
"""文章分类"""
|
|
|
|
|
name = models.CharField('分类名', max_length=30)
|
|
|
|
|
name = models.CharField('分类名', max_length=30, unique=True)
|
|
|
|
|
created_time = models.DateTimeField('创建时间', auto_now_add=True)
|
|
|
|
|
last_mod_time = models.DateTimeField('修改时间', auto_now=True)
|
|
|
|
|
parent_category = models.ForeignKey('self', verbose_name="父级分类", blank=True, null=True)
|
|
|
|
|
@ -215,7 +215,7 @@ class Category(BaseModel):
|
|
|
|
|
|
|
|
|
|
class Tag(BaseModel):
|
|
|
|
|
"""文章标签"""
|
|
|
|
|
name = models.CharField('标签名', max_length=30)
|
|
|
|
|
name = models.CharField('标签名', max_length=30, unique=True)
|
|
|
|
|
created_time = models.DateTimeField('创建时间', auto_now_add=True)
|
|
|
|
|
last_mod_time = models.DateTimeField('修改时间', auto_now=True)
|
|
|
|
|
|
|
|
|
|
@ -237,7 +237,7 @@ class Tag(BaseModel):
|
|
|
|
|
|
|
|
|
|
class Links(models.Model):
|
|
|
|
|
"""友情链接"""
|
|
|
|
|
name = models.CharField('链接名称', max_length=30)
|
|
|
|
|
name = models.CharField('链接名称', max_length=30, unique=True)
|
|
|
|
|
link = models.URLField('链接地址')
|
|
|
|
|
sequence = models.IntegerField('排序', unique=True)
|
|
|
|
|
created_time = models.DateTimeField('创建时间', auto_now_add=True)
|
|
|
|
|
|