Beispiel #1
0
 def get_queryset(self):
     user_id = self.request.user._id
     comment = self.get_comment()
     reports = comment.reports
     serialized_reports = []
     if user_id in reports:
         report = CommentReport(user_id, reports[user_id]['category'], reports[user_id]['text'])
         serialized_reports.append(report)
     return serialized_reports
Beispiel #2
0
    def get_object(self):
        comment = self.get_comment()
        reports = comment.reports
        user_id = self.request.user._id
        reporter_id = self.kwargs['user_id']

        if reporter_id != user_id:
            raise PermissionDenied('Not authorized to comment on this project.')

        if reporter_id in reports:
            return CommentReport(user_id, reports[user_id]['category'], reports[user_id]['text'])
        else:
            raise Gone(detail='The requested comment report is no longer available.')