Exemple #1
0
def fix_user():
    from app.customer.models.user import User
    from app.customer.models.real_video_verify import RealVideoVerify
    users = User.objects.all()
    for user in users:
        status = RealVideoVerify.get_status(user.id)
        if status == 1:
            user.update(set__is_video_auth=1)
        else:
            if user.is_video_auth == 1:
                desc = u"<html><p>" + _(
                    u'由于您未进行视频认证,将取消您的播主资格,如想再次成为视频播主,请进行申请视频认证,并添加审核人员微信: "honeynnm" '
                ) + u"</p></html>"
                MessageSender.send_system_message(user.id, desc)
                user.update(set__is_video_auth=4)
Exemple #2
0
    def get(self):
        data = []
        user_id = self.current_user_id
        moment_id = self.arg('moment_id', "")
        moment = UserMoment.objects.filter(show_status__ne=2,
                                           id=moment_id).first()
        if moment:
            UserMomentLook.inc_look(user_id, str(moment.id))
            like_user_list = moment.like_user_list
            dic = convert_user_moment(moment)
            if int(user_id) in like_user_list:
                is_liked = 1
            else:
                is_liked = 0
            dic["is_liked"] = is_liked

            if moment.type == 3:
                buy_video_status = VideoPurchaseRecord.get_buy_status(
                    user_id, moment.video_id)
                dic["buy_video_status"] = buy_video_status
                user_vip = UserVip.objects.filter(user_id=user_id).first()
                if user_vip:
                    now = datetime.datetime.now()
                    create_time = now.strftime("%Y-%m-%d")
                    vip_watch_record = VipWatchVideoRecord.objects.filter(
                        user_id=user_id,
                        create_time=create_time,
                        video_id=moment.video_id).first()
                    vip_comment_status = 2
                    if vip_watch_record:
                        vip_comment_status = 1
                    dic["vip_comment_status"] = vip_comment_status

            dic["check_real_video"] = RealVideoVerify.get_status(
                moment.user_id)

            data.append(dic)
        else:
            return self.write({'status': "fail", 'error': _(u"该动态已经被删除")})
        return self.write({"status": "success", "data": data})
Exemple #3
0
    def get(self):
        data = []
        current_user_id = self.current_user_id
        user_id = self.arg("user_id")

        if int(user_id) == int(current_user_id):
            videos = PrivateVideo.objects.filter(
                show_status__ne=2, user_id=user_id,
                delete_status=1).order_by("-create_time")
        else:
            videos = PrivateVideo.objects.filter(
                show_status=1, user_id=user_id,
                delete_status=1).order_by("-create_time")

        if videos:
            for video in videos:
                moment = UserMoment.objects.filter(
                    video_id=str(video.id)).order_by("-create_time").first()
                if moment:
                    dic = convert_user_moment(moment)
                    buy_video_status = VideoPurchaseRecord.get_buy_status(
                        current_user_id, moment.video_id)
                    dic["buy_video_status"] = buy_video_status

                    if user_id:
                        like_user_list = moment.like_user_list
                        if int(user_id) in like_user_list:
                            is_liked = 1
                        else:
                            is_liked = 0
                        dic["is_liked"] = is_liked
                        data.append(dic)
                    else:
                        dic["is_liked"] = 0
                        data.append(dic)
                    dic["check_real_video"] = RealVideoVerify.get_status(
                        moment.user_id)

        self.write({"status": "success", "data": data})
Exemple #4
0
    def get(self):
        data = []
        page = self.arg_int('page')
        user_id = self.current_user_id

        page_count = self.arg_int('page_count')

        # moments = UserMoment.objects.filter(show_status__in=[1, 3, 4], delete_status=1, is_public=1).order_by("-create_time")[(page - 1) * page_count:page * page_count]
        moments = UserMoment.get_index_moments(page, page_count,
                                               self.current_user)
        if moments:
            for moment in moments:
                if moment:
                    dic = convert_user_moment(moment)
                    if user_id:
                        like_user_list = moment.like_user_list
                        if int(user_id) in like_user_list:
                            is_liked = 1
                        else:
                            is_liked = 0
                        dic["is_liked"] = is_liked

                        if moment.type == 3:
                            buy_video_status = VideoPurchaseRecord.get_buy_status(
                                user_id, moment.video_id)
                            dic["buy_video_status"] = buy_video_status

                        dic["check_real_video"] = RealVideoVerify.get_status(
                            moment.user_id)

                        data.append(dic)
                    else:
                        dic["is_liked"] = 0
                        data.append(dic)

        self.write({"status": "success", "data": data})
Exemple #5
0
    def get(self):
        user = self.current_user
        user_id = self.current_user_id
        if not user_id:
            return self.write({"status": "success", "data": []})
        list_type = self.arg_int("list_type")
        show_user_id = self.arg_int("show_user_id", 0)
        page = self.arg_int('page')
        page_count = self.arg_int('page_count')
        data = []

        if list_type == 1:
            # 我的动态
            moments = UserMoment.objects.filter(
                user_id=user.id,
                show_status__ne=2,
                delete_status=1,
                is_public=1).order_by("-create_time")[(page - 1) *
                                                      page_count:page *
                                                      page_count]
        elif list_type == 2:
            # 我的关注动态
            follow_users = FollowUser.objects.filter(from_id=user.id)
            friend_users = FriendUser.objects.filter(from_id=user.id)
            user_ids = []
            if follow_users:
                for follow_user in follow_users:
                    fo_uid = follow_user.to_id
                    if fo_uid not in user_ids:
                        user_ids.append(fo_uid)
            if friend_users:
                for friend_user in friend_users:
                    fr_uid = friend_user.to_id
                    if fr_uid not in user_ids:
                        user_ids.append(fr_uid)
            is_spec = False
            if self.current_user.is_video_auth != 1 and not UserRedis.is_target_user(
                    user_id):
                is_pure = 1
                is_spec = True
            elif self.current_user.is_video_auth == 1 and not UserRedis.is_pure_anchor(
                    user_id):
                is_pure = 2
                is_spec = True
            if not is_spec:
                moments = UserMoment.objects.filter(
                    user_id__in=user_ids,
                    show_status__in=[1, 3, 4],
                    delete_status=1,
                    is_public=1).order_by("-create_time")[(page - 1) *
                                                          page_count:page *
                                                          page_count]
            else:
                moments = UserMoment.objects.filter(
                    user_id__in=user_ids,
                    show_status__in=[1, 3, 4],
                    delete_status=1,
                    is_public=1,
                    is_pure=is_pure).order_by("-create_time")[(page - 1) *
                                                              page_count:page *
                                                              page_count]
        elif list_type == 3:
            # 临时加一个 判断我的. 稍后客户端把lsit_type修复
            if show_user_id == int(user_id):
                moments = UserMoment.objects.filter(
                    user_id=user.id,
                    show_status__ne=2,
                    delete_status=1,
                    is_public=1).order_by("-create_time")[(page - 1) *
                                                          page_count:page *
                                                          page_count]
            else:
                # 其他用户动态
                moments = UserMoment.objects.filter(
                    user_id=show_user_id,
                    show_status__in=[1, 3, 4],
                    delete_status=1,
                    is_public=1).order_by("-create_time")[(page - 1) *
                                                          page_count:page *
                                                          page_count]

        if moments:
            for moment in moments:
                like_user_list = moment.like_user_list
                dic = convert_user_moment(moment)
                if int(user_id) in like_user_list:
                    is_liked = 1
                else:
                    is_liked = 0
                dic["is_liked"] = is_liked
                if moment.type == 3:
                    buy_video_status = VideoPurchaseRecord.get_buy_status(
                        user_id, moment.video_id)
                    dic["buy_video_status"] = buy_video_status

                dic["check_real_video"] = RealVideoVerify.get_status(
                    moment.user_id)
                data.append(dic)

        return self.write({"status": "success", "data": data})
Exemple #6
0
    def get(self):
        user_id = self.current_user_id
        user = self.current_user
        cover_url = self.arg('cover_url')
        video_url = self.arg('video_url')
        publish_status = self.arg_int('publish_status', 1)
        desc = self.arg('desc', "")
        file_id = self.arg('file_id', "")
        price = self.arg_int('price', 0)

        real_video_auth = RealVideoVerify.get_status(user_id)

        if int(real_video_auth) != 1:
            return self.write({
                "status": "fail",
                'error': _(u"视频认证通过后才可发布私房视频")
            })

        code, message = PrivateVideo.check_video_count(user)
        if code == 2:
            return self.write({"status": "fail", 'error': _(message)})

        if desc:
            # 文本内容鉴黄
            ret, duration = shumei_text_spam(text=desc,
                                             timeout=1,
                                             user_id=user.id,
                                             channel="DYNAMIC_COMMENT",
                                             nickname=user.nickname,
                                             phone=user.phone,
                                             ip=self.user_ip)
            print ret
            is_pass = 0
            if ret["code"] == 1100:
                if ret["riskLevel"] == "PASS":
                    is_pass = 1
                if ret["riskLevel"] == "REJECT":
                    is_pass = 0
                if ret["riskLevel"] == "REVIEW":
                    # todo +人工审核逻辑
                    is_pass = 1
            if not is_pass:
                return self.write({
                    'status': "fail",
                    'error': _(u"经系统检测,您的内容涉及违规因素,请重新编辑")
                })

        video = PrivateVideo()
        video.desc = desc
        video.user_id = int(user_id)
        video.cover_url = cover_url
        video.video_url = video_url
        video.price = price
        video.create_time = datetime.datetime.now()
        video.delete_status = 1
        video.show_status = 3
        video.is_valid = 1
        video.file_id = file_id
        video.save()

        user_moment = UserMoment()
        user_moment.user_id = user_id
        user_moment.like_count = 0
        user_moment.like_user_list = []
        user_moment.comment_count = 0

        user_moment.img_list = []
        user_moment.content = desc
        user_moment.create_time = datetime.datetime.now()
        user_moment.show_status = 5  # 1:展示  2:数美屏蔽  3:举报  4:数美部分屏蔽  5:数美鉴定中
        user_moment.delete_status = 1  # 1:未删除  2:删除
        user_moment.ispass = 2
        user_moment.type = 3
        user_moment.video_id = str(video.id)
        user_moment.cover_url = cover_url
        user_moment.video_url = video_url
        user_moment.price = video.price
        # 同步到动态
        if publish_status == 2:
            code, message = UserMoment.check_moment_count(user)
            if code == 2:
                return self.write({'status': "fail", 'error': _(message)})
            user_moment.is_public = 1
        else:
            user_moment.is_public = 2

        user_moment.save()

        from app_redis.user.models.user import UserRedis
        pure_id = "597ef85718ce420b7d46ce11"
        if user.is_video_auth == 1:
            if user.label:
                if pure_id in user.label:
                    user_moment.update(set__is_pure=1)
                else:
                    user_moment.update(set__is_pure=3)
            else:
                user_moment.update(set__is_pure=3)
        else:
            if UserRedis.is_target_user(user.id):
                user_moment.update(set__is_pure=2)
            else:
                user_moment.update(set__is_pure=4)

        return self.write({"status": "success"})