Commit f32a416c authored by kai's avatar kai

update

parent 2cc5d28c
...@@ -312,20 +312,28 @@ class Topic(models.Model): ...@@ -312,20 +312,28 @@ class Topic(models.Model):
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] return []
def get_latest_reply_date(self): def get_latest_reply_date(self):
try: try:
reply_query_results = Reply.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id,is_deleted=0,is_online=1).values("user_id", "create_time") reply_query_results = Reply.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, is_deleted=0,
is_online=1).values("user_id",
"create_time")
datetime_list = list() datetime_list = list()
if reply_query_results.count() > 0: if reply_query_results.count() > 0:
for reply in reply_query_results: for reply in reply_query_results:
UserExtra_results = UserExtra.objects.using(settings.SLAVE_DB_NAME).filter(user_id = reply['user_id']) UserExtra_results = UserExtra.objects.using(settings.SLAVE_DB_NAME).filter(
if not UserExtra_results['is_shadow']: user_id=reply['user_id']).values('is_shadow')
datetime_list.append(reply['create_time']) if UserExtra_results.count() > 0:
return max(datetime_list) if not UserExtra_results[0]['is_shadow']:
datetime_list.append(reply['create_time'])
dt = max(datetime_list)
return datetime.datetime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
tzinfo=datetime.timezone(datetime.timedelta(hours=8)))
else: else:
return 0 return datetime.datetime(1980, 1, 1, 0, 0, 0, tzinfo=datetime.timezone(datetime.timedelta(hours=8)))
except: except:
return 0 return datetime.datetime(1980, 1, 1, 0, 0, 0, tzinfo=datetime.timezone(datetime.timedelta(hours=8)))
class TopicComplaint(models.Model): class TopicComplaint(models.Model):
"""帖子举报""" """帖子举报"""
......
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