コード例 #1
0
 def get_users_comments(takes):
     comment_hash = []
     user_hash = []
     for take in takes:
         chapter_comments = Comment.get_comments(chapter_id=take.chunk.chapter.id)
         chunk_comments = Comment.get_comments(chunk_id=take.chunk.id)
         take_comments = Comment.get_comments(take_id=take.id)
         comments = list(chain(chapter_comments, chunk_comments, take_comments))
         for comment in comments:
             user = comment.owner
             if user:
                 user_hash.append(
                     {ZipIt.get_local_file_hash(user.name_audio): FileUtility.file_name(user.name_audio)})
             comment_hash.append(
                 {ZipIt.get_local_file_hash(comment.location): FileUtility.file_name(comment.location)})
     return comment_hash + user_hash
コード例 #2
0
 def get_queryset(self):
     queryset = []
     query = self.request.query_params
     if len(query) == 0:
         return Comment.objects.all()
     else:
         pk = query.get("id", None)
         chapter_id = query.get("chapter_id", None)
         chunk_id = query.get("chunk_id", None)
         take_id = query.get("take_id", None)
         if pk is not None:
             queryset = Comment.objects.filter(id=pk)
         if chapter_id is not None:
             queryset = Comment.get_comments(chapter_id=chapter_id)
         if chunk_id is not None:
             queryset = Comment.get_comments(chunk_id=chunk_id)
         if take_id is not None:
             queryset = Comment.get_comments(take_id=take_id)
         if len(queryset) != 0:
             return queryset
         else:
             return None
コード例 #3
0
 def get_queryset(self):
     queryset = []
     query = self.request.query_params
     if len(query) == 0:
         return Comment.objects.all()
     else:
         pk = query.get("id", None)
         chapter_id = query.get("chapter_id", None)
         chunk_id = query.get("chunk_id", None)
         take_id = query.get("take_id", None)
         if pk is not None:
             queryset = Comment.objects.filter(id=pk)
         if chapter_id is not None:
             queryset = Comment.get_comments(chapter_id=chapter_id)
         if chunk_id is not None:
             queryset = Comment.get_comments(chunk_id=chunk_id)
         if take_id is not None:
             queryset = Comment.get_comments(take_id=take_id)
         if len(queryset) != 0:
             return queryset
         else:
             return None