def __call__(self, time_slot: models.TimeSlot):
if time_slot.is_complete() and hasattr(time_slot, "comment"):
comment = time_slot.comment
if comment:
self.count_comment(comment)
if self.is_valid(comment):
if self.cres.is_error and self.cres.id == time_slot.comment_id:
the_form = forms.CommentReplyForm(initial={"reply": self.cres.reply})
else:
the_form = forms.CommentReplyForm()
one_comment = {
"name": self.name,
"publish_date": localtime(comment.created_at).strftime("%Y-%m-%d %H:%M"),
"full_star": range(comment.score),
"empty_star": range(5 - comment.score),
"comment": comment.content,
"class_type": self.class_type + "1?1",
"form": the_form,
"action_url": "reply/comment/{id}".format(id=comment.id),
"form_id": "reply_form_{id}".format(id=comment.id),
"reply_id": "reply_{id}".format(id=comment.id),
"reply_content": comment.reply
}
self.comment_list.append(one_comment)
评论列表
文章目录