コード例 #1
0
ファイル: queries.py プロジェクト: polylogyx/plgx-esp
    def post(self):
        args = self.parser.parse_args(
        )  # need to exists for input payload validation

        query_id = args['query_id']
        status = 'failure'
        message = None

        add_tags = args['add_tags'].split(',')
        remove_tags = args['remove_tags'].split(',')
        if not (add_tags or remove_tags):
            message = 'Please provide tags'
        else:
            query = dao.get_query_by_id(query_id)
            if not query:
                message = 'Invalid query id. Query with this id does not exist'
            else:
                if add_tags:
                    add_tags = create_tags(*add_tags)
                    for add_tag in add_tags:
                        if not add_tag in query.tags:
                            query.tags.append(add_tag)

                if remove_tags:
                    remove_tags = get_tags(*remove_tags)
                    for remove_tag in remove_tags:
                        if remove_tag in query.tags:
                            query.tags.remove(remove_tag)
                query.save()
                status = 'success'
                message = 'Successfully modified the tag(s)'
        return marshal(respcls(message, status),
                       parentwrapper.common_response_wrapper,
                       skip_none=True)
コード例 #2
0
 def post(self, query_id):
     args = self.parser.parse_args(
     )  # need to exists for input payload validation
     tags = args['tags'].split(',')
     query = dao.get_query_by_id(query_id)
     obj_list = get_tags_list_to_add(tags)
     query.tags.extend(obj_list)
     query.save()
     return marshal(respcls('Successfully created the tag(s) to queries',
                            'success'),
                    parentwrapper.common_response_wrapper,
                    skip_none=True)
コード例 #3
0
ファイル: queries.py プロジェクト: polylogyx/plgx-esp
 def get(self, query_id):
     status = 'failure'
     query = dao.get_query_by_id(query_id)
     if not query:
         message = 'Invalid query id. This query does not exist'
         data = None
     else:
         data = tag_name_format(query.tags)
         status = 'success'
         message = 'Successfully fetched the tag(s)'
     return marshal(respcls(message, status, data),
                    parentwrapper.common_response_wrapper,
                    skip_none=True)
コード例 #4
0
ファイル: queries.py プロジェクト: polylogyx/plgx-esp
 def post(self, query_id):
     if query_id:
         query = dao.get_query_by_id(query_id)
         if query:
             return marshal(
                 respcls(
                     "successfully fecthed the query info for the given id",
                     "success", marshal(query, wrapper.query_wrapper)),
                 parentwrapper.common_response_wrapper)
         else:
             message = "Query with this id does not exist"
     else:
         message = "Missing query id"
     return marshal(respcls(message), parentwrapper.failure_response_parent)
コード例 #5
0
ファイル: queries.py プロジェクト: polylogyx/plgx-esp
 def get(self, query_id):
     if query_id:
         query_qs = dao.get_query_by_id(query_id)
         if query_qs:
             query = marshal(query_qs, wrapper.query_wrapper)
             query['tags'] = [tag.to_dict() for tag in query_qs.tags]
             query['packs'] = [pack.name for pack in query_qs.packs]
             return marshal(
                 respcls(
                     "successfully fecthed the query info for the given id",
                     "success", query),
                 parentwrapper.common_response_wrapper)
         else:
             message = "Query with this id does not exist"
     else:
         message = "Missing query id"
     return marshal(respcls(message), parentwrapper.failure_response_parent)