示例#1
0
    def uncollect_market(self, request):
        """
        从收藏的市场中删除目标市场
        :param request 请求
        :return:
        """

        # 验证权限
        user = Auth.get_user(request)
        if not user:
            return HttpResponse(json.dumps(Auth.get_no_permission_msg()))

        # 获取参数
        market_id = request.POST.get('id', 0)
        if market_id == 0:
            return HttpResponse(json.dumps(self._error_msg['market_id_error']))

        # 查询是否已收藏过目标市场
        if market_id not in user.collected_markets:
            return HttpResponse(
                json.dumps(self._error_msg['market_none_error']))

        # 处理请求
        if not user.update(pull__collected_markets=market_id,
                           dec__collected_market_num=1):
            return HttpResponse(json.dumps(self._error_msg['general_error']))

        # 返回正确响应
        return HttpResponse(json.dumps(self._success_msg))
示例#2
0
文件: views.py 项目: sufay3/Backend
    def read_notify(self, request):
        """
        通知被读取时的处理程序
        :param request: 请求
        :return:
        """

        # 验证权限
        user = Auth.get_user(request)
        if not user:
            return HttpResponse(json.dumps(Auth.get_no_permission_msg()))

        # 返回正确响应
        return HttpResponse(json.dumps(self._success_msg))