newmediamonitoring/dashboard/models.py

413 lines
18 KiB
Python
Raw Normal View History

2020-09-03 02:55:44 +00:00
import uuid
from django.contrib.auth.models import User
from django.db import models
# 权限等级
2020-09-04 14:42:41 +00:00
2020-09-03 02:55:44 +00:00
class Level(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
name = models.CharField('等级名', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
level = models.IntegerField('级别', blank=True, null=True, default=0)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.name
# Create your models here.
2020-09-04 14:42:41 +00:00
2020-09-03 02:55:44 +00:00
class Group_type(models.Model):
2020-09-04 14:42:41 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
type = models.CharField('群组类型', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
def __str__(self):
return self.type
# 群组
2020-09-04 14:42:41 +00:00
2020-09-03 02:55:44 +00:00
class Group(models.Model):
GROUP_STATUS_CHOICES = (
2020-09-04 14:42:41 +00:00
('0', '关闭'),
('1', '开启')
2020-09-03 02:55:44 +00:00
)
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
name = models.CharField('群组名称', max_length=256, null=True, blank=True)
presentation = models.TextField('群组描述', null=True, blank=True)
image = models.FileField(upload_to='groupimage', null=True, blank=True)
2020-09-04 14:42:41 +00:00
type = models.ForeignKey(
Group_type, on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(
'状态', max_length=256, null=True, blank=True, choices=GROUP_STATUS_CHOICES)
2020-09-03 02:55:44 +00:00
province = models.CharField('', max_length=256, null=True, blank=True)
cities = models.CharField('', max_length=256, null=True, blank=True)
district = models.CharField('', max_length=256, null=True, blank=True)
town = models.CharField('', max_length=256, null=True, blank=True)
village = models.CharField('', max_length=256, null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.name
2020-09-04 14:42:41 +00:00
# 群组管理员
2020-09-03 02:55:44 +00:00
class Group_admin(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-09-04 14:42:41 +00:00
user = models.ForeignKey(
User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey(
Group, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.group.name
2020-09-04 14:42:41 +00:00
# 群组成员
2020-09-03 02:55:44 +00:00
class Group_user(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-09-04 14:42:41 +00:00
user = models.ForeignKey(
User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey(
Group, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user.username
2020-09-04 14:42:41 +00:00
# 单位类型
2020-09-03 02:55:44 +00:00
class Organizationtype(models.Model):
2020-09-04 14:42:41 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
organizationtype = models.CharField(
'单位类型', blank=True, null=True, max_length=256)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.organizationtype
# 单位
class Organization(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
name = models.CharField('单位名', max_length=256, null=True, blank=True)
image = models.FileField(upload_to='cover', null=True, blank=True)
2020-09-04 14:42:41 +00:00
organizationtype = models.ForeignKey(
Organizationtype, on_delete=models.CASCADE, null=True, blank=True)
province = models.CharField('', max_length=256, null=True, blank=True)
cities = models.CharField('', max_length=256, null=True, blank=True)
district = models.CharField('', max_length=256, null=True, blank=True)
town = models.CharField('', max_length=256, null=True, blank=True)
village = models.CharField('', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
# group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
# level = models.ForeignKey(Level,on_delete=models.CASCADE,null=True,blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.name
# 扩展用户表
class Userprofile(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField('姓名', null=True, blank=True, max_length=256)
sex = models.CharField('性别', null=True, blank=True, max_length=256)
image = models.FileField(upload_to='profile', null=True, blank=True)
2020-09-04 14:42:41 +00:00
organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True)
# 用户状态:注册进来默认为0为未审核状态审核后status=1
status = models.IntegerField('用户状态', null=True, blank=True, default=0)
2020-09-03 09:46:04 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
2020-09-03 02:55:44 +00:00
2020-09-03 09:46:04 +00:00
class Meta:
ordering = ["-created"]
2020-09-03 02:55:44 +00:00
def __str__(self):
2020-09-04 14:42:41 +00:00
return self.user.username+":"+self.name
2020-09-03 02:55:44 +00:00
def create_user_profile(sender, instance, created, **kwargs):
"""Create the UserProfile when a new User is saved"""
if created:
profile = Userprofile()
profile.user = instance
profile.save()
# 微信公众号
class Weixin(models.Model):
WEIXIN_STATUS_CHOICES = (
('1', '开启'),
('0', '关闭')
)
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('微信公众号', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
weixinid = models.CharField('微信ID', max_length=256, null=True, blank=True)
alias = models.CharField('别名', max_length=256, null=True, blank=True)
image = models.FileField(
upload_to='cover/%Y/%m/%d/', null=True, blank=True)
organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(
'状态', max_length=256, null=True, blank=True, choices=WEIXIN_STATUS_CHOICES)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.code
# 微信文章采集
class Weixin_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
title = models.CharField('文章标题', max_length=256, null=True, blank=True)
site = models.CharField('位置', max_length=256, null=True, blank=True)
date = models.CharField('发文时间', max_length=256, null=True, blank=True)
original = models.BooleanField('是否原创', null=True, blank=True)
url = models.CharField('文章链接', max_length=256, null=True, blank=True)
author = models.CharField('作者', max_length=256, null=True, blank=True)
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
reply = models.CharField('作者回复数', max_length=256, null=True, blank=True)
content = models.TextField('正文', null=True, blank=True)
2020-09-04 14:42:41 +00:00
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.title
# 微信评论
class Weixin_comment(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
comment = models.TextField('评论', null=True, blank=True)
user = models.CharField('用户', max_length=256, null=True, blank=True)
reply = models.TextField('回复', null=True, blank=True)
2020-09-04 14:42:41 +00:00
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user
# 微信错别字
class Weixin_Wrong(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
idea = models.CharField('建议', max_length=256, null=True, blank=True)
site = models.CharField('位置', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
change = models.BooleanField('是否已修改', null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.wrong
# 微博
class Weibo(models.Model):
WEIBO_STATUS_CHOICES = (
('1', '开启'),
('0', '关闭')
)
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('微博号', max_length=256, null=True, blank=True)
weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True)
alias = models.CharField('别名', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
image = models.FileField(
upload_to='cover/%Y/%m/%d/', null=True, blank=True)
organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(
'状态', max_length=256, null=True, blank=True, choices=WEIBO_STATUS_CHOICES)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.code
# 微博文章采集
class Weibo_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True)
content = models.TextField('正文', null=True, blank=True)
url = models.CharField('文章url', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
originalimageurl = models.CharField(
'原始图片url', max_length=256, null=True, blank=True)
transpondimageurl = models.CharField(
'转发图片url', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
original = models.BooleanField('是否原创', null=True, blank=True)
site = models.CharField('发布位置', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True)
tool = models.CharField('发布工具', max_length=256, null=True, blank=True)
like = models.CharField('点赞数', max_length=256, null=True, blank=True)
transpond = models.CharField('转发数', max_length=256, null=True, blank=True)
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
title = models.CharField('文章标题', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
weibo = models.ForeignKey(
Weibo, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.title
# 微博错别字
class Weibo_Wrong(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
idea = models.CharField('建议', max_length=256, null=True, blank=True)
site = models.CharField('位置', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
weibo = models.ForeignKey(
Weibo, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
change = models.BooleanField('是否已修改', null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
# 今日头条
class Toutiao(models.Model):
TOUTIAO_STATUS_CHOICES = (
('1', '开启'),
('0', '关闭')
)
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('头条号', max_length=256, null=True, blank=True)
toutiaoid = models.CharField('头条ID', max_length=256, null=True, blank=True)
alias = models.CharField('别名', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
image = models.FileField(
upload_to='cover/%Y/%m/%d/', null=True, blank=True)
organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(
'状态', max_length=256, null=True, blank=True, choices=TOUTIAO_STATUS_CHOICES)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.code
# 今日头条数据
class Toutiao_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
title = models.CharField('标题', max_length=256, null=True, blank=True)
url = models.CharField('链接', max_length=256, null=True, blank=True)
img = models.CharField('缩略图', max_length=256, null=True, blank=True)
count = models.CharField('阅读数', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
commentcount = models.CharField(
'评论数', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
reply = models.CharField('作者回复数', max_length=256, null=True, blank=True)
date = models.CharField('时间', max_length=256, null=True, blank=True)
content = models.TextField('正文', null=True, blank=True)
comment = models.TextField('评论', null=True, blank=True)
2020-09-04 14:42:41 +00:00
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.title
# 今日头条评论
class Toutiao_comment(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
comment = models.TextField('评论', null=True, blank=True)
user = models.CharField('用户', max_length=256, null=True, blank=True)
reply = models.TextField('回复', null=True, blank=True)
2020-09-04 14:42:41 +00:00
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user
# 今日头条错别字
class Toutiao_Wrong(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
idea = models.CharField('建议', max_length=256, null=True, blank=True)
site = models.CharField('位置', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
2020-09-03 02:55:44 +00:00
change = models.BooleanField('是否已修改', null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.wrong
# 其他新媒体
class Qita(models.Model):
QITA_STATUS_CHOICES = (
('1', '开启'),
('0', '关闭')
)
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
qitaid = models.CharField('新媒体ID', max_length=256, null=True, blank=True)
alias = models.CharField('别名', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
image = models.FileField(
upload_to='cover/%Y/%m/%d/', null=True, blank=True)
organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(
'状态', max_length=256, null=True, blank=True, choices=QITA_STATUS_CHOICES)
2020-09-03 02:55:44 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.name
2020-09-04 14:42:41 +00:00
# 其他新媒体监测
2020-09-03 02:55:44 +00:00
class Qita_jc(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-09-04 14:42:41 +00:00
mewnedia = models.ForeignKey(Qita, on_delete=models.CASCADE)
2020-09-03 02:55:44 +00:00
count = models.CharField('总发文量', max_length=256, null=True, blank=True)
2020-09-04 14:42:41 +00:00
count_jc = models.CharField(
'监测时间内发文量', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
reply = models.CharField('作者回复数', max_length=256, null=True, blank=True)
date = models.CharField('最近发文日期', max_length=256, null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.mewnedia.name
2020-09-04 14:42:41 +00:00
# 5级地名库
2020-09-03 02:55:44 +00:00
class Area_code_2020(models.Model):
2020-09-04 14:42:41 +00:00
code = models.CharField('区划代码', max_length=256, null=True, blank=True)
name = models.CharField('名称', max_length=256, null=True, blank=True)
level = models.CharField(
'级别1-5,省市县镇村', max_length=256, null=True, blank=True)
pcode = models.CharField('父级区划代码', max_length=256, null=True, blank=True)
2020-09-03 02:55:44 +00:00
def __str__(self):
return self.name