def makeSysAdmin():
    first = "Sys"
    last = "Admin"
    uid = "0"
    email = "*****@*****.**"

    u = UserModel(uid, first, last, email, "default", "admin")
    u.admin = True
    u.authenticated = True
    db.session.add(u)

    n1 = NodeModel("001", "http://secret-inlet-51780.herokuapp.com/api/", "remoteuser", "abc")
    n1.method = "basic"
    nodeauth1 = AuthModel("http://secret-inlet-51780.herokuapp.com/api/")

    n2 = NodeModel("002", "http://project-c404.rhcloud.com/api/", "node2", "asdfasdf")
    n2.method = "basic"
    nodeauth2 = AuthModel("http://project-c404.rhcloud.com/api/")

    nodeauth3 = AuthModel("https://blooming-earth-94594.herokuapp.com/api/")

    db.session.add(n1)
    db.session.add(n2)
    db.session.add(nodeauth1)
    db.session.add(nodeauth2)
    db.session.add(nodeauth3)

    db.session.commit()
    print("SysAdmin Created email:"+email+" password: default uid: 0")

    print("is admin:", u.admin)
    print("is authenticated:", u.authenticated)
def makeSysAdmin():
    first = "Sys"
    last = "Admin"
    uid = "0"
    print(uid)
    email = "*****@*****.**"

    u = UserModel(uid, first, last, email, "default", "admin")
    u.authenticated = True
    u.admin = True

    db.session.add(u)

    db.session.commit()
Example #3
0
 def register(self):
     headline("Pendaftaran Pelanggan")
     first_name = input("Masukkan nama depan: ")
     last_name = input("Masukkan nama belakang: ")
     username = input("Masukkan username: "******"Masukkan password: "******"Masukkan email: ")
     phone = input("Masukkan phone: ")
     address = input("Masukkan address: ")
     gender = input("Masukkan gender (L/P): ")
     try:
         UserModel().add_user(
             first_name=first_name,
             last_name=last_name,
             username=username,
             password=password,
             email=email,
             phone=phone,
             address=address,
             gender=gender,
             is_admin=0,
         )
     except Exception as err:
         return print(err)
     input("Berhasil daftar, Tekan Enter login.")
     self.login()
Example #4
0
def login():
    login_form = LoginForm()

    context = {'login_form': login_form}

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        user_doc = get_user(user_id=username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']

            if check_password_hash(password_from_db, password):
                user_Data = UserData(username, password)
                user = UserModel(user_Data)

                login_user(user)

                return redirect(url_for("hello"))
            else:
                flash("La información no coincide")

        else:
            flash("Usuario no existe")

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #5
0
def login():
    login_form = Login_Form()
    context = {'login_form': login_form}

    if request.method == 'POST':
        username = login_form.username.data
        password = login_form.password.data
        user_doc = get_user(username)

        if user_doc.to_dict():
            if check_password_hash(user_doc.to_dict()['password'], password):
                email = user_doc.to_dict()['email']
                user_data = UserData(username, password, email)
                user = UserModel(user_data)

                login_user(user)
                flash('Welcome again!', 'success')
                redirect(url_for('hello'))
            else:
                flash('Username or password is incorrect', 'danger')
        else:
            flash('Username not found', 'danger')

        return redirect(url_for('hello'))

    return render_template('auth/login.html', **context)
Example #6
0
def login():
    login_form = LoginForm()
    context = {'login_form': login_form}

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        user_doc = get_user(username)

        if user_doc.to_dict() is not None:

            if check_password_hash(user_doc.to_dict()['password'], password):
                user_data = UserData(username, password)
                user = UserModel(user_data)

                login_user(user)

                flash('Bienvenido de Nuevo')

                redirect(url_for('hello'))
            else:
                flash('La informacion no coincide')
        else:
            flash('El usuario no existe')

        # flash('Nombre de usuario registrado con éxito')

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #7
0
def login():
    login_form = LoginForm()
    context = {'login_form': login_form}

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data
        user_doc = get_user(username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']

            if check_password_hash(password_from_db, password):
                user_data = UserData(username, password)
                user = UserModel(user_data)
                login_user(user)
                flash('Welcome Back')
                redirect(url_for('hello'))
            else:
                flash('Data does not match')
        else:
            flash('User does not exist')

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #8
0
def login():
    """Login view"""

    login_form = LoginForm()

    context = {
        'login_form': login_form
    }

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data
        user_doc = get_user(username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']
            if password_from_db == password:
                user_data = UserData(username, password)
                user = UserModel(user_data)

                login_user(user)
                flash('Welcome aboard')
                redirect(url_for('hello'))
            else:
                flash('password incorrect')
        else:
            flash('User does not exist!')
        return redirect(url_for('index'))
    return render_template('login.html', **context)
Example #9
0
def signup():
    signup_form = SignupForm()

    if signup_form.validate_on_submit():
        email = signup_form.email.data
        password = signup_form.password.data

        user_doc = get_user(email).to_dict()
        if user_doc is None:
            password_hash = generate_password_hash(password)
            user_data = UserData(email, password_hash)

            user_put(user_data)

            user = UserModel(user_data)
            login_user(user)

            flash('Welcome to our app', 'success')

            return redirect(url_for('panel'))
        else:
            signup_form.email.errors.append('User already exists')

    context = {
        'signup_form': signup_form,
    }

    return render_template('signup.html', **context)
Example #10
0
def login():
    login_form = LoginForm()

    if login_form.validate_on_submit():
        email = login_form.email.data
        password = login_form.password.data

        user_doc = get_user(email).to_dict()
        if user_doc is not None:
            if check_password_hash(user_doc['password'], password):
                user_data = UserData(email, password)
                user = UserModel(user_data)

                login_user(user)

                flash('Login successful', 'success')

                return redirect(url_for('index'))
            else:
                login_form.email.errors.append('Invalid Username/password')
        else:
            login_form.email.errors.append('User not found')

    context = {
        'login_form': login_form,
    }

    return render_template('login.html', **context)
Example #11
0
def signup():
    signup_form = LoginForm()
    context = {
        'signup_form': signup_form,
    }

    if signup_form.validate_on_submit():
        username = signup_form.username.data
        password = signup_form.password.data

        user_doc = get_user(username)

        if user_doc.to_dict() is None:
            password_hash = generate_password_hash(password)

            user_data = UserData(username, password_hash)

            # create user in the data base
            create_user(user_data)

            # login user in the app
            user = UserModel(user_data)
            login_user(user)

            flash('Welcome')

            return redirect(url_for('hello'))
        else:
            flash('This user already exists')

    return render_template('signup.html', **context)
Example #12
0
def signup():
    signup_form = LoginForm()

    context = {'signup_form': signup_form}

    #POST: buscamos al usuario si es que existe, ya es usuario, si no, lo creamos
    if signup_form.validate_on_submit():
        username = signup_form.username.data
        password = signup_form.password.data

        #vamos a buscar ese usuario en nuestra BD
        user_doc = get_user(username)
        if user_doc.to_dict() is None:
            #generamos un password hash del password que nos envia el usuario
            password_hash = generate_password_hash(password)
            #creamos una nueva instancia de user_data
            user_data = UserData(username, password_hash)

            #creamos una funcion desde firestore_service para que persista el dato del usuario
            user_put(user_data)
            #ya que creamos un nuevo usuario en la base de datos, creamos un usermodel para poder logearlo en la sesion
            user = UserModel(user_data)
            login_user(user)
            flash('Bienvenido')

            return redirect(url_for('hello'))

        else:
            flash('El usuario ya existe')
    return render_template('signup.html', **context)
Example #13
0
def app_client(sample_app: Flask):

    with sample_app.test_request_context():

        sample_app.db.create_all()
        session = sample_app.db.session

        for user in populate_users:
            new_user = UserModel(
                nickname=user["nickname"],
                first_name=user["first_name"],
                last_name=user["last_name"],
                email=user["email"],
                password=user["password"],
                biography=user["biography"],
            )

            session.add(new_user)
            session.commit()

        session.close()

    yield sample_app.test_client()

    with sample_app.test_request_context():
        all_users = session.query(UserModel).paginate().items

        for user in all_users:
            session.delete(user)
            session.commit()

        session.close()
        sample_app.db.drop_all()
Example #14
0
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('username',
                            type=str,
                            required=True,
                            help="Username field is required")
        parser.add_argument('password',
                            type=str,
                            required=True,
                            help="Password field is required")
        args = parser.parse_args()

        # Get user
        user = UserModel.find_by_username(args["username"])
        if not user:
            return {"errors": {"username": "******"}}, 400

        # Check password
        if not user.check_password(args["password"]):
            return {"errors": {"password": "******"}}, 400

        # Create token
        access_token = create_access_token(identity=user.id,
                                           expires_delta=False,
                                           fresh=True)
        return {
            'access_token': access_token,
            'user': {
                'username': user.username,
                'email': user.email,
                'item_view': user.item_view.value,
            }
        }, 200
Example #15
0
def signup():
    signup_form = loginForm()
    context = {
        'signup_form': signup_form,
    }

    if signup_form.validate_on_submit():
        username = signup_form.username.data
        password = signup_form.password.data
        print(signup_form.submit.data)

        user_document = get_user(username)

        if user_document.to_dict() is None:
            password_hash = generate_password_hash(password)
            #password_db = user_document.to_dict().get('password')
            user_data = UserData(username, password_hash)
            put_user(user_data)
            user_model = UserModel(user_data)
            login_user(user_model)

            flash('Bienvenido !!!')
            redirect((url_for('hello')))
        else:
            flash('El usuario ya existe !')

        #session['username'] = username
        #flash('Registro exitoso')

        return redirect(url_for('index'))

    return render_template('signup.html', **context)
Example #16
0
def signup():
    sign_form = loginForm()
    context = {
        'form': sign_form
    }

    if sign_form.validate_on_submit():
        username = sign_form.username.data
        password = sign_form.password.data

        user_doc = get_user_by_id(username)

        if user_doc.to_dict() is None:
            pass_hash = generate_password_hash(password)
            user_data = UserData(username, pass_hash)
            insert_user(user_data)

            user = UserModel(user_data)
            login_user(user)

            flash('Usuario creado correctamente', 'success')
            return redirect(url_for('hello'))
        else:
            flash('El usuario ya existe', 'warning')

    return render_template('signup.html', **context)
Example #17
0
    def post(self):
        current_app.logger.info(f'Received POST on users')

        gov_id = request.form.get('gov_id')
        first_name = request.form.get('first_name')
        last_name = request.form.get('last_name')
        email = request.form.get('email')
        ethereum_id = request.form.get('ethereum_id')
        password = request.form.get('password')
        role_id = request.form.get('role_id')

        user = UserModel(gov_id=gov_id,
                         first_name=first_name,
                         last_name=last_name,
                         email=email,
                         ethereum_id=ethereum_id,
                         password=password,
                         role_id=role_id)

        try:
            db.session.add(user)
            db.session.commit()
        except exc.IntegrityError as e:
            current_app.logger.error(e.orig)
            db.session.rollback()
            return dict(
                error=f'There was an error creating the user:{e.orig}'), 400

        return dict(user=user.to_dict()), 201
Example #18
0
def signup():
    signup_form = LoginForm()
    context = {'signup_form': signup_form}

    if signup_form.validate_on_submit():
        username = signup_form.username.data
        password = signup_form.password.data

        user_doc = get_user(username)

        if user_doc.to_dict() is None:
            password_hash = generate_password_hash(password)
            user_data = UserData(username, password_hash)
            user_put(user_data)

            user = UserModel(user_data)

            login_user(user)

            flash('Bienvenido!')

            return redirect(url_for('hello'))

        else:
            flash('El usuario existe!')

    return render_template('signup.html', **context)
Example #19
0
def login():
    login_form = loginForm()
    context = {
        'form': login_form
    }

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        user_doc = get_user_by_id(username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']
            if check_password_hash(password_from_db, password):
                user_data = UserData(username, password)
                user = UserModel(user_data)
                login_user(user)
                flash('Bienvenido de nuevo', 'success')
                redirect(url_for('hello'))
            else:
                flash('Usuario y/o contrasena incorrectos', 'warning')
        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #20
0
def login():

    form = Login()


    if current_user.is_authenticated:
        return redirect(url_for('home'))

    if form.validate_on_submit():

        email = form.email.data 
        password = form.password.data    

        user_doc = get_user(email)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']
            if check_password_hash(password_from_db, password):

                user_data = UserData(user_doc.to_dict()['name'], email, password)
                
                user = UserModel(user_data)

                login_user(user)

                flash(u'Bienvenido de nuevo!', 'success')
                return redirect(url_for('home'))
            else:
                flash('Información no validad', 'error')
        else:
            flash('El usuario no existe!', 'error')
        
        return redirect(url_for('auth.login'))

    return render_template('login.html', form=form)
Example #21
0
def login():
    login_form = LoginForm()
    context = {'login_form': login_form}

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        user_doc = get_user(username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']

            if password == password_from_db:
                user_data = UserData(username, password)
                user = UserModel(user_data)

                login_user(user)

                flash('Bienvenido de nuevo')
                redirect(url_for('hello'))

            else:
                flash('La información no coincide')

        else:
            flash('El usuario no existe')

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #22
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    login_form = LoginForm()
    context = {
        'login_form': login_form,
    }
    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data
        user_doc = get_user(username)
        if user_doc.to_dict() is not None:
            db_password = user_doc.to_dict()['password']
            if check_password_hash(db_password, password):
                user_data = UserData(username, password)
                user_model = UserModel(user_data)
                login_user(user_model)
                flash(f'Login Correcto!!!', 'success')
                return redirect(url_for('hello'))
            else:
                flash(f'La informacion no coincide!!!', 'danger')
        else:
            flash(f'Usuario no encontrado!!!', 'danger')
        return redirect(url_for('index'))
    return render_template('login.html', **context)
Example #23
0
def login():
    login_form = LoginForm()
    context = {'login_form': login_form}

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        user_doc = get_user(username)

        if user_doc[0] is not None:
            password_from_db = user_doc[1]

            if password == password_from_db:
                user_data = UserData(username, password)
                user = UserModel(user_data)
                login_user(user)
                flash('Welcome again')
                redirect(url_for('hello'))
            else:
                flash('The information dont match')
        else:
            flash('The user doesnt exists')

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #24
0
    def post():
        body = get_user_info()
        if UserModel.query.filter_by(username=body.username).first():
            return response(status_code=status.HTTP_409_CONFLICT,
                            message='User with this name already exists')

        user = UserModel(name=body.username, password=body.password)
        db.session.add(user)
        db.session.commit()

        data = user.as_dict()
        data[TOKEN] = encode_token(user.as_dict())

        return response(status_code=status.HTTP_200_OK,
                        data=data,
                        message='Successfully registered')
Example #25
0
def login():
    login_form = LoginForm()
    context = {
        'login_form': LoginForm(),
    }

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data

        # Get user from database
        user_doc = get_user(username)

        if user_doc.to_dict() is not None:
            # Getting password from DB
            password_from_db = user_doc.to_dict()['password']

            # Check is password is correct
            if check_password_hash(password_from_db, password):
                user_data = UserData(username, password)
                user = UserModel(user_data)

                login_user(user)

                flash('Welcome back')

                redirect(url_for('hello'))
            else:  # wrong password
                flash('Wrong password')
        else:  # User not found
            flash('User doesn\'t exists')

        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #26
0
def login():
    #Para mandar un submit, hay que agregarlo al contexto
    login_form = LoginForm()
    # La funcion debe retornar 200 y la app debe tener incluido el Blueprint
    context = {'login_form': LoginForm()}

    if login_form.validate_on_submit():
        #validemos que el usuario esta en la base de datos
        #Si la forma es valida, obtenemos el username y password
        username = login_form.username.data  #es ua instancia de StringField
        password = login_form.password.data

        user_doc = get_user(username)

        if user_doc.to_dict() is not None:
            password_from_db = user_doc.to_dict()['password']

            if password == password_from_db:
                user_data = UserData(username, password)
                user = UserModel(user_data)

                login_user(user)

                flash('Bienvenido de nuevo')

                redirect(url_for('hello'))
            else:
                flash('La información no coincide')
        else:
            flash('El usuario no existe')
        #como ya obtenemos el username, lo guardamos en la sesion
        #para desplegar el username
        return redirect(url_for('index'))
    return render_template('login.html',
                           **context)  # se envia el contexto expandido
Example #27
0
def login():
    login_form = LoginForm()
    context = {
        'login_form': login_form
    }

    if login_form.validate_on_submit():
        username = login_form.username.data
        password = login_form.password.data
        user_doc = get_user(username)
        
        
        if user_doc.to_dict() is not None:
            #password_from_db = user_doc.to_dict()['password']

            if check_password_hash(user_doc.to_dict()['password'], password):
                user_data = UserData(username, password)
                user = UserModel(user_data)
                print(f'-user: {user}')
                status=login_user(user)
               
                redirect(url_for('hello'))
            else:
                flash('La información no coincide')
        else:
          flash('El usario no existe')
        return redirect(url_for('index'))

    return render_template('login.html', **context)
Example #28
0
def register(username,password):
    user = UserHandler.find_by_username(username)
    if user is None:
        newUser = UserModel(username, password)
        UserHandler.save_to_db(newUser)
        login_user(newUser, remember=True)
        return True
    raise UserExists
Example #29
0
def deploy():
    db.drop_all()
    db.create_all()

    try:
        RoleModel.insert_roles()
        r = RoleModel.query.filter_by(role_name='管理员').first()
        u = UserModel()
        u.user_name = 'admin'
        u.nick_name = 'admin'
        u.password = '******'
        u.role = r
        db.session.add(u)
        db.session.commit()
    except Exception, e:
        print e
        db.session.rollback()
Example #30
0
    def test_create_category(self):
        user = UserModel(username='******', password='******')

        category = CategoryModel(name='categoryname', user=user)

        self.assertEqual(
            category.name, 'categoryname',
            "The name of the category after creation in wrong!!.")
Example #31
0
 def validate_password(form, field):
     user = UserModel().get_by_username(form.username.data) 
     if user is None:
         raise ValidationError("auth error")
     entry_password = get_password_hash(settings.SECRET_KEY, user.username, field.data)
     if entry_password != user.password:
         raise ValidationError("auth error")
     form.user = user
Example #32
0
    def test_category_relationship(self):

        user = UserModel(username="******",
                         password="******",
                         email="*****@*****.**")
        user.save_to_db()

        category = CategoryModel(name='test_category', user=user)
        recipe = RecipeModel(name='test_recipe',
                             description='Add stuff',
                             user=user,
                             category=category)

        category.save_to_db()
        recipe.save_to_db()

        self.assertEqual(recipe.category.name, 'test_category')
Example #33
0
 def put(self, email):
     data = User.req.parse_args()
     user = UserModel.get_by_email(email)
     if not user:
         user = UserModel(email, data['name'])
         user.save_to_db()
         return {'massage': f'user with email {email} created'}
     user.name = data['name']
     user.save_to_db()
     return {'massage': f'user name is changed'}, 200
Example #34
0
def verify_token(token):
    # first try to authenticate by token
    nodeauth = AuthModel.query.filter_by(token=token).first()
    if nodeauth:
        g.user = None
        return True
    user = UserModel.verifyToken(token)
    if not user:
        return False
    g.user = user
    return True
Example #35
0
def genRandUsers(number):
    for i in range(number):
        first = random.choice(data["first"])
        last = random.choice(data["last"])
        uid = str(int(hashlib.sha224( first + str(datetime.utcnow())).hexdigest(),16))[:6]
        print(uid)
        email = first+"."+last+"@example.com"
        print(email)
        img = random.choice(IMAGES)
        visibility = random.choice(["PUBLIC","PRIVATE", "FOAF", "FRIENDS"])
        title = random.choice([first+"'s post","NEW post", last+"'s Fave text", "Lorem Ipsum"])
        description = random.choice(["Lorem Ipsum", "Sequire Non Descrir", "Latin"])
        content = random.choice(lorem)

        # make a user
        u = UserModel(uid, first, last, email, "default", "abramhindle")

        # make a post
        pid = str(int(hashlib.sha224( uid + str(datetime.utcnow())).hexdigest(),16))[:6]
        p = PostModel(pid, uid, title, description,content, ["Lorem Ipsum", "Old Ye Engrish"], "text/plain", visibility,"")

        # make a comment
        cid = str(int(hashlib.sha224( pid + str(datetime.utcnow())).hexdigest(),16))[:6]
        c = CommentModel(cid, uid, pid, "hahah lol")

        # make a picture
        iid = str(int(hashlib.sha224( cid + str(datetime.utcnow())).hexdigest(),16))[:6]
        i = ImageModel(iid, uid, img, "user1.jpg")
        u.propic = i.iid

        db.session.add(u)
        db.session.add(p)
        db.session.add(c)

        db.session.commit()

        db.session.add(i)
        db.session.commit()
Example #36
0
 def on_model_change(self, form, model):
     if len(model.password2):
         model.password = UserModel.generate_password(form.password2.data)
     elif not model.password:
         model.password = UserModel.generate_password('12345678')
Example #37
0
def coach():
    role = RoleModel.objects(name="coach").first()
    users = UserModel.objects(roles=role).all()
    return render_template("coach.html", users=users)
Example #38
0
def getPublicPosts(host):
	r = requests.get(host.rstrip("/")+"/posts")
	data = r.json()

	if data:
		# list to return ids of
		post_ids = []

		for post in data["posts"]:
			author = post["author"]

			# need to get authors from cache / remote
			u = api.getUser(author["id"][:25])
			if not u:
				author = getForeignAuthor(host, author["id"])

				first = author["displayName"].split(" ")[0]
				last = author["displayName"].split(" ")[-1]
				uid = author["id"][:25]
				email = author["email"]
				if "github_username" in author.keys():
					gitId = author["github_username"]
				else:
					gitId = "abramhindle"
				u = UserModel(uid, first, last, email, "default", gitId)

				u.origin = host

				db.session.add(u)

			pid = post["id"][:25]

			post_ids.append(pid)

			title = post["title"]
			if "description" in post.keys():
				description = post["description"]
			else:
				description = "description"
			text = post["content"]

			if "categories" in post.keys():
				categories = post["categories"]
			else:
				categories = ["categories"]

			# new model obj init
			p = PostModel(pid, uid, title, description, text, categories, "PUBLIC")

			if "contentType" in post.keys():
				p.contentType = post["contentType"]
			if "published" in post.keys():
				p.datetime = post["published"]
			p.origin = post["origin"]

			# get comments from posts
			for comment in post["comments"]:
				# need to get authors from cache / remote
				if "author" in comment.keys():
					author = api.getUser(comment["author"]["id"][:25])

				elif "local_author" in comment.keys():
					author = api.getUser(comment["local_author"]["id"][:25])

				elif "remote_author_name" in comment.keys():
					author = api.getUser(comment["remote_author_name"]["id"][:25])

				if not author:
					author = getForeignAuthor(host, author["id"])

					first = author["displayName"].split(" ")[0]
					last = author["displayName"].split(" ")[-1]
					uid = author["id"][:25]
					email = author["email"]
					gitId = author["github_username"]
					u = UserModel(uid, first, last, email, "default", gitId)
					db.session.add(u)

				cid = comment["id"]
				text = comment["comment"]

				c = CommentModel(cid, u.uid, p.pid, text)

				c.contentType = comment["contentType"]
				c.datetime = comment["published"]

				db.session.add(c)

		#db.session.commit()
		return post_ids

	else:
		return []
Example #39
0
 def load_user(id):
     return UserModel.objects(id=id).first()