Exemplo n.º 1
0
 def get(self, request, pk):
     code_lag=check_lan(request)
     try:
         all_post = AllSongMusic.objects.filter(all_music_auth=pk, is_enable=True, is_delete=False)
         return js_resp_paging(all_post, request, AllSongMusic_Popular_Serializer)
     except User.DoesNotExist:
         return json_resp(code=499, msg=code_lag['499'])
Exemplo n.º 2
0
    def post(self, request):
        code_lag = check_lan(request)
        date = request.data
        serializer = Create_SongExceptionSerializer(data=date)
        if serializer.is_valid():
            serializer.save()

            return json_resp(code=200, msg='OK')
        return json_resp(code=499, msg=code_lag['499'])
Exemplo n.º 3
0
 def post(self, request):
     code_lag = check_lan(request)
     data = request.data
     data['case_user'] = request.user.id
     serializer = Create_ExceptionCaseSerializer(data=data)
     if serializer.is_valid():
         serializer.save()
         return json_resp(code=200, msg='ok')
     return json_resp(code=499, msg=code_lag['499'])
Exemplo n.º 4
0
    def get(self, request, pk):
        code_lag = check_lan(request)
        music = self.get_object(pk)
        if music:
            ser_data = AllSongMusic_html5_Serializer(music)

            data = ser_data.data

            return json_resp(code=200, msg='ok', data=data)
        else:
            return json_resp(code=479, msg=code_lag['479'])
Exemplo n.º 5
0
    def get(self, request, pk):
        code_lag=check_lan(request)
        up_all_click_count(pk)
        # update_hour_click(pk, "allmusic")
        redis_db = read_from_cache(pk, 'allmusic')
        music = self.get_object(pk)
        if music:
            pass
        else:
            return json_resp(code=479,msg=code_lag['479'])
        owner_id = request.user.id
        if p(owner_id).is_loveing(pk):
            is_praise = True
        else:
            is_praise = False
        share_count = get_all_share_count(pk)
        praise_redis_count = p(pk).lovedby_count()

        praise_count=music.praise+praise_redis_count
        click_count = get_all_click_count(pk)
        comment_count = music.all_music_comment.count()

        if redis_db:
            redis_db["is_praise"] = is_praise
            redis_db['share_count'] = share_count
            redis_db['praise_count'] = praise_count
            redis_db['view_count'] = click_count
            redis_db['comment_count'] = comment_count
            return json_resp(code=200, msg='ok',
                             data=redis_db)
        else:

            if music:
                if music.is_delete:
                    return json_resp(code=479, msg=code_lag['479'])
                else:

                    serializer = AllSongMusicDetailSerializer(music)

                    data = serializer.data
                    data['is_praise'] = is_praise
                    data['share_count'] = share_count
                    data['praise_count'] = praise_count
                    data['view_count'] = click_count
                    data['comment_count'] = comment_count
                    write_to_cache(pk, 'allmusic', data)
                    return json_resp(code=200, msg='ok', data=data)
            else:
                return json_resp(code=479, msg=code_lag['479'])
Exemplo n.º 6
0
    def post(self, request):
        code_lag = check_lan(request)
        try:

            music_id = request.data.get('musicid')
        except:
            return json_resp(code=499, msg=code_lag['499'])
        if music_id:
            try:
                music = MusicProfiel.objects.get(id=music_id)
                music.view_count += 1
                music.save()
                return json_resp(code=200, msg="ok")
            except:
                return json_resp(code=499, msg=code_lag['499'])
        else:
            return json_resp(code=499, msg=code_lag['499'])
Exemplo n.º 7
0
    def put(self, request, pk):
        code_lag = check_lan(request)
        music = self.get_object(pk)
        if music:
            auth = music.all_music_auth
            if request.user == auth:
                data_copy = request.data.copy()
                data_copy['is_delete'] = True
                data_copy['deleted_at'] = datetime.datetime.now()
                serializer = CreateAllSongMusicSerializer(music, data=data_copy, partial=True)

                if serializer.is_valid():
                    serializer.save()
                    return json_resp(code=200, msg='ok')
                return json_resp(code=499, msg=code_lag['499'])
            else:
                return json_resp(code=480, msg=code_lag['480'])
        else:
            return json_resp(code=479, msg=code_lag['479'])
Exemplo n.º 8
0
    def post(self, request, pk):
        code_lag=check_lan(request)
        music = self.get_object(pk)
        user = request.user
        data = request.data
        data['user'] = user.id
        data['music'] = pk
        if music:
            to_user = music.all_music_auth
        else:
            return json_resp(code=479, msg=code_lag['479'])

        serializer = ALLCommentSerializers(data=request.data)
        if serializer.is_valid():
            serializer.save(owner=user, music=music)
            # up_notifactions_count(music.all_music_auth.id)
            comment_msg(request.user.id, to_user.id, music.id)
            return json_resp(code=200, msg="ok")
        else:
            return json_resp(code=484, msg=code_lag['484'])
Exemplo n.º 9
0
 def post(self, request):
     code_lag = check_lan(request)
     slug = self.request.data.get('slug', '')
     word = self.request.data.get('word', "")
     if word:
         if slug == 'song':
             music = self.get_queryset_music(word)
             singer = self.get_queryset_singer(word=word)
             if singer:
                 type = 0
             else:
                 type = 1
             return api_paging(singer=singer, song=music, Serializer_singer=SingerSerializer,
                               Serializer_song=MusicProfileSearchSer, request=request, type=type, return_count=10)
         elif slug == 'people':
             users = self.get_queryset_users(word=word)
             return js_resp_paging(objs=users, request=request, serializer_obj=AccountSerializer, pages=20)
         else:
             return json_resp(code=499, msg=code_lag['499'])
     else:
         return json_resp(code=486, msg=code_lag['486'])
Exemplo n.º 10
0
    def put(self, request, pk):
        code_lag=check_lan(request)

        music = self.get_object(pk)
        if not music:
            return json_resp(code=479, msg=code_lag['479'])
        else:

            owner_id = request.user.id

            if p(owner_id).is_loveing(pk):
                p(owner_id).unpraise(pk)
                return json_resp(code=200, msg=code_lag['200'])

            else:
                p(owner_id).praise(pk)
                to_user_id = music.all_music_auth.id
                from_user = owner_id

                praise_msg.delay(from_user, to_user_id, music.id)
                return json_resp(code=200, msg=code_lag['200'])