def post(self): the_post = Post() username = the_post.get_username(self) cellphone_key = the_post.get_cellphone_key(self) user_instance = DBOHHOUser() cellphone_instance = DBCellphone() relation_instance = DBOHHOUserAndCellphoneRelation() user = user_instance.get_by_username(username) cellphone_instance.set_key(cellphone_key) cellphone = cellphone_instance.get_by_key() if user and cellphone: relation = relation_instance.get_by_cellphone_and_user( cellphone.id, user.id) if not relation: data = dict() data["user_id"] = user.id data["cellphone_id"] = cellphone.id success = relation_instance.add(data) if success: return self.redirect(USER_AND_CELLPHONE_LIST_URL) else: if not relation.state: relation_instance.restore(relation) return self.redirect(USER_AND_CELLPHONE_LIST_URL) return self.redirect(USER_AND_CELLPHONE_ADD_URL)
def post(self): the_post = Post() self.set_format(the_post.get_format(self)) country_code = the_post.get_cellphone_country_code(self) cellphone_key = the_post.get_cellphone_key(self) cellphone_number = the_post.get_cellphone_number(self) cellphone_dict = the_post.get_cellphone(self) code = the_post.get_code(self) base_url = the_post.get_base_url(self) instance = LogicRebindCellphone() result = instance.rebind_cellphone(cellphone_key, cellphone_number, code, base_url, cellphone_dict, country_code) return self.response(result)
def post(self): user_instance = DBOHHOUser() cellphone_instance = DBCellphone() relation_instance = DBOHHOUserAndCellphoneRelation() the_post = Post() username = the_post.get_username(self) relation_id = the_post.get_id(self) detail_url = USER_AND_CELLPHONE_DETAIL_URL + "?id=" + relation_id cellphone_key = the_post.get_cellphone_key(self) user = user_instance.get_by_username(username) cellphone_instance.set_key(cellphone_key) cellphone = cellphone_instance.get_by_key() relation = relation_instance.get_by_id(relation_id) submit = self.get_body_argument("submit", None) delete_or_restore = self.get_body_argument("delete_or_restore", None) if submit: if cellphone and user: if relation: data = dict() data["user_id"] = user.id data["cellphone_id"] = cellphone.id success = relation_instance.update(relation, data) if success: return self.redirect(USER_AND_CELLPHONE_LIST_URL) return self.redirect(detail_url) # if delete_or_restore: # if cellphone and user: # if relation: # if relation.state: # # print("execute delete") # success = relation_instance.delete(relation) # if success: # return self.redirect(USER_AND_CELLPHONE_LIST_URL) # else: # # print("execute restore") # success = relation_instance.restore(relation) # if success: # return self.redirect(USER_AND_CELLPHONE_LIST_URL) return self.redirect(detail_url)
def post(self): pass the_post = Post() cellphone_key = the_post.get_cellphone_key(self) detail_url = MANAGEMENT_CELLPHONE_DETAIL_URL + "?cellphone_key=" + str( cellphone_key) submit = self.get_body_argument("submit", "") cancel = self.get_body_argument("cancel", "") delete = self.get_body_argument("delete", "") instance = Cellphone(cellphone_key) if cancel: return self.redirect(MANAGEMENT_CELLPHONE_LIST_URL) if delete: cellphone = instance.get() if cellphone: success = instance.delete(cellphone) if success: return self.redirect(MANAGEMENT_CELLPHONE_LIST_URL) else: return self.redirect(detail_url) if submit: cellphone = instance.get() data = dict() data["operation"] = the_post.get_cellphone_operation(self) data[ "operation_version"] = the_post.get_cellphone_operation_version( self) data["manufacturer"] = the_post.get_cellphone_manufacturer(self) data["platform_type"] = the_post.get_cellphone_platform_type(self) success = instance.update(cellphone, data) if success: return self.redirect(MANAGEMENT_CELLPHONE_LIST_URL) else: return self.redirect(detail_url) return self.redirect(detail_url)