예제 #1
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))


        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = Film.objects.filter(id=id, active=True)
        if one.count()<= 0:
            result = {"state": -2, "msg": "该电影不存在或已被删除"}
            return CrossDomainReturn(result)

        # fileReview=one[0]
        # fileReview.hits+=1
        # fileReview.save()

        # if one.fromUser == user:  # 如果是本人登录的话,更新最后的已读访问
        #     one.lastDetectNum = one.replyNum
        #     aa = ReplyInfo.objects.filter(toPost=one)
        #     aa.update(isRead=True)

        the_film = one[0]
        isGood=False
        goods = Mark.objects.filter(user=user, film=the_film)

        if (goods.count() != 0):
            isGood=True

        replys = FilmReview.objects.filter(film__id=id, active=True)
        replyNum = replys.count()
        reply = []

        for one in replys:
            temp = {"id": one.id, "author": one.author.nickName, "autherHeadPhoto": str(one.author.headImage),
                    "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
                    "title": one.title
                    }
            reply.append(temp)


        temp = {"id": the_film.id,
                'title': the_film.name,
                       'image': the_film.head_image.url,
                       'mark': the_film.score/the_film.marked_members if the_film.marked_members!=0 else 0,
                       'relase_date': str(the_film.on_time.strftime('%Y-%m-%d')),
                       'time': str(the_film.on_time.strftime('%H:%M:%S')),
                       'marked_members': the_film.marked_members,
                       'comment_members': the_film.commented_member,
                        "isMark":isGood,"replys":reply,"replyNum":replyNum,
                        "displayTime":the_film.displayTime,#上映时间
                }


        result = {"state": 1, "result": temp}

        return CrossDomainReturn(result)
예제 #2
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))
        score=int(request.POST.get("score", 0))
        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)

        one = Film.objects.filter(id=id)
        if one.count()<= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)

        firm=one[0]

        isGood = False
        goods = Mark.objects.filter(user=user, film__id=id)


        if(goods.count()==0):
            Mark.objects.create(user=user,film=firm,score=score)
            firm.marked_members+=1
            firm.score+=score
            firm.save()
            result = {"state": 1, "msg": "成功"}
        else:
            result = {"state": -4, "msg": "无权"}

        return CrossDomainReturn(result)
예제 #3
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登陆"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))
        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = Film.objects.filter(id=id)
        if one.count() <= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)
        firm = one[0]

        title = request.POST.get("title", "None")
        content = request.POST.get("content", "None")

        FilmComment.objects.create(active=True,
                                   author=user,
                                   title=title,
                                   firm=firm,
                                   content=content)
        firm.commented_member += 1
        firm.save()
        result = {"state": 1, "result": "成功"}

        return CrossDomainReturn(result)
예제 #4
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))
        operaType = int(request.POST.get("operaType", 0))  # 1点赞 0取消赞
        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = FilmReview.objects.filter(id=id)
        if one.count() <= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)

        news = one[0]

        content=request.POST.get("content")
        FilmReviewComment.objects.create(film_review=news,author=user,content=content)

        news.commented_members+=1
        news.save()
        result = {"state": 1, "result": "成功"}

        return CrossDomainReturn(result)
예제 #5
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登陆"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))
        operaType = int(request.POST.get("operaType", 0))  # 1点赞 0取消赞
        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = News.objects.filter(id=id)
        if one.count() <= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)

        news = one[0]
        news.hits += 1
        news.save()

        isGood = False
        goods = NewsGoods.objects.filter(fromUser=user, toNews__id=id)

        if (goods.count() != 0):
            isGood = True

        replys = NewsComment.objects.filter(news__id=id)
        replyNum = replys.count()
        reply = []
        for one in replys:
            temp = {
                "id": one.id,
                "author": one.author.nickName,
                "autherHeadPhoto": str(one.author.headImage),
                "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
                "content": one.content
            }
            reply.append(temp)

        one = news
        temp = {
            "id": one.id,
            "author": one.author.nickName,
            "photo": str(one.picture),
            "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
            "Title": one.title,
            "clickNum": one.hits,
            "replyNum": one.commented_members,
            "content": one.Content,
            "isGood": isGood,
            "replys": reply,
            "replyNum": replyNum,
        }

        result = {"state": 1, "result": temp}

        return CrossDomainReturn(result)
예제 #6
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)

        heheadImage = request.FILES.get("headImage", "default/1.png")
        user.headImage = heheadImage
        user.save()
        result = {"state": 1, "msg": "修改成功", "imageHead": str(user.headImage)}
        return CrossDomainReturn(result)
예제 #7
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))


        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = FilmReview.objects.filter(id=id, active=True)
        if one.count()<= 0:
            result = {"state": -2, "msg": "该影评不存在或已被删除"}
            return CrossDomainReturn(result)

        fileReview=one[0]
        fileReview.hits+=1
        fileReview.save()

        # if one.fromUser == user:  # 如果是本人登录的话,更新最后的已读访问
        #     one.lastDetectNum = one.replyNum
        #     aa = ReplyInfo.objects.filter(toPost=one)
        #     aa.update(isRead=True)

        isGood=False
        goods = FilmReviewGoods.objects.filter(fromUser=user, toNews__id=id)

        if (goods.count() != 0):
            isGood=True


        replys = FilmReviewComment.objects.filter(film_review__id=id,active=True)
        replyNum = replys.count()
        reply = []
        for one in replys:
            temp = {"id": one.id, "author": one.author.nickName,"autherHeadPhoto":str(one.author.headImage),
                    "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
                    "content":one.content
                    }
            reply.append(temp)

        one=fileReview
        temp = {"id": one.id, "author": one.author.nickName, "photo": str(one.thumbnail),
                "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")), "Title": one.title,
                "clickNum": one.hits, "replyNum": one.commented_members, "content": one.content,
                "isGood":isGood,"replys": reply,"replyNum":replyNum,"poster":one.film.poster.url
                }


        result = {"state": 1, "result": temp}

        return CrossDomainReturn(result)
예제 #8
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        nickName = request.POST.get("nickName",None)
        if nickName !=None and nickName!="":
            user.nickName = nickName
            user.save()
            result = {"state": 1, "msg": "修改成功", "nickName": str(user.nickName)}

        else:
            result = {"state": -2, "msg": "昵称长度不合法", "nickName": str(user.nickName)}
        return CrossDomainReturn(result)
예제 #9
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登陆"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))

        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = Film.objects.filter(id=id)
        if one.count() <= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)
        firm = one[0]
        '''
        film = models.ForeignKey(Film, verbose_name=u'电影', on_delete=models.PROTECT)
            author = models.ForeignKey(User, verbose_name=u'作者', on_delete=models.PROTECT)
            create_time = models.DateTimeField(auto_now_add=True, verbose_name=u'评论时间')
            update_time = models.DateTimeField(auto_now=True, verbose_name=u'更新时间')
            title = models.CharField(max_length=50, verbose_name=u'标题')
            subtitle = models.CharField(max_length=50, verbose_name=u'副标题')
            content = models.TextField(verbose_name="内容")
            commented_members = models.IntegerField(default=0, verbose_name=u'评论人数')
            hits = models.IntegerField(default=0, verbose_name=u'点击量')
        
            thumbnail = models.ImageField(verbose_name=u'缩略图', upload_to='upload')
        
            active = models.BooleanField(default=True, verbose_name=u'情况')
        '''
        title = request.POST.get("title", "None")
        subtitle = request.POST.get("subtitle", "None")
        content = request.POST.get("content", "None")
        thumbnail = request.File.get("thumbnail", "None")

        FilmReview.objects.create(active=True,
                                  author=user,
                                  title=title,
                                  firm=firm,
                                  subtitle=subtitle,
                                  content=content,
                                  thumbnail=thumbnail)
        firm.commented_member += 1
        firm.save()
        result = {"state": 1, "result": "成功"}

        return CrossDomainReturn(result)
예제 #10
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)

        posts = NewsComment.objects.filter(author=user).order_by("-create_time")

        result = []
        for one in posts:
            temp = {"id": one.id, "title": one.title, "firmName": one.news.title,
                    "thumbnail": str(one.news.picture),
                    "create_time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
                    }
            result.append(temp)



        result = {"state": 1, "result": result}
        return CrossDomainReturn(result)
예제 #11
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)

        posts=FilmReview.objects.filter(author=user).order_by("-create_time")


        result = []
        for one in posts:
            temp = {"id": one.id, "title": one.title, "firmName": one.film.name,
                    "thumbnail":str(one.thumbnail),
                    "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
                    }
            result.append(temp)

        posts = serializers.serialize("json", posts)

        result = {"state": 1, "result": result}
        return CrossDomainReturn(result)
예제 #12
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登陆"}
            return CrossDomainReturn(temp)

        id = request.POST.get("id")  # 要删除对象的id
        type = str(request.POST.get("id", 0))  # 要删除的评论类型,0是电影的,1是新闻的
        if type == '0':
            temp = FilmComment.objects.filter(id=id, author=user)
        elif type == "1":
            temp = NewsComment.objects.filter(id=id, author=user)
        else:
            temp = {"state": -3, "msg": "数据不全"}
            return CrossDomainReturn(temp)
        if len(temp) > 0:
            temp = temp[0]
            temp.delete()
            temp = {"state": 1, "msg": "删除成功"}
        else:
            temp = {"state": -2, "msg": "删除失败,无权或无文章"}

        return CrossDomainReturn(temp)
예제 #13
0
    def post(self, request):
        user = checkUserLogin(request)
        if not user:
            temp = {"state": -1, "msg": "尚未登录"}
            return CrossDomainReturn(temp)
        id = int(request.POST.get("id", 0))
        operaType=int(request.POST.get("operaType", 0)) # 1点赞 0取消赞
        if id == 0:
            result = {"state": -3, "msg": "错误请求"}
            return CrossDomainReturn(result)
        one = FilmReview.objects.filter(id=id)
        if one.count()<= 0:
            result = {"state": -2, "msg": "该帖子不存在或已被删除"}
            return CrossDomainReturn(result)

        news=one[0]

        goods=FilmReviewGoods.objects.filter(fromUser=user,toNews__id=id)

        if(goods.count()==0):
            if(operaType==1):
                FilmReviewGoods.objects.create(fromUser=user,toNews_id=id,isGood=True)
                news.goodNum+=1
                news.save()
        else:
            goods=goods[0]
            if(operaType==1):
                goods.isGood=True
                news.goodNum += 1
                news.save()
            else:
                goods.isGood=False
                news.goodNum -= 1
                news.save()
            goods.save()


        # if one.fromUser == user:  # 如果是本人登录的话,更新最后的已读访问
        #     one.lastDetectNum = one.replyNum
        #     aa = ReplyInfo.objects.filter(toPost=one)
        #     aa.update(isRead=True)
        # one.save()
        #
        #
        # replys = NewsComment.objects.filter(news__id=id)
        #
        # reply = []
        # for one in replys:
        #     temp = {"id": one.id, "author": one.author.nickName,
        #             "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")),
        #             "content":one.content
        #             }
        #     reply.append(temp)
        #
        # temp = {"id": one.id, "author": one.author.nickName, "photo": str(one.picture),
        #         "Time": str(one.create_time.strftime("%Y-%m-%d %H:%M:%S")), "Title": one.title,
        #         "clickNum": one.hits, "replyNum": one.commented_members, "content": one.Content,
        #         "replys": reply
        #         }


        result = {"state": 1, "msg": "成功"}

        return CrossDomainReturn(result)