コード例 #1
0
ファイル: revision.py プロジェクト: nuannuanwu/weixiao
def comment_messages(sender, comment, request, **kwargs):
    """ 添加评论后,增加对应*瓦片*的评论数(冗余字段), 并跳转且作出提示 """
    tile = comment.content_object
    cid = request.REQUEST.get('cid')
    try:
        comment.content_object.after_add_comments()
        tile = comment.content_object
        href = request.REQUEST.get('notify','')
        channel = get_channel(tile)
        if not href:
            href = reverse('axis_tile_view',kwargs={'tile_id': tile.id}) + "?channel=" + channel
    
        #添加一条提醒
        actions = {'title':'新消息','href':href + "#comment_div_" + str(comment.id)}
        
        if tile.creator != request.user:
            notify.send(request.user, verb='新消息', action_object=tile, recipient=tile.creator, actions=actions)
        if cid:
            comment_obj = get_object_or_404(Comment, pk=cid)
            relation = Comment_relation()
            relation.target_object = comment_obj
            relation.action_object = comment
            relation.save()
            if comment_obj.user != request.user:
                notify.send(request.user, verb='新消息', action_object=comment_obj, recipient=comment_obj.user, actions=actions)
    except:
        pass

    if request.user.is_authenticated():
        comment._set_url("http://www." + str(time.mktime(datetime.datetime.now().timetuple())) + ".com")
        comment.save()
コード例 #2
0
ファイル: admin.py プロジェクト: nuannuanwu/weixiao
 def tile_view(self,obj):
     channel = get_channel(obj)
     href = reverse('axis_tile_view',kwargs={'tile_id': obj.id}) + "?channel=" + channel
     return '<a href="' + href + '" target="_blank">' + obj.title + '</a>'