newmediamonitoring/dashboard/models.py

830 lines
32 KiB
Python
Raw Normal View History

2020-09-13 06:06:21 +00:00
import uuid
from django.contrib.auth.models import User
from django.db import models
2020-11-17 00:45:44 +00:00
from django.db.models import Q
2020-10-22 07:15:02 +00:00
2020-09-13 06:06:21 +00:00
# 权限等级
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +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)
level = models.IntegerField('级别', blank=True, null=True, default=0)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.name
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +00:00
class Group_type(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-09-17 08:10:13 +00:00
type = models.CharField('矩阵类型', max_length=256, null=True, blank=True)
2020-09-13 06:06:21 +00:00
def __str__(self):
return self.type
2020-10-22 07:15:02 +00:00
2020-09-17 08:10:13 +00:00
# 矩阵
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +00:00
class Group(models.Model):
2020-09-29 01:49:28 +00:00
GROUP_CLASSIFY_CHOICES = (
('0', '区域'),
('1', '媒体种类'),
('2', '行业'),
2020-10-25 11:49:42 +00:00
('3', '管理')
2020-09-29 01:49:28 +00:00
)
2020-09-13 06:06:21 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-09-17 08:10:13 +00:00
name = models.CharField('矩阵名称', max_length=256, null=True, blank=True)
presentation = models.TextField('矩阵描述', null=True, blank=True)
2020-09-13 06:06:21 +00:00
image = models.FileField(upload_to='groupimage', null=True, blank=True)
type = models.ForeignKey(
Group_type, on_delete=models.CASCADE, null=True, blank=True)
2020-09-24 06:37:12 +00:00
status = models.IntegerField(
2020-10-08 07:12:48 +00:00
'状态', null=True, blank=True, default=0)
2020-09-13 06:06:21 +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)
2020-10-08 07:12:48 +00:00
classify = models.CharField(
'分类', max_length=256, null=True, blank=True, choices=GROUP_CLASSIFY_CHOICES)
2020-10-25 14:18:41 +00:00
rank = models.IntegerField('rank', default=0)
2020-09-22 03:48:12 +00:00
user = models.ForeignKey(
User, on_delete=models.CASCADE, blank=True, null=True)
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
2020-10-10 14:44:15 +00:00
def total_user(self):
return self.group_user_set.count()
2020-09-13 06:06:21 +00:00
def __str__(self):
return self.name
2020-10-25 14:56:33 +00:00
class Meta:
ordering = ["rank"]
2020-10-22 07:15:02 +00:00
2020-10-10 07:46:04 +00:00
# 矩阵管理员
2020-09-22 03:48:12 +00:00
2020-10-10 07:46:04 +00:00
class Group_admin(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
user = models.ForeignKey(
User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey(
Group, 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.group.name
2020-10-22 07:15:02 +00:00
2020-11-01 07:37:53 +00:00
class Meta:
ordering = ["created"]
2020-10-22 07:15:02 +00:00
2020-09-17 08:10:13 +00:00
# 矩阵成员
2020-10-10 07:46:04 +00:00
class Group_user(models.Model):
2020-09-13 06:06:21 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
user = models.ForeignKey(
User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey(
Group, 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.user.username
2020-10-22 07:15:02 +00:00
2020-09-13 06:06:21 +00:00
# 单位类型
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +00:00
class Organizationtype(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
organizationtype = models.CharField(
'单位类型', blank=True, null=True, max_length=256)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.organizationtype
# 单位
2021-03-28 14:41:15 +00:00
2020-09-13 06:06:21 +00:00
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-10-15 01:06:37 +00:00
# organizationtype = models.ForeignKey(
# Organizationtype, on_delete=models.CASCADE, null=True, blank=True)
2020-09-13 06:06:21 +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)
2020-09-22 03:48:12 +00:00
level = models.ForeignKey(
Level, on_delete=models.CASCADE, null=True, blank=True)
2020-09-24 06:37:12 +00:00
directly = models.CharField('单位类型', max_length=256, null=True, blank=True)
2020-10-08 07:12:48 +00:00
status = models.CharField('状态', max_length=256, null=True, blank=True)
2020-10-15 01:06:37 +00:00
2020-10-22 07:15:02 +00:00
# 20201014新添加字段
2020-10-25 11:49:42 +00:00
id_code = models.CharField(
'单位唯一标识码', max_length=256, null=True, blank=True)
2020-10-15 01:06:37 +00:00
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
2020-09-23 09:47:05 +00:00
class Meta:
ordering = ["name"]
2020-09-13 06:06:21 +00:00
def __str__(self):
return self.name
2020-10-21 13:37:19 +00:00
def is_direct(self):
return self.province != '' and self.cities == ''
2020-09-13 06:06:21 +00:00
# 扩展用户表
class Userprofile(models.Model):
2020-10-25 18:11:34 +00:00
"""
admin_status:
'0': '已删除',
'1': '添加申请市级审核中',
'2': '添加申请省级审核中',
'3': '正常',
'4': '注销申请市级审核中',
'5': '注销申请省级审核中',
"""
2020-09-13 06:06:21 +00:00
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)
2020-09-20 11:20:19 +00:00
unit = models.CharField('自己输入单位', null=True, blank=True, max_length=256)
2020-09-17 08:23:27 +00:00
department = models.CharField('部门', null=True, blank=True, max_length=256)
post = models.CharField('职务', null=True, blank=True, max_length=256)
2020-09-13 06:06:21 +00:00
image = models.FileField(upload_to='profile', null=True, blank=True)
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-10-25 18:11:34 +00:00
admin_status = models.IntegerField('管理状态', default=3)
2021-03-14 05:33:51 +00:00
message_status = models.BooleanField('是否发送消息', default=True)
2021-03-28 03:10:50 +00:00
platform = models.CharField('手机操作系统', null=True, blank=True, max_length=32)
2020-10-22 07:15:02 +00:00
# 20201017新增字段职位
zhiwei = models.CharField('职位', max_length=256, null=True, blank=True)
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
class Meta:
ordering = ["-created"]
2020-09-30 08:02:29 +00:00
def is_level1(self):
2020-11-17 00:45:44 +00:00
return self.organization.level.level == 1 or self.organization.level.level == 9
2020-09-30 08:02:29 +00:00
def is_level2(self):
return self.organization.level.level == 2
2020-10-08 07:12:48 +00:00
@classmethod
def level2_admin(cls, cities):
return Userprofile.objects.filter(organization__level__level=2, organization__cities=cities)
@classmethod
def level1_admin(cls):
2020-11-17 00:45:44 +00:00
return Userprofile.objects.filter(Q(organization__level__level=1) | Q(organization__level__level=9))
2020-10-08 07:12:48 +00:00
2020-09-13 06:06:21 +00:00
def __str__(self):
2021-01-26 07:49:57 +00:00
if self.is_level1():
2020-10-21 13:37:19 +00:00
return '省级管理员%s' % (self.name,)
2021-01-26 07:49:57 +00:00
elif self.is_level2():
2020-10-21 13:37:19 +00:00
return '市级管理员%s' % (self.name,)
return self.name
2020-09-13 06:06:21 +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 NewMedia(models.Model):
2020-10-22 07:15:02 +00:00
"""
status:
'0': '已删除',
'1': '添加申请市级审核中',
'2': '添加申请省级审核中',
'3': '正常',
'4': '注销申请市级审核中',
'5': '注销申请省级审核中',
"""
2020-09-13 06:06:21 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('微信公众号', 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)
2020-09-24 06:37:12 +00:00
status = models.IntegerField(
2020-10-08 07:12:48 +00:00
'状态', null=True, blank=True, default=0)
2020-09-22 03:48:12 +00:00
attention = models.CharField('关注量', null=True, blank=True, max_length=256)
remark = models.CharField('备注', null=True, blank=True, max_length=2560)
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
2020-10-22 07:15:02 +00:00
# 20201015新增字段
2020-10-25 11:49:42 +00:00
identificationcode = models.CharField(
'新媒体标识码', max_length=256, null=True, blank=True)
2020-10-22 07:15:02 +00:00
function = models.CharField('功能', max_length=256, null=True, blank=True)
articleurl = models.TextField('文章URL', null=True, blank=True)
2020-09-13 06:06:21 +00:00
class Meta:
abstract = True
ordering = ["-created"]
2020-09-22 03:48:12 +00:00
@classmethod
def category_one_count(cls):
t1 = Weixin.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province=''
).filter(
organization__cities='',
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t2 = Weibo.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province=''
).filter(
organization__cities='',
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t3 = Toutiao.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province=''
).filter(
organization__cities='',
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t4 = Douyin.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province=''
).filter(
organization__cities='',
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t5 = Qita.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province=''
).filter(
organization__cities='',
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
return t1 + t2 + t3 + t4 + t5
@classmethod
def category_two_count(cls):
t1 = Weixin.objects.exclude(
organization__province='',
2020-10-22 04:05:23 +00:00
organization__cities='',
status=0
2020-09-22 03:48:12 +00:00
).filter(
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t2 = Weibo.objects.exclude(
organization__province='',
2020-10-22 04:05:23 +00:00
organization__cities='',
status=0
2020-09-22 03:48:12 +00:00
).filter(
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t3 = Toutiao.objects.exclude(
organization__province='',
2020-10-22 04:05:23 +00:00
organization__cities='',
status=0
2020-09-22 03:48:12 +00:00
).filter(
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t4 = Douyin.objects.exclude(
organization__province='',
2020-10-22 04:05:23 +00:00
organization__cities='',
status=0
2020-09-22 03:48:12 +00:00
).filter(
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
t5 = Qita.objects.exclude(
organization__province='',
2020-10-22 04:05:23 +00:00
organization__cities='',
status=0
2020-09-22 03:48:12 +00:00
).filter(
2020-10-22 04:05:23 +00:00
organization__district='',
2020-09-22 03:48:12 +00:00
).count()
return t1 + t2 + t3 + t4 + t5
@classmethod
def category_three_count(cls):
t1 = Weixin.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province='',
organization__cities='',
organization__district=''
).count()
t2 = Weibo.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province='',
organization__cities='',
organization__district=''
).count()
t3 = Toutiao.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province='',
organization__cities='',
organization__district=''
).count()
t4 = Douyin.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province='',
organization__cities='',
organization__district=''
).count()
t5 = Qita.objects.exclude(
2020-10-22 04:05:23 +00:00
status=0,
2020-09-22 03:48:12 +00:00
organization__province='',
organization__cities='',
organization__district=''
).count()
return t1 + t2 + t3 + t4 + t5
@classmethod
def media_list(cls, organization_id):
2020-10-08 07:12:48 +00:00
weixin = Weixin.objects.filter(
organization_id=organization_id).exclude(status=0)
weibo = Weibo.objects.filter(
organization_id=organization_id).exclude(status=0)
toutiao = Toutiao.objects.filter(
organization_id=organization_id).exclude(status=0)
douyin = Douyin.objects.filter(
organization_id=organization_id).exclude(status=0)
qita = Qita.objects.filter(
organization_id=organization_id).exclude(status=0)
2020-09-22 03:48:12 +00:00
results = []
for o in weixin:
result = dict()
result['id'] = o.id
result['code'] = o.code
result['alias'] = o.alias
2020-10-08 07:12:48 +00:00
result['status'] = o.status
2020-09-22 03:48:12 +00:00
result['type'] = 'weixin'
2021-03-28 14:41:15 +00:00
result['subtype'] = ''
2020-09-22 03:48:12 +00:00
results.append(result)
for o in weibo:
result = dict()
result['id'] = o.id
result['code'] = o.code
result['alias'] = o.alias
2020-10-08 07:12:48 +00:00
result['status'] = o.status
2020-09-22 03:48:12 +00:00
result['type'] = 'weibo'
2021-03-28 14:41:15 +00:00
result['subtype'] = ''
2020-09-22 03:48:12 +00:00
results.append(result)
for o in toutiao:
result = dict()
result['id'] = o.id
result['code'] = o.code
result['alias'] = o.alias
2020-10-08 07:12:48 +00:00
result['status'] = o.status
2020-09-22 03:48:12 +00:00
result['type'] = 'toutiao'
2021-03-28 14:41:15 +00:00
result['subtype'] = ''
2020-09-22 03:48:12 +00:00
results.append(result)
for o in douyin:
result = dict()
result['id'] = o.id
result['code'] = o.code
result['alias'] = o.alias
2020-10-08 07:12:48 +00:00
result['status'] = o.status
2020-09-22 03:48:12 +00:00
result['type'] = 'douyin'
2021-03-28 14:41:15 +00:00
result['subtype'] = ''
2020-09-22 03:48:12 +00:00
results.append(result)
for o in qita:
result = dict()
result['id'] = o.id
result['code'] = o.code
result['alias'] = o.alias
2020-10-08 07:12:48 +00:00
result['status'] = o.status
2020-09-22 03:48:12 +00:00
result['type'] = 'qita'
2021-03-28 14:41:15 +00:00
result['subtype'] = o.type
2020-09-22 03:48:12 +00:00
results.append(result)
return results
2020-09-13 06:06:21 +00:00
def __str__(self):
return self.code + ':' + self.alias
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +00:00
# 微信公众号
class Weixin(NewMedia):
weixinid = models.CharField('微信ID', max_length=256, null=True, blank=True)
# 微信文章采集
class Weixin_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
2021-03-28 14:41:15 +00:00
mp = models.CharField('mp', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
content = models.TextField('content', null=True, blank=True)
author = models.CharField('author', max_length=256, null=True, blank=True)
timestamp = models.CharField(
'timestamp', max_length=256, null=True, blank=True)
link = models.CharField('link', max_length=2560, null=True, blank=True)
2020-09-13 06:06:21 +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)
weixin = models.ForeignKey(
Weixin, 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.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)
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
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(NewMedia):
weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True)
# 微博文章采集
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)
originalimageurl = models.CharField(
'原始图片url', max_length=256, null=True, blank=True)
transpondimageurl = models.CharField(
'转发图片url', max_length=256, null=True, blank=True)
original = models.BooleanField('是否原创', null=True, blank=True)
site = models.CharField('发布位置', max_length=256, null=True, blank=True)
year = models.CharField('', max_length=256, null=True, blank=True)
month = models.CharField('', max_length=256, null=True, blank=True)
day = models.CharField('', max_length=256, null=True, blank=True)
2020-09-13 06:06:21 +00:00
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)
weibo = models.ForeignKey(
Weibo, 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.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)
weibo = models.ForeignKey(
Weibo, on_delete=models.CASCADE, null=True, blank=True)
change = models.BooleanField('是否已修改', null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
# 今日头条
class Toutiao(NewMedia):
toutiaoid = models.CharField('头条ID', max_length=256, null=True, blank=True)
# 今日头条数据
class Toutiao_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
2021-01-06 07:14:57 +00:00
tid = models.CharField('tid', max_length=256, null=True, blank=True)
2021-03-28 14:41:15 +00:00
celltype = models.CharField(
'celltype', max_length=256, null=True, blank=True)
2021-01-06 07:14:57 +00:00
title = models.CharField('标题', max_length=256, null=True, blank=True)
2021-03-28 14:41:15 +00:00
content = models.TextField('内容', null=True, blank=True)
2021-01-06 07:14:57 +00:00
time = models.CharField('时间', max_length=256, null=True, blank=True)
url = models.CharField('链接', max_length=256, null=True, blank=True)
commentcount = models.IntegerField('评论量', null=True, blank=True)
readnum = models.IntegerField('阅读量', null=True, blank=True)
likenum = models.IntegerField('点赞量', null=True, blank=True)
shownum = models.IntegerField('点击量', null=True, blank=True)
2020-09-13 06:06:21 +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)
2021-01-07 04:04:02 +00:00
# comment = models.TextField('评论', null=True, blank=True)
# user = models.CharField('用户', max_length=256, null=True, blank=True)
# reply = models.TextField('回复', null=True, blank=True)
# toutiao = models.ForeignKey(
# Toutiao, on_delete=models.CASCADE, null=True, blank=True)
2021-03-28 14:41:15 +00:00
type = models.CharField('type', max_length=256, null=True, blank=True)
tid = models.CharField('tid', max_length=256, null=True, blank=True)
cid = models.CharField('cid', max_length=256, null=True, blank=True)
rid = models.CharField('rid', max_length=256, null=True, blank=True)
username = models.CharField(
'username', max_length=256, null=True, blank=True)
content = models.TextField('content', null=True, blank=True)
time = models.CharField('time', max_length=256, null=True, blank=True)
reply_count = models.IntegerField('reply_count', null=True, blank=True)
diggcount = models.IntegerField('diggcount', null=True, blank=True)
2021-01-07 04:04:02 +00:00
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
2021-01-07 04:04:02 +00:00
return self.username
2020-09-13 06:06:21 +00:00
# 今日头条错别字
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)
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
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
2020-09-13 09:30:46 +00:00
# 抖音
class Douyin(NewMedia):
douyinid = models.CharField('抖音ID', max_length=256, null=True, blank=True)
# 抖音数据
class Douyin_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
mewnedia = models.ForeignKey(Douyin, on_delete=models.CASCADE)
count = models.CharField('总发文量', max_length=256, null=True, blank=True)
count_jc = 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)
2020-09-17 08:10:13 +00:00
date = models.DateField('最近发文日期', max_length=256, null=True, blank=True)
2020-09-13 09:30:46 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.mewnedia.code
2020-10-22 07:15:02 +00:00
2020-09-13 06:06:21 +00:00
# 其他新媒体
2020-09-22 03:48:12 +00:00
2020-09-13 06:06:21 +00:00
class Qita(NewMedia):
type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
qitaid = models.CharField('新媒体ID', max_length=256, null=True, blank=True)
def __str__(self):
2020-10-15 03:03:23 +00:00
return self.qitaid
2020-09-13 06:06:21 +00:00
2020-10-22 07:15:02 +00:00
2020-09-13 06:06:21 +00:00
# 其他新媒体监测
class Qita_jc(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
mewnedia = models.ForeignKey(Qita, on_delete=models.CASCADE)
count = models.CharField('总发文量', max_length=256, null=True, blank=True)
count_jc = 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)
2020-09-17 08:10:13 +00:00
date = models.DateField('最近发文日期', max_length=256, null=True, blank=True)
2020-09-13 06:06:21 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
2021-01-06 07:14:57 +00:00
return self.mewnedia.code
2020-10-22 07:15:02 +00:00
2020-09-13 06:06:21 +00:00
# 5级地名库
class Area_code_2020(models.Model):
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)
def __str__(self):
return self.name
2020-09-23 09:47:05 +00:00
class Meta:
ordering = ["code"]
2020-09-22 03:48:12 +00:00
# 新闻
2020-09-13 06:06:21 +00:00
class News(models.Model):
NEWMEDIA_NEWS_CHOICES = (
2020-09-13 06:20:15 +00:00
('0', '政策依据'),
('1', '基层动态'),
2020-09-13 09:30:46 +00:00
('2', '外省动态'),
('3', '监测通报'),
2020-09-24 06:37:12 +00:00
('4', '舆情热点'),
('5', '通知'),
('6', '重点新闻'),
2020-09-13 06:06:21 +00:00
)
2020-09-22 03:48:12 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
type = models.CharField('文章类型', max_length=256, null=True,
blank=True, choices=NEWMEDIA_NEWS_CHOICES)
source = models.CharField('文章来源', max_length=256, null=True, blank=True)
title = models.CharField('文章标题', max_length=256, null=True, blank=True)
2020-09-13 09:30:46 +00:00
image = models.FileField(
upload_to='news/%Y/%m/%d/', null=True, blank=True)
2020-09-22 03:48:12 +00:00
author = models.CharField('作者', max_length=256, null=True, blank=True)
date = models.DateField('发表日期', null=True, blank=True, max_length=256)
content = models.TextField('内容', null=True, blank=True)
2020-09-13 09:30:46 +00:00
2020-09-13 06:06:21 +00:00
def __str__(self):
return self.title
2020-10-13 13:33:48 +00:00
2020-10-25 14:18:41 +00:00
class Meta:
ordering = ["-date"]
2020-10-22 07:15:02 +00:00
# 手机验证码验证表
2020-10-13 13:33:48 +00:00
class CheckCode(models.Model):
2020-10-25 11:49:42 +00:00
phone_code = models.CharField(
'手机验证码', max_length=256, null=True, blank=True)
2020-10-22 07:15:02 +00:00
phone = models.CharField('电话号', max_length=256, null=True, blank=True)
c_time = models.DateTimeField('时间', auto_now_add=True)
2020-10-23 00:50:51 +00:00
2020-10-25 12:01:49 +00:00
# 新媒体舆情临时表
2020-10-23 00:50:51 +00:00
class NewmediaSentimentWeixin(models.Model):
2020-10-25 12:01:49 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('公众号', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
comment_count = models.CharField(
'评论数', max_length=256, null=True, blank=True)
reply_count = models.CharField(
'回复数', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True)
2020-10-23 00:50:51 +00:00
def __str__(self):
return self.title
2020-10-25 12:01:49 +00:00
2020-10-23 00:50:51 +00:00
class NewmediaSentimentWeibo(models.Model):
2020-10-25 12:01:49 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('微博号', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
comment_count = models.CharField(
'评论数', max_length=256, null=True, blank=True)
reply_count = models.CharField(
'回复数', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True)
2020-10-23 00:50:51 +00:00
def __str__(self):
return self.title
2020-10-25 12:01:49 +00:00
2020-10-23 00:50:51 +00:00
class NewmediaSentimentToutiao(models.Model):
2020-10-25 12:01:49 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
code = models.CharField('头条号', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
comment_count = models.CharField(
'评论数', max_length=256, null=True, blank=True)
reply_count = models.CharField(
'回复数', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True)
2020-10-23 00:50:51 +00:00
def __str__(self):
return self.title
2020-10-25 12:01:49 +00:00
2021-01-06 07:14:57 +00:00
# 时效性监测临时表
2020-10-23 00:50:51 +00:00
class TimelinessMonitoring(models.Model):
2020-11-17 10:25:42 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2020-10-25 18:11:34 +00:00
n_type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
2021-01-06 07:14:57 +00:00
# name = models.ForeignKey(NewMedia,on_delete=models.CASCADE)
2021-03-28 14:41:15 +00:00
identificationcode = models.CharField(
'新媒体标识码', max_length=256, null=True, blank=True)
2020-10-25 18:11:34 +00:00
results = models.CharField('监测结果', max_length=256, null=True, blank=True)
2020-10-28 15:31:17 +00:00
update = models.IntegerField('更新次数', null=True, blank=True)
2021-01-06 07:14:57 +00:00
silent = models.IntegerField('静默日数', null=True, blank=True)
2020-10-25 18:11:34 +00:00
start_data = models.CharField(
'开始时间', max_length=256, null=True, blank=True)
end_data = models.CharField('结束时间', max_length=256, null=True, blank=True)
2021-01-06 07:14:57 +00:00
date = models.CharField('时间', max_length=256, null=True, blank=True)
date_length = models.CharField('时间', max_length=256, null=True, blank=True)
city = models.CharField('', max_length=256, null=True, blank=True)
district = models.CharField('', max_length=256, null=True, blank=True)
2020-10-23 00:50:51 +00:00
def __str__(self):
2021-01-06 07:14:57 +00:00
return self.id
2020-10-23 00:50:51 +00:00
2020-10-25 14:22:21 +00:00
2020-10-25 12:01:49 +00:00
# 错别字临时表
2020-10-23 00:50:51 +00:00
class Wrongly(models.Model):
2020-10-25 12:01:49 +00:00
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
error = models.CharField('错误', max_length=256, null=True, blank=True)
idea = models.CharField('建议', max_length=256, null=True, blank=True)
site = models.TextField('上下文', null=True, blank=True)
n_type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
n_name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
2020-11-18 07:48:17 +00:00
city = models.CharField('', max_length=256, null=True, blank=True)
jc_date = models.CharField('监测时间', max_length=256, null=True, blank=True)
2020-10-23 00:50:51 +00:00
def __str__(self):
return self.title
2021-03-28 14:41:15 +00:00
# 评论临时表
2020-11-18 07:48:17 +00:00
class 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)
2021-03-28 14:41:15 +00:00
name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True)
date = models.CharField('时间', max_length=256, null=True, blank=True)
url = models.CharField('文章链接', max_length=256, null=True, blank=True)
2020-11-18 07:48:17 +00:00
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user
2020-11-17 10:25:42 +00:00
2021-03-28 14:41:15 +00:00
# 新媒体更新表(国办)
2020-12-30 08:01:57 +00:00
class Newmediaupdate(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
2021-03-28 14:41:15 +00:00
organization_name = models.CharField(
'单位全称', max_length=256, null=True, blank=True)
organization_id_code = models.CharField(
'单位唯一标识码', max_length=256, null=True, blank=True)
identificationcode = models.CharField(
'新媒体标识码', max_length=256, null=True, blank=True)
newmedia_name = models.CharField(
'账号名称', max_length=256, null=True, blank=True)
newmedia_type = models.CharField(
'账号类型', max_length=256, null=True, blank=True)
2020-12-30 08:01:57 +00:00
function = models.CharField('功能', max_length=256, 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)
articleurl = models.TextField('文章URL', null=True, blank=True)
biz = models.TextField('BIZ,账号id', null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
2020-11-17 10:25:42 +00:00
2020-12-30 08:01:57 +00:00
def __str__(self):
2021-03-28 14:41:15 +00:00
return self.newmedia_name