def clear(self, request, **kwargs): self.method_check(request, allowed=['post']) notice_id = kwargs['notice_id'].encode('utf-8') dummy_data = {} es_check = False my_auth = MyBasicAuthentication() es_check = my_auth.is_authenticated(request, **kwargs) if es_check: param = { 'act': 'update_notice_state', 'token': es_check['t'], 'operator': es_check['u'], 'account_id': es_check['i'], 'notice_ids': notice_id, } print "######################clear param: ",param res = BackendRequest.get_notice(param) if res['result']: dummy_data["status"] = '1' else: dummy_data["status"] = '0' dummy_data["msg"] =res.get('error','clear notices error!') else: dummy_data["status"] = "0" dummy_data["msg"] = "auth error!" dummy_data["location"] = "/auth/login/" bundle = self.build_bundle(obj=dummy_data, data=dummy_data, request=request) response_data = bundle resp = self.create_response(request, response_data) return resp
def notices(self, request, **kwargs): self.method_check(request, allowed=['get']) dummy_data = {} es_check = False my_auth = MyBasicAuthentication() es_check = my_auth.is_authenticated(request, **kwargs) if es_check: param = { 'act': 'get_notice_list', 'token': es_check['t'], 'operator': es_check['u'], 'account_id': es_check['i'], } res = BackendRequest.get_notice(param) if res['result']: dummy_data["status"] = '1' dummy_data["data"] =res.get('notices') else: dummy_data["status"] = '0' dummy_data["msg"] =res.get('error','get notices error!') else: dummy_data["status"] = "0" dummy_data["msg"] = "auth error!" dummy_data["location"] = "/auth/login/" bundle = self.build_bundle(obj=dummy_data, data=dummy_data, request=request) response_data = bundle resp = self.create_response(request, response_data) return resp