Esempio n. 1
0
def get_public_content(api, username, request):
    then = (datetime.now(pytz.utc) - timedelta(days=120)).strftime("%s")
    query = \
        '// Retrieve all the current users questions\n' \
        'MATCH (a:Pleb {username: "******"})<-[:OWNED_BY]-' \
        '(questions:Question) ' \
        'WHERE questions.to_be_deleted = False AND questions.created > %s' \
        ' AND questions.is_closed = False ' \
        'RETURN questions, NULL AS solutions, ' \
        'questions.created AS created, NULL AS s_question UNION ' \
        '// Retrieve all the current users solutions\n' \
        'MATCH (a:Pleb {username: "******"})<-' \
        '[:OWNED_BY]-(solutions:Solution)<-' \
        '[:POSSIBLE_ANSWER]-(s_question:Question) ' \
        'WHERE s_question.to_be_deleted = False ' \
        'AND solutions.created > %s' \
        ' AND solutions.is_closed = False ' \
        'AND s_question.is_closed = False ' \
        'AND solutions.to_be_deleted = False ' \
        'RETURN solutions, NULL AS questions, ' \
        'solutions.created AS created, s_question AS s_question' \
        % (username, then, username, then)
    news = []
    res, _ = db.cypher_query(query)
    # Profiled with ~50 objects and it was still performing under 1 ms.
    # By the time sorting in python becomes an issue the above mentioned
    # ticket should be resolved.
    res = sorted(res, key=attrgetter('created'), reverse=True)[:5]
    page = api.paginate_queryset(res)
    for row in page:
        news_article = None
        if row.questions is not None:
            row.questions.pull()
            news_article = QuestionSerializerNeo(Question.inflate(
                row.questions),
                                                 context={
                                                     'request': request
                                                 }).data
        elif row.solutions is not None:
            row.s_question.pull()
            row.solutions.pull()
            question_data = QuestionSerializerNeo(
                Question.inflate(row.s_question)).data
            news_article = SolutionSerializerNeo(Solution.inflate(
                row.solutions),
                                                 context={
                                                     'request': request
                                                 }).data
            news_article['question'] = question_data
        news.append(news_article)
    return api.get_paginated_response(news)
Esempio n. 2
0
 def get_focused_on(self, request=None):
     from api.neo_models import SBObject
     from sb_quests.neo_models import Position
     from sb_quests.serializers import PositionSerializer
     from sb_tags.neo_models import Tag
     from sb_tags.serializers import TagSerializer
     from sb_questions.neo_models import Question
     from sb_questions.serializers import QuestionSerializerNeo
     query = 'MATCH (a:Mission {object_uuid: "%s"})-[:FOCUSED_ON]->(b)' \
             'RETURN b' % self.object_uuid
     res, _ = db.cypher_query(query)
     if res.one:
         child_label = SBObject.inflate(res.one).get_child_label()
         if child_label == "Position":
             return PositionSerializer(Position.inflate(res.one),
                                       context={
                                           'request': request
                                       }).data
         elif child_label == "Tag":
             return TagSerializer(Tag.inflate(res.one),
                                  context={
                                      'request': request
                                  }).data
         elif child_label == "Question":
             return QuestionSerializerNeo(Question.inflate(res.one),
                                          context={
                                              'request': request
                                          }).data
     else:
         return None
 def test_can_not_flag(self, m):
     m.get(reverse('question-detail',
                   kwargs={'object_uuid': self.question.object_uuid}),
           json=QuestionSerializerNeo(self.question).data,
           status_code=status.HTTP_200_OK)
     self.client.force_authenticate(user=self.user)
     comment = Comment(content='test_content',
                       owner_username=self.pleb2.username,
                       parent_type="question",
                       parent_id=self.question.object_uuid).save()
     comment.owned_by.connect(self.pleb2)
     self.question.comments.connect(comment)
     self.pleb.save()
     for item in self.pleb.privileges.all():
         self.pleb.privileges.disconnect(item)
     cache.clear()
     url = "%scomments/%s/" % (reverse(
         'question-detail',
         kwargs={'object_uuid': self.question.object_uuid
                 }), comment.object_uuid)
     response = self.client.get(url, format='json')
     self.question.comments.disconnect(comment)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertFalse(response.data['can_flag']['status'])
     self.assertEqual(
         response.data['can_flag']['detail'],
         "You must have 50+ reputation to flag Conversation "
         "Cloud content.")
     self.assertEqual(response.data['can_flag']['short_detail'],
                      "Requirement: 50+ Reputation")
 def test_can_flag(self, m):
     m.get(reverse('question-detail',
                   kwargs={'object_uuid': self.question.object_uuid}),
           json=QuestionSerializerNeo(self.question).data,
           status_code=status.HTTP_200_OK)
     self.client.force_authenticate(user=self.user)
     comment = Comment(content='test_content',
                       owner_username=self.pleb2.username,
                       parent_type="question",
                       parent_id=self.question.object_uuid).save()
     comment.owned_by.connect(self.pleb2)
     self.question.comments.connect(comment)
     privilege = Privilege.nodes.get(name="flag")
     self.pleb.privileges.connect(privilege)
     cache.clear()
     url = "%scomments/%s/?expedite=true" % (reverse(
         'question-detail',
         kwargs={'object_uuid': self.question.object_uuid
                 }), comment.object_uuid)
     response = self.client.get(url, format='json')
     self.pleb.privileges.disconnect(privilege)
     self.question.comments.disconnect(comment)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertTrue(response.data['can_flag']['status'])
     self.assertIsNone(response.data['can_flag']['detail'])
     self.assertIsNone(response.data['can_flag']['short_detail'])
Esempio n. 5
0
 def get_question(self, obj):
     from sb_questions.neo_models import Question
     from sb_questions.serializers import QuestionSerializerNeo
     request, expand, _, relations, expedite = gather_request_data(
         self.context,
         expedite_param=self.context.get('expedite_param', None),
         expand_param=self.context.get('expand_param', None))
     question = Question.get(object_uuid=obj.parent_id)
     if expand:
         return QuestionSerializerNeo(question).data
     return reverse('question-detail',
                    kwargs={'object_uuid': question.object_uuid},
                    request=self.context.get('request', None))
 def test_sloppy(self):
     self.client.force_authenticate(user=self.user)
     es = Elasticsearch(settings.ELASTIC_SEARCH_HOST)
     index_res = es.index(index='full-search-base',
                          doc_type='question',
                          body=QuestionSerializerNeo(self.question).data)
     time.sleep(1)
     self.assertTrue(index_res['created'])
     url = reverse('search-list') + "?query=levels of"
     response = self.client.get(url, format='json')
     self.assertGreaterEqual(response.data['count'], 1)
     self.assertContains(response,
                         self.question.object_uuid,
                         status_code=status.HTTP_200_OK)
     self.question.delete()
    def test_invalid_filter(self):
        self.client.force_authenticate(user=self.user)
        es = Elasticsearch(settings.ELASTIC_SEARCH_HOST)
        index_res = es.index(index='full-search-base',
                             doc_type='question',
                             body=QuestionSerializerNeo(self.question).data)
        time.sleep(1)
        self.assertTrue(index_res['created'])
        url = reverse('search-list') + "?query=battery-powered&" \
                                       "filter=" + str(uuid1())
        response = self.client.get(url, format='json')

        self.assertContains(response, "We currently have limited support for "
                            "filter operations.",
                            status_code=status.HTTP_400_BAD_REQUEST)
        self.question.delete()
Esempio n. 8
0
 def list(self, request, *args, **kwargs):
     council_list = []
     html = request.query_params.get('html', 'false').lower()
     queryset = self.get_queryset()
     page = self.paginate_queryset(queryset)
     for row in page:
         if row[0] is not None:
             row[0].pull()  # fix for None objects being returned
             # from the query due to multiple column returns
         council_object = None
         if row.questions is not None:
             council_object = QuestionSerializerNeo(Question.inflate(
                 row.questions),
                                                    context={
                                                        'request': request
                                                    }).data
         elif row.solutions is not None:
             council_object = SolutionSerializerNeo(Solution.inflate(
                 row.solutions),
                                                    context={
                                                        'request': request
                                                    }).data
         elif row.comments is not None:
             council_object = CommentSerializer(Comment.inflate(
                 row.comments),
                                                context={
                                                    'request': request
                                                }).data
         elif row.posts is not None:
             council_object = PostSerializerNeo(Post.inflate(row.posts),
                                                context={
                                                    'request': request
                                                }).data
         if html == 'true':
             council_object['last_edited_on'] = parser.parse(
                 council_object['last_edited_on'])
             council_object['request'] = request
             council_object = {
                 "html":
                 render_to_string("council_votable.html", council_object),
                 "id":
                 council_object["id"],
                 "type":
                 council_object["type"]
             }
         council_list.append(council_object)
     return self.get_paginated_response(council_list)
 def test_can_not_flag_own(self, m):
     m.get(reverse('question-detail',
                   kwargs={'object_uuid': self.question.object_uuid}),
           json=QuestionSerializerNeo(self.question).data,
           status_code=status.HTTP_200_OK)
     self.client.force_authenticate(user=self.user)
     comment = Comment(content='test_content',
                       owner_username=self.pleb.username,
                       parent_type="question",
                       parent_id=self.question.object_uuid).save()
     comment.owned_by.connect(self.pleb)
     self.question.comments.connect(comment)
     url = "%scomments/%s/" % (reverse(
         'question-detail',
         kwargs={'object_uuid': self.question.object_uuid
                 }), comment.object_uuid)
     response = self.client.get(url, format='json')
     self.question.comments.disconnect(comment)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertFalse(response.data['can_flag']['status'])
     self.assertEqual(response.data['can_flag']['detail'],
                      "You cannot flag your own content")
     self.assertEqual(response.data['can_flag']['short_detail'],
                      "Cannot Flag Own Content")
 def test_login_to_flag(self, m):
     m.get(reverse('question-detail',
                   kwargs={'object_uuid': self.question.object_uuid}),
           json=QuestionSerializerNeo(self.question).data,
           status_code=status.HTTP_200_OK)
     comment = Comment(content='test_content',
                       owner_username=self.pleb.username,
                       parent_type="question",
                       parent_id=self.question.object_uuid,
                       visibility="public").save()
     comment.owned_by.connect(self.pleb)
     self.question.comments.connect(comment)
     url = "%scomments/%s/" % (reverse(
         'question-detail',
         kwargs={'object_uuid': self.question.object_uuid
                 }), comment.object_uuid)
     response = self.client.get(url, format='json')
     self.question.comments.disconnect(comment)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertFalse(response.data['can_flag']['status'])
     self.assertEqual(response.data['can_flag']['detail'],
                      "You must be logged in to flag content.")
     self.assertEqual(response.data['can_flag']['short_detail'],
                      "Signup To Flag")
Esempio n. 11
0
def update_search_object(object_uuid,
                         label=None,
                         object_data=None,
                         index="full-search-base"):
    from plebs.serializers import PlebSerializerNeo
    from sb_quests.serializers import QuestSerializer
    from sb_quests.neo_models import Quest
    from sb_missions.serializers import MissionSerializer
    from sb_missions.neo_models import Mission
    from sb_questions.serializers import QuestionSerializerNeo
    from sb_base.neo_models import get_parent_votable_content
    if label is None:
        label = get_parent_votable_content(
            object_uuid).get_child_label().lower()
    logger.critical("Updating Search Object")
    logger.critical({"object_uuid": object_uuid})
    query = 'MATCH (a:%s {object_uuid:"%s"}) RETURN a' % \
            (label.title(), object_uuid)
    res, _ = db.cypher_query(query)
    if res.one:
        res.one.pull()
    else:
        raise update_search_object.retry(exc=DoesNotExist(
            'Object with uuid: %s '
            'does not exist' % object_uuid),
                                         countdown=3,
                                         max_retries=None)
    if label == "question":
        instance = Question.inflate(res.one)
        object_data = QuestionSerializerNeo(instance).data
        if 'mission' in object_data:
            object_data.pop('mission')
        if 'profile' in object_data:
            object_data.pop('profile')
        logger.critical(object_data)
    elif label == "quest":
        instance = Quest.inflate(res.one)
        object_data = QuestSerializer(instance).data
        logger.critical(object_data)
    elif label == "mission":
        instance = Mission.inflate(res.one)
        object_data = MissionSerializer(instance).data
        # Need to pop review_feedback because ES's serializer cannot parse
        # set types.
        # If we don't pop it we receive
        # TypeError("Unable to serialize set([]) (type: <type 'set'>)",))
        # If we can submit a JSON serialized version we can get around this by
        # using:
        # from rest_framework.renderers import JSONRenderer
        # JSONRenderer().render(serializer.data)
        # Also please note python's json.dumps() function runs into this same
        # issue.
        if 'review_feedback' in object_data:
            object_data.pop('review_feedback', None)
        if 'quest' in object_data:
            object_data.pop('quest')
        logger.critical(object_data)
    elif label == "pleb":
        instance = Pleb.inflate(res.one)
        object_data = PlebSerializerNeo(instance).data
        if 'quest' in object_data:
            object_data.pop('quest')
        logger.critical(object_data)
    else:
        # Currently we only need this functionality for Questions as
        # they are the only objects in search that we display votes
        # for in the search interface.
        error_dict = {
            "message": "Search False setup. "
            "Object Data None, Instance not None",
            "instance_label": label,
            "instance_uuid": object_uuid,
        }
        logger.critical(error_dict)
        return False
    try:
        es = Elasticsearch(settings.ELASTIC_SEARCH_HOST)
        res = es.index(index=index,
                       doc_type=object_data['type'],
                       id=object_uuid,
                       body=object_data)
    except (ElasticsearchException, TransportError, ConflictError,
            RequestError) as e:
        logger.exception("Failed to connect to Elasticsearch")
        logger.critical(object_data)
        raise update_search_object.retry(exc=e, countdown=5, max_retries=None)
    except KeyError:
        error_dict = {
            "message": "Search: KeyError False creation",
            "instance_uuid": object_uuid,
            "object_data": object_data
        }
        logger.critical(error_dict)
        return False
    try:
        if instance.search_id is None:
            instance.search_id = res['_id']
            instance.populated_es_index = True
            instance.save()
    except AttributeError:
        pass

    cache.delete("%s_vote_search_update" % object_uuid)
    return res
Esempio n. 12
0
    def newsfeed(self, request):
        """
        The newsfeed endpoint expects to be called on the me endpoint and
        assumes that the request object provided will contain the user the
        newsfeed is being provided to. It is not included as a list_route on
        the me endpoint due to the me endpoint not being a viewset.
        If we transition to that structure it could easily be moved to a
        list_route there.
        Query if we want to grab tags:
        MATCH (a:Pleb {username: "******"})-
                [OWNS_QUESTION]->(questions:Question)-[:TAGGED_AS]->(tags:Tag)
            WHERE questions.to_be_deleted = False AND questions.created > %s
            RETURN questions, tags.name AS tags, NULL as solutions,
                NULL as posts UNION
        MATCH (a)-[manyFriends:FRIENDS_WITH*2 {active: True}]->
                ()-[OWNS_QUESTION]->(questions:Question)-[:TAGGED_AS]->
                (tags:Tag)
            WHERE questions.to_be_deleted = False AND questions.created > %s
            RETURN questions, tags.name AS tags, NULL as posts,
                NULL as solutions UNION

        :param request:
        """
        # This query retrieves all of the current user's posts, solutions,
        # and questions as well as their direct friends posts, solutions,
        # and questions. It then looks for all of their friends friends
        # solutions and questions, combines all of the content and
        # returns the result. The query filters out content scheduled for
        # deletion and only looks for content created more recently than the
        # time provided. The reasoning for not including friends of friends
        # posts is to try and improve privacy. Friends of friends have not
        # actually been accepted potentially as friends by the user and
        # therefore should not have access to information posted on the user's
        # wall which in this case would be their posts.
        # We currently do not sort this query in neo because we are waiting
        # for post processing on unions as a whole to be added as a feature.
        # See Github issue #2725 for updates
        # https://github.com/neo4j/neo4j/issues/2725
        then = (datetime.now(pytz.utc) - timedelta(days=120)).strftime("%s")
        query = \
            '// Retrieve all the current users questions\n' \
            'MATCH (a:Pleb {username: "******"})<-[:OWNED_BY]-' \
            '(questions:Question) ' \
            'WHERE questions.to_be_deleted = False AND questions.created > %s' \
            ' AND questions.is_closed = False ' \
            'RETURN questions, NULL AS solutions, NULL AS posts, ' \
            'questions.created AS created, NULL AS s_question, ' \
            'NULL AS mission, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the news articles the user may be \n' \
            '// interested in\n' \
            'MATCH (a:Pleb {username: "******"})-[:INTERESTED_IN]->' \
            '(tag:Tag)<-[:TAGGED_AS]-(news:NewsArticle) ' \
            'WHERE news.published > %s AND news.is_closed = False ' \
            ' RETURN DISTINCT news, NULL AS solutions, NULL AS posts, ' \
            'news.published AS created, NULL AS s_question, ' \
            'NULL AS mission, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS questions UNION ' \
            '' \
            '// Retrieve all the current users solutions\n' \
            'MATCH (a:Pleb {username: "******"})<-' \
            '[:OWNED_BY]-(solutions:Solution)<-' \
            '[:POSSIBLE_ANSWER]-(s_question:Question) ' \
            'WHERE s_question.to_be_deleted = False ' \
            'AND solutions.created > %s' \
            ' AND solutions.is_closed = False ' \
            'AND s_question.is_closed = False ' \
            'RETURN solutions, NULL AS questions, NULL AS posts, ' \
            'solutions.created AS created, s_question AS s_question,' \
            'NULL AS mission, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the current users posts\n' \
            'MATCH (a:Pleb {username: "******"})<-[:OWNED_BY]-(posts:Post) ' \
            'WHERE posts.to_be_deleted = False AND posts.created > %s ' \
            'AND posts.is_closed = False ' \
            'RETURN posts, NULL as questions, NULL as solutions, ' \
            'posts.created AS created, NULL AS s_question,' \
            'NULL AS mission, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the posts on the current users wall that are \n' \
            '// not owned by the current user \n' \
            'MATCH (a:Pleb {username: "******"})-[:OWNS_WALL]->(w:Wall)' \
            '-[:HAS_POST]->(posts:Post) ' \
            'WHERE NOT (posts)-[:OWNED_BY]->(a) AND ' \
            'posts.to_be_deleted = False AND posts.created > %s ' \
            'AND posts.is_closed = False ' \
            'RETURN posts, NULL as questions, NULL as solutions, ' \
            'posts.created AS created, NULL AS s_question,' \
            'NULL AS mission, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve the missions affecting the given user\n' \
            'MATCH (a:Pleb {username: "******"})-[:LIVES_AT]->(:Address)-' \
            '[:ENCOMPASSED_BY*..]->' \
            '(:Location)<-[:WITHIN]-(mission:Mission {active: true})' \
            '<-[:EMBARKS_ON]-(quest:Quest {active: true}) ' \
            'WHERE NOT((mission)-[:FOCUSED_ON]->(:Position {verified:false}))' \
            ' AND mission.created > %s ' \
            'RETURN mission, NULL AS solutions, NULL AS posts, ' \
            'NULL AS questions, mission.created AS created, ' \
            'NULL AS s_question, NULL AS updates, NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve the mission updates affecting ' \
            '// the given user\n' \
            'MATCH (a:Pleb {username: "******"})-[:LIVES_AT]->(:Address)-' \
            '[:ENCOMPASSED_BY*..]->' \
            '(:Location)<-[:WITHIN]-(q_mission:Mission {active: true})' \
            '<-[:EMBARKS_ON]-(quest:Quest {active: true}) WITH q_mission ' \
            'MATCH (q_mission)<-[:ABOUT]-(updates:Update) ' \
            'WHERE NOT((q_mission)-[:FOCUSED_ON]' \
            '->(:Position {verified:false}))' \
            ' AND updates.created > %s AND updates.is_closed = False ' \
            'RETURN updates, NULL AS solutions, NULL AS posts, ' \
            'NULL AS questions, updates.created AS created, ' \
            'NULL AS s_question, NULL as mission, q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the posts owned by users that the current user ' \
            '// is following \n' \
            'MATCH (a:Pleb {username: "******"})-[r:FOLLOWING {active: True}]->' \
            '(:Pleb)<-[:OWNED_BY]-(posts:Post) ' \
            'WHERE posts.to_be_deleted = False AND ' \
            'posts.created > %s AND posts.is_closed = False ' \
            'RETURN NULL AS solutions, posts AS posts, ' \
            'NULL AS questions, posts.created AS created, ' \
            'NULL AS s_question, NULL AS mission, NULL AS updates, ' \
            'NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the users questions that the current user is ' \
            '// following \n' \
            'MATCH (a:Pleb {username: "******"})-[r:FOLLOWING {active: True}]->' \
            '(:Pleb)<-[:OWNED_BY]-(questions:Question) ' \
            'WHERE questions.to_be_deleted = False AND ' \
            'questions.created > %s AND questions.is_closed = False ' \
            'RETURN NULL AS solutions, NULL AS posts, ' \
            'questions AS questions, questions.created AS created, ' \
            'NULL AS s_question, NULL AS mission, NULL AS updates, ' \
            'NULL AS q_mission, ' \
            'NULL AS news UNION ' \
            '' \
            '// Retrieve all the users solutions that the current user is ' \
            '// following \n' \
            'MATCH (a:Pleb {username: "******"})-[r:FOLLOWING {active: True}]->' \
            '(:Pleb)<-[:OWNED_BY]-(solutions:Solution)<-' \
            '[:POSSIBLE_ANSWER]-(s_question:Question) ' \
            'WHERE s_question.to_be_deleted = False AND ' \
            'solutions.created > %s AND solutions.is_closed = False ' \
            'RETURN solutions, NULL AS posts, ' \
            'NULL AS questions, solutions.created AS created, ' \
            's_question as s_question, NULL AS mission, NULL AS updates, ' \
            'NULL AS q_mission, ' \
            'NULL AS news' \
            % (
                request.user.username, then, request.user.username, then,
                request.user.username, then,
                request.user.username, then, request.user.username, then,
                request.user.username, then, request.user.username, then,
                request.user.username, then, request.user.username, then,
                request.user.username, then)
        news = []
        res, _ = db.cypher_query(query)
        # Profiled with ~50 objects and it was still performing under 1 ms.
        # By the time sorting in python becomes an issue the above mentioned
        # ticket should be resolved.
        res = sorted(res, key=attrgetter('created'), reverse=True)
        page = self.paginate_queryset(res)
        for row in page:
            news_article = None
            if row.questions is not None:
                row.questions.pull()
                news_article = QuestionSerializerNeo(Question.inflate(
                    row.questions),
                                                     context={
                                                         'request': request
                                                     }).data
            elif row.solutions is not None:
                row.s_question.pull()
                row.solutions.pull()
                question_data = QuestionSerializerNeo(
                    Question.inflate(row.s_question)).data
                news_article = SolutionSerializerNeo(Solution.inflate(
                    row.solutions),
                                                     context={
                                                         'request': request
                                                     }).data
                news_article['question'] = question_data
            elif row.posts is not None:
                row.posts.pull()
                news_article = PostSerializerNeo(Post.inflate(row.posts),
                                                 context={
                                                     'request': request
                                                 }).data
            elif row.mission is not None:
                row.mission.pull()
                news_article = MissionSerializer(Mission.inflate(row.mission),
                                                 context={
                                                     'request': request
                                                 }).data
                news_article['reputation'] = Pleb.get(
                    username=news_article['owner_username']).reputation
            elif row.updates is not None:
                row.updates.pull()
                row.q_mission.pull()
                news_article = UpdateSerializer(Update.inflate(row.updates),
                                                context={
                                                    'request': request
                                                }).data
                news_article['mission'] = MissionSerializer(
                    Mission.inflate(row.q_mission),
                    context={
                        'request': request
                    }).data
            elif row.news is not None:
                row.news.pull()
                news_article = NewsArticleSerializer(NewsArticle.inflate(
                    row.news),
                                                     context={
                                                         'request': request
                                                     }).data
            news.append(news_article)
        return self.get_paginated_response(news)