|
@@ -13,7 +13,7 @@ from fields.intention_fields import (
|
|
|
intention_keyword_detail_fields,
|
|
|
intention_keyword_fields,
|
|
|
intention_page_fields,
|
|
|
- intention_type_fields,
|
|
|
+ intention_type_detail_fields, intention_type_page_fields,
|
|
|
)
|
|
|
from libs.login import login_required
|
|
|
from services.intention_service import (
|
|
@@ -110,7 +110,7 @@ class IntentionTypeListApi(Resource):
|
|
|
limit = request.args.get("limit", default=20, type=int)
|
|
|
search = request.args.get("search", default=None, type=str)
|
|
|
intention_types, total = IntentionTypeService.get_intention_types(page, limit, search)
|
|
|
- data = marshal(intention_types, intention_type_fields)
|
|
|
+ data = marshal(intention_types, intention_type_page_fields)
|
|
|
response = {"data": data, "has_more": len(intention_types) == limit, "limit": limit,
|
|
|
"total": total, "page": page}
|
|
|
return response, 200
|
|
@@ -128,13 +128,20 @@ class IntentionTypeListApi(Resource):
|
|
|
)
|
|
|
args = parser.parse_args()
|
|
|
intention_type = IntentionTypeService.save_intention_type(args)
|
|
|
- response = marshal(intention_type, intention_type_fields)
|
|
|
+ response = marshal(intention_type, intention_type_detail_fields)
|
|
|
return response, 200
|
|
|
|
|
|
class IntentionTypeApi(Resource):
|
|
|
@setup_required
|
|
|
@login_required
|
|
|
@account_initialization_required
|
|
|
+ def get(self, intention_type_id):
|
|
|
+ intention_type = IntentionTypeService.get_intention_type(intention_type_id)
|
|
|
+ return marshal(intention_type, intention_type_detail_fields)
|
|
|
+
|
|
|
+ @setup_required
|
|
|
+ @login_required
|
|
|
+ @account_initialization_required
|
|
|
def patch(self, intention_type_id):
|
|
|
parser = reqparse.RequestParser()
|
|
|
parser.add_argument(
|
|
@@ -145,8 +152,7 @@ class IntentionTypeApi(Resource):
|
|
|
)
|
|
|
args = parser.parse_args()
|
|
|
intention_type = IntentionTypeService.update_intention_type(intention_type_id, args)
|
|
|
- response = {"id": intention_type.id, "name": intention_type.name}
|
|
|
- return response, 200
|
|
|
+ return marshal(intention_type, intention_type_detail_fields), 200
|
|
|
|
|
|
@setup_required
|
|
|
@login_required
|