Exemple #1
0
def create_user(name, username, password, email, meta=None, receive_sms=False, receive_email=False):
    """Create a new user in the database"""
    # There will be one and only one user with a given username
    if User.query.filter_by(username=username, user_activation_key="").count():
        raise UserExists()
    if User.query.filter_by(username=username).count():
        raise UserExistsUnconfirmed()
    if User.query.filter_by(email=email).count():
        raise EmailAddressExists()

    # Creating an user instance and getting its id by commiting the
    # chage to the database
    print "CREATING USER", username, password
    activation_key = md5(username + password).hexdigest()
    user = User(
        name=name, username=username, password=password, email=email,
        receive_sms=receive_sms, receive_email=receive_email,
        user_activation_key=activation_key)
    dbsession.commit()

    # Time to save all meta attributes that we received
    for key, value in (meta or {}).items():
        user.set_meta(key, value)
    dbsession.commit()

    return user
Exemple #2
0
def convert_getComments(comments):
    """Converts the comments coming from wordpress API"""
    for comment in comments:
        link = url_for('post', pid=comment['post_id'])
        comment['link'] = '%s#coment-%s' % (link, comment['comment_id'])
        comment['user'] = User.get(comment['user_id'])
    return comments
Exemple #3
0
Fichier : wp.py Projet : calcwb/gd
def convert_getComments(comments):
    """Converts the comments coming from wordpress API"""
    for comment in comments:
        link = url_for('post', pid=comment['post_id'])
        comment['link'] = '%s#coment-%s' % (link, comment['comment_id'])
        comment['user'] = User.get(comment['user_id'])
    return comments