예제 #1
0
    def add(username, text, created_at):
        """
        Add a tweet to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        user_node = user_idx['username'][username].single
        if not user_node:
            return False, 'User not found!'
        if text:
            with db.transaction:
                tweet_node = db.node()
                tweet_node['text'] = text
                tweet_node['created_at'] = created_at
                tweet_node.SEND(user_node)
                tid = tweet_ref['tot_tweet']
                tweet_node['tid'] = tid
                tweet_ref['tot_tweet'] = tweet_ref['tot_tweet'] + 1
                tweet_idx['tid'][tid] = tweet_node
            return True, ''
        else:
            return False, 'Tweet should not be empty!'
예제 #2
0
    def add(username, password, password_confirm, invitation):
        """
        Add a user to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        if not username or not password or not password_confirm:
            return False, 'The username/password should not be empty!'
        if password != password_confirm:
            return False, 'The password you input twice is not the same!'
        if invitation != INVITATION_CODE:
            return False, 'The invitation code is invalid!'
        user_node = user_idx['username'][username].single
        if user_node:
            return False, 'The username %s has been used!' % username
        with db.transaction:
            user_node = db.node()
            user_node['name'] = username
            user_node['username'] = username
            user_node['password'] = password
            user_node['gender'] = ''
            user_node['hometown'] = ''
            user_idx['username'][username] = user_node
        user = User.get(username)
        return True, user
예제 #3
0
파일: model.py 프로젝트: huxuan/pyneo4jet
    def add(username, password, password_confirm, invitation):
        """
        Add a user to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        if not username or not password or not password_confirm:
            return False, 'The username/password should not be empty!'
        if password != password_confirm:
            return False, 'The password you input twice is not the same!'
        if invitation != INVITATION_CODE:
            return False, 'The invitation code is invalid!'
        user_node = user_idx['username'][username].single
        if user_node:
            return False, 'The username %s has been used!' % username
        with db.transaction:
            user_node = db.node()
            user_node['name'] = username
            user_node['username'] = username
            user_node['password'] = password
            user_node['gender'] = ''
            user_node['hometown'] = ''
            user_idx['username'][username] = user_node
        user = User.get(username)
        return True, user
예제 #4
0
파일: model.py 프로젝트: huxuan/pyneo4jet
    def add(username, text, created_at):
        """
        Add a tweet to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        user_node = user_idx['username'][username].single
        if not user_node:
            return False, 'User not found!'
        if text:
            with db.transaction:
                tweet_node = db.node()
                tweet_node['text'] = text
                tweet_node['created_at'] = created_at
                tweet_node.SEND(user_node)
                tid = tweet_ref['tot_tweet']
                tweet_node['tid'] = tid
                tweet_ref['tot_tweet'] = tweet_ref['tot_tweet'] + 1
                tweet_idx['tid'][tid] = tweet_node
            return True, ''
        else:
            return False, 'Tweet should not be empty!'
예제 #5
0
파일: model.py 프로젝트: no4j/pyneo4jet
    def add(username, password, password_confirm, invitation):
        """
        Add a user to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        if not username:
            return False, "The username should not be empty!"
        if not password:
            return False, "The password should not be empty!"
        if not password_confirm:
            return False, "The password for confirmation should not be empty!"
        if password != password_confirm:
            return False, "The password you input twice is not the same!"
        if invitation != INVITATION_CODE:
            return False, "The invitation code is invalid!"
        user_node = user_idx["username"][username].single
        if user_node:
            return False, "The username %s has been used!" % username
        user = User(username, password)
        with db.transaction:
            user_node = db.node()
            user_node["username"] = user.username
            user_node["password"] = user.password
            user_node["avatar"] = user.avatar
            user_idx["username"][username] = user_node
        return True, ""
예제 #6
0
파일: model.py 프로젝트: no4j/pyneo4jet
    def add(username, text, created_at):
        """
        Add a tweet to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        # NOTE(huxuan): If tid is needed we should manually generate it
        if text:
            with db.transaction:
                tweet_node = db.node()
                tweet_node["username"] = username
                tweet_node["text"] = text
                tweet_node["created_at"] = created_at
                user_node = user_idx["username"][username].single
                tweet_node.SEND(user_node)
            return True, ""
        else:
            return False, "Tweet should not be empty!"
예제 #7
0
    def add(username, text, created_at):
        """
        Add a tweet to neo4j database

        :rtype: true or false indicates the result of add action

        Note:
            Before add there needs a check!
        """
        # NOTE(huxuan): If tid is needed we should manually generate it
        if text:
            with db.transaction:
                tweet_node = db.node()
                tweet_node['username'] = username
                tweet_node['text'] = text
                tweet_node['created_at'] = created_at
                user_node = user_idx['username'][username].single
                tweet_node.SEND(user_node)
            return True, ''
        else:
            return False, 'Tweet should not be empty!'