コード例 #1
0
class LogicAddUserAccuracyExtension(object):
    def __init__(self):
        self.user = User()

    def add_user_accuracy_extension(self, user_id, user_extension_dict):
        OHHOLog.print_log(user_extension_dict)
        result = self.user.add_user_extension(user_id, user_extension_dict)
        nickname = user_extension_dict.get(USER_EXTENSION_NICK_NAME, None)
        primary_interest = user_extension_dict.get(
            USER_EXTENSION_PRIMARY_INTEREST, "")
        primary_interest = OHHOOperation.dict2json(primary_interest)
        OHHOLog.print_log(user_extension_dict)
        OHHOLog.print_log(USER_EXTENSION_PRIMARY_INTEREST)
        OHHOLog.print_log(primary_interest)
        if nickname is not None:
            UpdateUserInfo.update_user_info(user_id, name=nickname)
        # create or update match condition
        relation = self.user.record_user_and_match_condition.get_nearest_by_user(
            user_id)
        if relation and relation.match_condition_id:
            condition = self.user.match_condition.get_by_id(
                relation.match_condition_id)
        else:
            condition = None
            condition_id = self.user.add_new_condition(user_id)
            if condition_id:
                condition = self.user.match_condition.get_by_id(condition_id)

        if condition:
            OHHOLog.print_log(condition.id)
            self.user.match_condition.update(condition,
                                             {"interest": primary_interest})
        return result
コード例 #2
0
    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)