def get(self, *args, **kwargs): template_param = { "page_tab": "phone_manage", "current_user": None, "phones": [] } template_param["current_user"] = self.current_user phones = get_all_phone(self.session) template_param["phones"] = phones self.render("page/phone_manage.html", **template_param)
def get(self, *args, **kwargs): result = { "errno": 0, "reason": "", "phone_info": [] } phone_id = self.get_argument("phoneId", default="") if not phone_id: phones = get_all_phone(self.session) for phone in phones: usage = get_phone_usage(self.session, phone) result["phone_info"].append(dict( phoneId=phone.phone_id, identifier=phone.identifier, product=phone.product, mode=phone.mode, dpi=phone.dpi, osv=phone.osv, osvalias=phone.osv_alias, belongs=phone.belongs, currentuser=usage.email if usage is not None else "" )) else: phone = get_phone_by_phone_id(self.session, phone_id) usage = get_phone_usage(self.session, phone) if not phone: result["phone_info"] = [] else: result["phone_info"] = [dict( qiyi_id=phone.qiyi_id, phoneId=phone.phone_id, identifier=phone.identifier, product=phone.product, mode=phone.mode, dpi=phone.dpi, osv=phone.osv, osvalias=phone.osv_alias, belongs=phone.belongs, currentuser=usage.email if usage is not None else "" )] return self.write(json.dumps(result))