本文整理汇总了Python中utils.Serializer.json_response函数的典型用法代码示例。如果您正苦于以下问题:Python json_response函数的具体用法?Python json_response怎么用?Python json_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_response函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _view3
def _view3(request, *args, **kwargs):
post = request.POST
if not post or not post.get('token'):
_LOGGER.info('Token Required for Manager.')
return json_response(PARAM_REQUIRED, CODE_MESSAGE.get(PARAM_REQUIRED))
token = post.get('token')
user_meta = {}
try:
my_manager = manager.canteen_get_by_token(token)
_LOGGER.info('Token hit in db for Manager User')
user_meta.update({'manager_model': my_manager})
user_meta.update({"flag": CANTEEN_FLAG})
request.user_meta = user_meta
except ObjectDoesNotExist:
pass
# _LOGGER.info('Token not in db for Canteen Manager.')
# return json_response(TOKEN_INVALID, CODE_MESSAGE.get(TOKEN_INVALID))
if user_meta.get("flag",None) is None:
try:
my_manager = manager.school_get_by_token(token)
_LOGGER.info('Token hit in db for School User')
user_meta.update({'manager_model': my_manager})
user_meta.update({"flag": SCHOOL_FLAG})
request.user_meta = user_meta
except ObjectDoesNotExist:
_LOGGER.info('Token not in db for Manager.')
return json_response(TOKEN_INVALID, CODE_MESSAGE.get(TOKEN_INVALID))
return func(request, *args, **kwargs)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:28,代码来源:Decorator.py
示例2: sm_delete_notice
def sm_delete_notice(request):
school_manager = request.user_meta.get("manager_model")
notice_id = request.POST.get("notice_id")
notice_model = notice.get_school_notice_by_id(notice_id)
if school_manager != notice_model.manager:
return json_response(AUTHORFAILED, CODE_MESSAGE.get(AUTHORFAILED))
notice.delte_notice(notice_model)
return json_response(OK, CODE_MESSAGE.get(OK))
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:8,代码来源:views.py
示例3: customer_custom_addr_delete
def customer_custom_addr_delete(request):
address_form = AddressDeleteForm(request.POST)
if address_form.is_valid():
address_dict = address_form.cleaned_data
customer_model = request.user_meta['customer_model']
customer.delete_custom_addr(customer_model, address_dict)
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(PARAM_REQUIRED, address_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:9,代码来源:cus_views.py
示例4: window_dish_delete
def window_dish_delete(request):
delete_id_list_form = DeleteIdListForm(request.POST)
if delete_id_list_form.is_valid():
delete_id_list_dict = delete_id_list_form.cleaned_data
delete_id_list = delete_id_list_dict['data']
window_id = request.user_meta['window_model'].id
dish.delete(window_id, delete_id_list)
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(PARAM_REQUIRED, delete_id_list_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:10,代码来源:win_views.py
示例5: window_order_update
def window_order_update(request):
order_update_form = WindowOrderUpdateForm(request.POST)
if order_update_form.is_valid():
order_update_dict = order_update_form.cleaned_data
window_id = request.user_meta['window_model'].id
impact = order.update_status_bywin(window_id, order_update_dict)
if impact == 1:
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(DB_ERROR, CODE_MESSAGE.get(DB_ERROR))
else:
return json_response(PARAM_REQUIRED, order_update_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:12,代码来源:win_views.py
示例6: window_dish_update
def window_dish_update(request):
dish_update_form = DishUpdateForm(request.POST, request.FILES)
if dish_update_form.is_valid():
dish_update_dict = dish_update_form.cleaned_data
window_id = request.user_meta['window_model'].id
impact = dish.update(window_id, dish_update_dict)
if impact == 1:
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(DB_ERROR, CODE_MESSAGE.get(DB_ERROR))
else:
return json_response(PARAM_REQUIRED, dish_update_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:12,代码来源:win_views.py
示例7: _view
def _view(request, *args, **kwargs):
post = request.POST
if not post or not post.get('token'):
_LOGGER.info('Token Required for User')
return json_response(PARAM_REQUIRED, CODE_MESSAGE.get(PARAM_REQUIRED))
token = post.get('token')
if token == TOKEN:
# _LOGGER.info('Token is equal to Default TOKEN.')
return func(request, *args, **kwargs)
else:
_LOGGER.info('Token is not equal to Default TOKEN.')
return json_response(TOKEN_INVALID, CODE_MESSAGE.get(TOKEN_INVALID))
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:12,代码来源:Decorator.py
示例8: window_deliver_time_update
def window_deliver_time_update(request):
deliver_time_updated_form = DeliverTimeUpdateForm(request.POST)
if deliver_time_updated_form.is_valid():
deliver_time_updated_dict = deliver_time_updated_form.cleaned_data
window_id = request.user_meta['window_model'].id
impact = deliver_time.update(window_id, deliver_time_updated_dict)
if impact == 1:
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(DB_ERROR, CODE_MESSAGE.get(DB_ERROR))
else:
return json_response(PARAM_REQUIRED, deliver_time_updated_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:12,代码来源:win_views.py
示例9: window_password_update
def window_password_update(request):
window_password_form = PasswordUpdateForm(request.POST)
if window_password_form.is_valid():
window_password_dict = window_password_form.cleaned_data
window_model = request.user_meta['window_model']
if window_model.password == window_password_dict['old_password']:
window.update_password(window_model, window_password_dict)
return json_response_from_object(OK, CODE_MESSAGE.get(OK))
else:
return json_response(USER_PWD_ERROR, CODE_MESSAGE.get(USER_PWD_ERROR))
else:
return json_response(PARAM_REQUIRED, window_password_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:12,代码来源:win_views.py
示例10: window_order_display
def window_order_display(request):
pagination_form = PaginationForm(request.POST)
if pagination_form.is_valid():
pagination_dict = pagination_form.cleaned_data
window_id = request.user_meta['window_model'].id
order_status = pagination_dict['order_status']
if not order_status == ORDER_STATUS[0][0]:
order_bean_list = order.get_order_bean_list_bywin(window_id, order_status, pagination_dict)
return json_response_from_object(OK, order_bean_list, 'orderList')
else:
return json_response(ORDER_STATUS_ERROR, CODE_MESSAGE.get(ORDER_STATUS_ERROR))
else:
return json_response(PARAM_REQUIRED, pagination_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:13,代码来源:win_views.py
示例11: window_promotion_update
def window_promotion_update(request):
promotion_update_form = PromotionUpdateForm(request.POST)
if promotion_update_form.is_valid():
window_model = request.user_meta['window_model']
promotion_update_dict = promotion_update_form.cleaned_data
impact = promotion.update(window_model.id, promotion_update_dict)
if impact == 1:
window.update_promotion_list(window_model)
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(DB_ERROR, CODE_MESSAGE.get(DB_ERROR))
else:
return json_response(PARAM_REQUIRED, promotion_update_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:13,代码来源:win_views.py
示例12: window_deliver_time_create
def window_deliver_time_create(request):
deliver_time_form = DeliverTimeForm(request.POST)
if deliver_time_form.is_valid():
window_model = request.user_meta['window_model']
if window_model.deliver_time_number <= DELIVER_TIME_MAX:
new_deliver_time = deliver_time.create(deliver_time_form, False)
new_deliver_time.window = window_model
deliver_time_bean = deliver_time.create(new_deliver_time)
window.update_deliver_time_number(window_model, 1) # update deliver_time_number of window
return json_response_from_object(OK, deliver_time_bean)
else:
return json_response(DELIVER_TIME_REACH_MAX, CODE_MESSAGE.get(DELIVER_TIME_REACH_MAX))
else:
return json_response(PARAM_REQUIRED, deliver_time_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:14,代码来源:win_views.py
示例13: window_dish_create
def window_dish_create(request):
dish_form = DishForm(request.POST, request.FILES)
if dish_form.is_valid():
window_model = request.user_meta['window_model']
if window_model.dish_number <= DISH_MAX:
new_dish = dish.create(dish_form, False)
new_dish.window = window_model
dish_bean = dish.create(new_dish)
window.update_dish_number(window_model, 1) # update dish_number of window
return json_response_from_object(OK, dish_bean)
else:
return json_response(DISH_REACH_MAX, CODE_MESSAGE.get(DISH_REACH_MAX))
else:
return json_response(PARAM_REQUIRED, dish_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:14,代码来源:win_views.py
示例14: window_login
def window_login(request):
window_login_form = LoginForm(request.POST)
if window_login_form.is_valid():
window_login_dict = window_login_form.cleaned_data
try:
window_model = window.get_by_username(window_login_dict)
if window_model.password == window_login_dict['password']: # verify user's authority
window_bean = window.update_token(window_model, window_login_dict) # assign a token for user
return json_response_from_object(OK, window_bean)
else:
return json_response(USER_LOGIN_FAILED, CODE_MESSAGE.get(USER_LOGIN_FAILED))
except ObjectDoesNotExist:
return json_response(USER_NOT_EXIST, CODE_MESSAGE.get(USER_NOT_EXIST))
else:
return json_response(PARAM_REQUIRED, window_login_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:15,代码来源:win_views.py
示例15: sm_modify_own_notice
def sm_modify_own_notice(request):
change_notice_form = ChangeSNoticeForm(request.POST)
if change_notice_form.is_valid():
change_notice_dict= change_notice_form.cleaned_data
school_manager = request.user_meta.get("manager_model")
notice_id = request.POST.get("notice_id")
already_notice = notice.get_school_notice_by_id(notice_id)
# 只能修改自己发布的通知
if school_manager != already_notice.manager:
return json_response(AUTHORFAILED, CODE_MESSAGE.get(AUTHORFAILED))
notice_bean = notice.sm_modify_notice(already_notice, change_notice_dict)
return json_response_from_object(OK, notice_bean)
else:
return json_response(PARAM_REQUIRED, change_notice_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:15,代码来源:views.py
示例16: window_promotion_create
def window_promotion_create(request):
promotion_form = PromotionForm(request.POST)
if promotion_form.is_valid():
window_model = request.user_meta['window_model']
if window_model.promotion_number <= PROMOTION_MAX:
new_promotion = promotion.create(promotion_form, False)
new_promotion.window = window_model
promotion_bean = promotion.create(new_promotion)
window.update_promotion_number(window_model, 1) # update promotion_number of window
window.update_promotion_list(window_model)
return json_response_from_object(OK, promotion_bean)
else:
return json_response(PROMOTION_REACH_MAX, CODE_MESSAGE.get(PROMOTION_REACH_MAX))
else:
return json_response(PARAM_REQUIRED, promotion_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:15,代码来源:win_views.py
示例17: window_password_reset
def window_password_reset(request):
window_password_form = PasswordResetForm(request.POST)
if window_password_form.is_valid():
window_password_dict = window_password_form.cleaned_data
try:
window_model = window.get_by_username(window_password_dict) # verify user's authority
window.update_password(window_model, window_password_dict)
verify_code_model = request.verify_code_meta['verify_code_model']
verify_code_model.delete()
return json_response_from_object(OK, CODE_MESSAGE.get(OK))
except ObjectDoesNotExist:
verify_code_model = request.verify_code_meta['verify_code_model']
verify_code_model.delete()
return json_response(USER_NOT_EXIST, CODE_MESSAGE.get(USER_NOT_EXIST))
else:
return json_response(PARAM_REQUIRED, window_password_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:16,代码来源:win_views.py
示例18: window_sales_dish
def window_sales_dish(request):
sales_form = SalesForm(request.POST)
if sales_form.is_valid():
sales_dict = sales_form.cleaned_data
window_model = request.user_meta['window_model']
# get all dishes of this window
dish_model_list = dish.get_dish_list_bywin(window_model.id, {'page': 1, 'count': DISH_MAX})
# get all orders of this window during given time interval, and calculate sales of dishes.
sales_volume = 0
dish_sale_dict = {}
for dish_model in dish_model_list:
dish_sale_dict.update({dish_model: 0})
page = 1
while True:
order_model_list = order.get_order_list_ofwin(window_model, {'page': page, 'count': 1000}, sales_dict)
for order_model in order_model_list:
sales_volume += order_model.food_cost
order_dish_model_list = orderdish.get_dish_list_byorder(order_model)
for order_dish_model in order_dish_model_list:
dish_model = order_dish_model.dish
dish_sale_dict.update({dish_model: dish_sale_dict.get(dish_model)+order_dish_model.number})
page += 1
if len(order_model_list) < 1000:
break
# make it serialized
dish_sale_bean_list = []
for dish_model, sale in dish_sale_dict.items():
dish_sale_bean = DishSaleBean(dish_model, sale)
dish_sale_bean_list.append(dish_sale_bean)
# sorted by sales
sorted_dish_sale_bean_list = sorted(dish_sale_bean_list, key=operator.attrgetter("sales"), reverse=True)
result_dict = {"total": sales_volume, "dishList": sorted_dish_sale_bean_list}
return json_response_from_object(OK, result_dict)
else:
return json_response(PARAM_REQUIRED, CODE_MESSAGE.get(PARAM_REQUIRED))
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:35,代码来源:win_views.py
示例19: window_comment_reply
def window_comment_reply(request):
reply_form = ReplyForm(request.POST)
if reply_form.is_valid():
reply_dict = reply_form.cleaned_data
window_id = request.user_meta['window_model'].id
order_model = order.get_order_byid_bywin(window_id, reply_dict)
order_dish_model = orderdish.get_order_dish_byid(order_model, reply_dict)
if order_dish_model.comment_time: # user can only make reply on comments
if order_dish_model.reply_time is None:
orderdish.update_reply(order_dish_model, reply_dict)
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(ORDER_DISH_REPLIED, CODE_MESSAGE.get(ORDER_DISH_REPLIED))
else:
return json_response(ORDER_STATUS_ERROR, CODE_MESSAGE.get(ORDER_STATUS_ERROR))
else:
return json_response(PARAM_REQUIRED, CODE_MESSAGE.get(PARAM_REQUIRED))
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:17,代码来源:win_views.py
示例20: customer_order_update
def customer_order_update(request):
order_update_form = CustomerOrderUpdateForm(request.POST)
if order_update_form.is_valid():
order_update_dict = order_update_form.cleaned_data
customer_id = request.user_meta['customer_model'].id
impact = order.update_status_bycus(customer_id, order_update_dict)
if impact == 1:
if order_update_dict['new_order_status'] == ORDER_STATUS[1][0]:
jpush = JPush()
order_model = order.get_order_byid_bycus(customer_id, order_update_dict)
registration_id = order_model.window.registration_id
jpush.push_by_id(NEW_ORDER_MSG, registration_id)
return json_response(OK, CODE_MESSAGE.get(OK))
else:
return json_response(DB_ERROR, CODE_MESSAGE.get(DB_ERROR))
else:
return json_response(PARAM_REQUIRED, order_update_form.errors)
开发者ID:NobodyWHU,项目名称:QianXun-1,代码行数:17,代码来源:cus_views.py
注:本文中的utils.Serializer.json_response函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论