def get_personal_page_extension_by_user_id(user_id, base_url): """通过user_id 获取到额外的信息(个人主页的信息)""" user = User() user_accuracy_extension_instance = DBOHHOUserAccuracyExtension() user_extension = user_accuracy_extension_instance.get_by_user_id_only_one( user_id) data = dict() if user_extension: data = user_accuracy_extension_instance.get_information( user_extension, base_url) if user_extension.occupation_id: data["occupation_name"] = user_extension.occupation.name else: data["occupation_name"] = "" if user_extension.position_id: data["position_name"] = user_extension.position.name else: data["position_name"] = "" if user_extension.degree_id: data["degree_name"] = user_extension.degree.name else: data["degree_name"] = "" if user_extension.birthday: data["age"] = user.get_age(user_extension.birthday) data["zodiac"] = user.get_zodiac(user_extension.birthday) OHHOLog.print_log("user_accuracy_extension_data") OHHOLog.print_log(data) return data
def get(self): the_get = Get() user_instance = User() relation_instance = UserAndMatchCondition() user_and_match_condition_id = the_get.get_id(self) relation = relation_instance.get_by_id(user_and_match_condition_id) username = "" match_condition_id = "" name = "" if relation: user = user_instance.get_by_id(relation.user_id) username = user.username if relation.match_condition_id is not None: match_condition_id = relation.match_condition_id if relation.name is not None: name = relation.name return self.render(USER_AND_MATCH_CONDITION_DETAIL_HTML, username=username, name=name, match_condition_id=match_condition_id, user_and_match_condition_id=user_and_match_condition_id, detail_url=USER_AND_MATCH_CONDITION_DETAIL_URL, list_url=USER_AND_MATCH_CONDITION_LIST_URL )
def get(self): username = self.current_user user = User() user_object = user.get_by_username(username) if user_object: cellphone = user_object.cellphone country_code = user.get_country_code_by_id( user_object.country_code_id) if not country_code: country_code = "+86" last_login = OHHODatetime.clock2string( OHHODatetime.utc2beijing(user_object.last_login)) else: cellphone = "" country_code = "+86" last_login = "" cellphone = cellphone if cellphone else "" phone = country_code + "-" + cellphone return self.render( BACKSTAGE_HOME_HTML, phone=phone, last_login=last_login, user_url=MANAGEMENT_USER_LIST_URL, staff_url=MANAGEMENT_STAFF_LIST_URL, device_url=MANAGEMENT_DEVICE_LIST_URL, cellphone_url=MANAGEMENT_CELLPHONE_LIST_URL, relation_url=MANAGEMENT_RELATION_HOME_URL, base_home_url=MANAGEMENT_BASE_HOME_URL, permission_home_url=MANAGEMENT_PERMISSION_HOME_URL, statistics_user=STATISTICS_USER_URL, statistics_device=STATISTICS_DEVICE_URL, )
def post(self): instance = User() the_post = Post() country_code = the_post.get_cellphone_country_code(self) username = the_post.get_username(self) password = the_post.get_password(self) if not username or not password or not country_code: message = "username or password or country_code is empty" return self.redirect("/backstage/login/?data=%s" % message) else: success, the_username = instance.check_user4backstage( username, password, country_code) if success: OHHOLog.print_log("login success") user_instance = instance.get_by_username(the_username) if user_instance: instance.token.add(user_instance.id) update_success = instance.update_user( user_instance, {"last_login": OHHODatetime.get_utc_now()}) OHHOLog.print_log(update_success) else: OHHOLog.print_log("no such user") self.set_secure_cookie("username", the_username) return self.redirect("/backstage/home/") if the_username: message = "password is incorrect" else: message = "user does not exist" return self.redirect("/backstage/login/?data=%s" % message)
def __init__(self): self.blue_tooth = Bluetooth() self.meet = Meet() self.user = User() self.device = DBOHHODevice() self.relation = DBOHHOUserAndDeviceRelation() self.display_configuration = DBOHHOUserDisplayConfiguration()
def post(self): the_post = Post() user_id = the_post.get_user_id(self) submit = the_post.get_submit(self) delete_or_restore = the_post.get_delete_or_restore(self) instance = User() user = instance.get_by_id(user_id) delete_url = MANAGEMENT_USER_DELETE_URL + "?user_id=" + str(user_id) if delete_or_restore and user: if user.state: success = instance.delete(user) else: success = instance.restore(user) if success: return self.redirect(MANAGEMENT_USER_LIST_URL) else: return self.redirect(delete_url) if submit: user_extension = the_post.get_user_extension(self) user_extension_instance = DBOHHOUserAccuracyExtension() user_extension_object = user_extension_instance.get_by_user( user_id) success = user_extension_instance.update(user_extension_object, user_extension) if success: return self.redirect(MANAGEMENT_USER_LIST_URL) else: return self.redirect(delete_url) return self.redirect(delete_url)
def get_user_and_friend_relation(user_id, friend_id): """个人主页判断是不是朋友关系""" user = User() temp_relation = user.get_user_and_friend_relation(user_id, friend_id) if temp_relation: relation = 1 else: relation = 0 return relation
def get(self): the_request = Get() self.set_format(the_request.get_format(self)) user_id = the_request.get_user_id(self) base_url = the_request.get_base_url(self) user = User() data = user.get_basic_user_information(user_id, base_url) result = Result.result_success() result["data"] = data return self.response(result)
def add_new_user(password, cellphone, country_code="+86"): username = OHHOUUID.get_uuid1_string() user = User() user.set_username(username) OHHOLog.print_log(user.add_user(password, cellphone, country_code)) the_user = user.get_by_username(username) if the_user: result = Result.result_success() result["user_id"] = the_user.id else: result = Result.result_failed() result["user_id"] = 0 return result
def get(self): instance = User() the_get = Get() username = the_get.get_username(self) if username: user = instance.get_by_username(username) if user: return self.write("false") else: return self.write("true") return self.render(BACKSTAGE_REGISTER_HTML, postUrl=BACKSTAGE_REGISTER_URL, msg="")
def post(self): the_post = Post() username = the_post.get_username(self) password = the_post.get_password(self) instance = User(username) result = instance.add_user(password) if result.get("code", 0) > 0: user_extension_dict = the_post.get_user_extension(self) user = instance.get_user() success = instance.add_user_extension(user.id, user_extension_dict) if success: return self.redirect(MANAGEMENT_USER_LIST_URL) return self.redirect(MANAGEMENT_USER_ADD_URL)
def post(self): # name = self.get_body_argument("user_name", None) result = dict() # base_url = the_post.get_base_url(self) user = User() user_id = 4 friend_user_id = 13 log_string = "1234567890" OHHOLog.print_log(log_string) # message = user.get_user_basic_information(user_id, base_url) user.push(log_string, friend_user_id, user_id) # return Result.result_success() self.write(OHHOOperation.dict2json(result))
def get(self): the_get = Get() user_id = the_get.get_user_id(self) instance = User() user = instance.get_by_id(user_id) country_code = instance.country_code.get_query() user_extension = instance.get_user_extension_by_user(user_id) if not user_extension: user_extension = instance.init_user_extension(user_id) return self.render(MANAGEMENT_USER_DELETE_HTML, user=user, user_extension=user_extension, country_code_list=country_code)
def get(self): the_get = Get() cellphone = the_get.get_cellphone_number(self) if cellphone is None: cellphone = "" state = the_get.get_state(self) if state is None: state = "" page = the_get.get_page(self) data_count_per_page = the_get.get_data_count_per_page(self) page_count_per_page = the_get.get_page_count_per_page(self) offset = (page - 1) * data_count_per_page limit = data_count_per_page instance = User() if cellphone: query = instance.find_by_cellphone(cellphone) # instance.get_by_cellphone(cellphone) # query = instance.find_by_username() else: query = instance.get_all() try: if state == "": pass elif int(state): query = instance.get_valid(query) else: query = instance.get_invalid(query) except Exception as ex: pass users, count = instance.get_some_users(query, offset, limit) total_page = int(ceil(count / data_count_per_page)) pagination = Pagination(total_page, page, data_count_per_page, page_count_per_page) page_list, previous, next = pagination.get_page_list_of_this_page() # return self.render("backstage/management/user_list.html", return self.render( MANAGEMENT_USER_LIST_HTML, users=users, pages=page_list, previous=previous, next=next, page=page, cellphone_number=cellphone, state=state, detail_url=MANAGEMENT_USER_DETAIL_URL, delete_url=MANAGEMENT_USER_DELETE_URL, )
def __init__(self): self.device = Device() self.user = User() self.meet = Meet() self.friend = Friend() self.map = DBOHHOMapInformation() self.match_condition = LogicGetMatchCondition() self.condition = MatchCondition() self.condition_relation = UserAndMatchCondition() self.device_relation = DBOHHOUserAndDeviceRelation() self.user_extension = DBOHHOUserAccuracyExtension() self.exclude = DBOHHORecordExclude() self.configuration = DBOHHOUserConfiguration() self.match_apply = DBOHHORecordMatchApply() self.favourite_book = DBOHHOUserFavouriteBook() self.favourite_movie = DBOHHOUserFavouriteMovie() self.favourite_music = DBOHHOUserFavouriteMusic() self.favourite_sport = DBOHHOUserFavouriteSport() self.match_online = DBOHHOMatchOnline()
def get(self): the_get = Get() user_id = the_get.get_user_id(self) friend_user_id = the_get.get_friend_id(self) is_delete = the_get.get_delete(self) user = User() meet = Meet() the_user = user.get_by_id(user_id) the_friend = user.get_by_id(friend_user_id) if is_delete: met_instance = meet.get_met_by_users(user_id, friend_user_id) success = meet.met.delete(met_instance) if success: result = Result.result_success("delete successfully!") else: result = Result.result_failed("delete failed!") else: if the_user and the_friend: success = meet.add_apply(user_id, friend_user_id) if success: apply = meet.get_apply_by_user_and_friend( user_id, friend_user_id) if apply: data = dict() data["apply_id"] = apply.id data["user_id"] = user_id data["another_user_id"] = friend_user_id success = meet.add_met(data) if success: result = Result.result_success("add successfully!") else: result = Result.result_failed("add met failed!") else: result = Result.result_failed("get apply failed!") else: result = Result.result_failed("add apply failed!") else: result = Result.result_failed("user does not exist!") self.write(OHHOOperation.dict2json(result))
def get(self): # name = self.get_body_argument("user_name", None) the_get = Get() result = dict() base_url = the_get.get_base_url(self) user_id = the_get.get_user_id(self) friend_user_id = the_get.get_friend_id(self) user = User() friend_user_id2 = user_id if user_id else 4 user_id = 4 friend_user_id = friend_user_id if friend_user_id else 13 log_string = "1234567890" OHHOLog.print_log(log_string) # message = user.get_user_basic_information(user_id, base_url) for i in range(100): OHHOLog.print_log(user.push(str(i), friend_user_id, user_id)) OHHOLog.print_log(user.push(str(i), friend_user_id2, user_id)) # return Result.result_success() self.write(OHHOOperation.dict2json(Result.result_success()))
def post(self): the_post = Post() user_instance = User() relation_instance = UserAndMatchCondition() username = the_post.get_username(self) name = the_post.get_name(self) match_condition_id = the_post.get_match_condition_id(self) user_and_match_condition_id = the_post.get_id(self) relation = relation_instance.get_by_id(user_and_match_condition_id) match_condition = relation_instance.get_match_condition( match_condition_id) submit = the_post.get_submit(self) delete = the_post.get_delete(self) detail_url = USER_AND_MATCH_CONDITION_DETAIL_URL + "?id=" + user_and_match_condition_id user = user_instance.get_by_cellphone(username) OHHOLog.print_log(submit) OHHOLog.print_log(relation) OHHOLog.print_log(user) OHHOLog.print_log(match_condition) if submit and relation and user and match_condition: OHHOLog.print_log("start logic") data = dict() data["user_id"] = user.id data["name"] = name data["match_condition_id"] = match_condition_id success = relation_instance.update(relation, data) if success: return self.redirect(USER_AND_MATCH_CONDITION_LIST_URL) if delete and relation: success = relation_instance.delete(relation) if success: return self.redirect(USER_AND_MATCH_CONDITION_LIST_URL) return self.redirect(detail_url)
def post(self): user = User() the_post = Post() country_code = the_post.get_country_code(self) cellphone = the_post.get_username(self) password = the_post.get_password(self) code = the_post.get_code(self) instance = LogicBackstageRegister() register_instance = LogicRegister() msg = "" country_code_object = user.get_country_code(country_code) if country_code_object and not user.get_by_country_code_and_cellphone( country_code_object.id, cellphone): register_result = register_instance.add_new_user( password, cellphone, country_code) OHHOLog.print_log(register_result) if Result.is_success(register_result): user_id = register_result.get("user_id", 0) user_object = user.get_by_id(user_id) if user_object: self.set_secure_cookie("username", user_object.username) return self.redirect("/backstage/home/") # if Code.check_code(username, code): # 目前验证码没有用,先注释掉 # pass # else: # return self.render(BACKSTAGE_REGISTER_HTML, # postUrl=BACKSTAGE_REGISTER_URL, # msg="验证码不正确" # ) # if username and password: # result1 = instance.register(username, password) # if result1: # self.set_secure_cookie("username", username) # return self.redirect("/backstage/home/") return self.render(BACKSTAGE_REGISTER_HTML, postUrl=BACKSTAGE_REGISTER_URL, msg="注册不成功")
def post(self): user = User() the_post = Post() self.set_format(the_post.get_format(self)) user_id = the_post.get_user_id(self) friend_user_id = the_post.get_friend_id(self) apply_id = the_post.get_apply_id(self) category = the_post.get_category(self) reason = the_post.get_reason(self) content = the_post.get_content(self) base_url = the_post.get_base_url(self) cancel_meet = LogicCancelMeet() cancel_meet.cancel_meet(user_id, friend_user_id, apply_id, base_url) feedback = LogicAddCancelMeetFeedback() result = feedback.add_feedback(user_id, friend_user_id, apply_id, reason, content, category) information = user.get_cancel_meet_user_information(user_id, apply_id, base_url) information["message"] = content user.push_user_information(friend_user_id, PUSH_STATE_TYPE_CANCEL_MEET, information) return self.response(result)
def __init__(self): self.user = User()
def __init__(self): self.user = User() self.cellphone = Cellphone()
def __init__(self): self.user = User() self.country_code = DBOHHOCountryCode() self.cellphone = Cellphone()
def __init__(self): self.agree = MatchAgree() self.apply = MatchApply() self.refuse = MatchRefuse() self.meet = Meet() self.user = User()
def __init__(self): self.meet = Meet() self.user = User() self.apply = DBOHHORecordMatchApply()
def get(self): the_get = Get() cellphone_instance = Cellphone() relation_instance = UserAndCellphoneRelation() user_instance = User() users_query = user_instance.get_all() users_query = user_instance.get_valid(users_query) cellphones_query = cellphone_instance.get_all_cellphone() cellphone_key = the_get.get_cellphone_key(self) if cellphone_key is None: cellphone_key = "" username = the_get.get_username(self) if username is None: username = "" page = the_get.get_page(self) data_count_per_page = the_get.get_data_count_per_page(self) page_count_per_page = the_get.get_page_count_per_page(self) offset = (page - 1) * data_count_per_page limit = data_count_per_page query = relation_instance.get_all() if cellphone_key: cellphone_query = cellphone_instance.get_all_cellphone() cellphone_query = cellphone_instance.find_by_key( cellphone_query, cellphone_key) cellphone_id_list = list() if not cellphone_instance.cellphone.is_empty(cellphone_query): cellphone_id_list = [ cellphone.id for cellphone in cellphone_query ] query = relation_instance.find_by_cellphone( query, cellphone_id_list) if username: user_query = user_instance.find_by_username(username) user_id_list = list() if not user_instance.user.is_empty(user_query): user_id_list = [user.id for user in user_query] query = relation_instance.find_by_user(query, user_id_list) query, count = relation_instance.get_some(query, offset, limit) total_page = int(ceil(count / data_count_per_page)) pagination = Pagination(total_page, page, data_count_per_page, page_count_per_page) page_list, previous, next = pagination.get_page_list_of_this_page() relations = list() for q in query: temp = dict() temp["id"] = q.id temp["state"] = q.state user = user_instance.get_by_id(q.user_id) temp["username"] = user.username if user else "" temp["user_id"] = user.id if user else "" cellphone = cellphone_instance.get_by_id(q.cellphone_id) temp["key"] = cellphone.key if cellphone else "" temp["cellphone_id"] = cellphone.id if cellphone else "" relations.append(temp) return self.render(USER_AND_CELLPHONE_LIST_HTML, relations=relations, pages=page_list, previous=previous, next=next, page=page, list_url=USER_AND_CELLPHONE_LIST_URL, detail_url=USER_AND_CELLPHONE_DETAIL_URL, add_url=USER_AND_CELLPHONE_ADD_URL, delete_url=USER_AND_CELLPHONE_DELETE_URL, username=username, cellphone_key=cellphone_key, users_query=users_query, cellphones_query=cellphones_query)
def __init__(self): self.map = DBOHHOMapInformation() self.user = User() self.meet = Meet() self.apply = DBOHHORecordMatchApply() self.user_configuration = DBOHHOUserConfiguration()
def __init__(self): self.device = Device() self.imei = IMEI() self.user = User()
def __init__(self): self.apply = MatchApply() self.condition = MatchCondition() self.meet = Meet() self.user = User()
def __init__(self, user_id): self.user_id = user_id self.user = User() self.map = DBOHHOMapInformation() self.impression = DBOHHOUserImpression() self.extension = DBOHHOUserAccuracyExtension()