Commit ddbf3b99 authored by lixiaofang's avatar lixiaofang

add

parent 69504c7f
......@@ -3,21 +3,17 @@ import logging
from trans2es.models.topic import TopicTag, TopicImage, CommunityTopicProduct, Topic
from django.conf import settings
from trans2es.models.pictorial import PictorialTag
from random import randint
from random import randint
from trans2es.models.user_extra import UserExtra
from django.db import models
def get_edit_tag_id_list(topic_id):
try:
has_edit = False
tag_id_list = TopicTag.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=topic_id,
is_collection=1).values_list("tag_id",
flat=True)
if len(tag_id_list) > 0:
has_edit = True
return has_edit
return tag_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
......@@ -53,20 +49,16 @@ def get_topic_product_info(topic_id):
return []
def get_pictorial_tag_by_id(self):
def get_pictorial_tag_by_id(pictorial_id):
try:
has_edit = False
tag_id_list = list(
PictorialTag.objects.filter(pictorial_id=self.id, is_online=True).values_list("tag_id", flat=True))
tag_id_list = list(PictorialTag.objects.filter(pictorial_id=pictorial_id, is_online=True, is_collection=1).values_list("tag_id", flat=True))
if len(tag_id_list) > 0:
has_edit = True
return has_edit
return tag_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
# def get_topic_data(numtime, numitme2):
# try:
#
......
import pymysql
import traceback
import logging
from vest.request.auto_request import login, time_conv, get_comment, reply
from vest.request.auto_request import login, time_conv, get_comment, reply,get_product_comment,get_face_comment
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
......@@ -67,20 +68,22 @@ def true_comment_one():
if user_id:
for i in user_id:
comment = ""
#先判断是不是编辑标签
# 先判断是不是编辑标签
edit_judge = get_edit_tag_id_list(i[1])
if edit_judge:
if len(edit_judge) > 0:
rand_tag_id = random.randint(0, len(edit_judge)-1)
comment = get_comment()
else:
# 判断有没有商品信息
product_judge = get_topic_product_info(i[1])
if product_judge:
comment = get_comment()
comment = get_product_comment()
else:
#判断有没有人脸
# 判断有没有人脸
face_judge = topic_has_image(i[1])
if face_judge:
comment = get_comment()
comment = get_face_comment()
else:
comment = get_comment()
......
......@@ -469,3 +469,39 @@ def get_pictorial_comment():
except:
return None
def get_product_comment():
try:
data = open("/srv/apps/physical/vest/data/pictorial_reply_data.txt", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
def get_face_comment():
try:
data = open("/srv/apps/physical/vest/data/pictorial_reply_data.txt", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment