Ejemplo n.º 1
0
def check():

    uerror = userdb.checkUsername(request.form['username'])
    eerror = userdb.checkEmail(request.form['email'])
    perror = userdb.checkPhone(int(request.form['phone_no']))
    print(request.form['phone_no'], type(int(request.form['phone_no'])))
    print(uerror, eerror, perror)
    if userdb.getInfo(
            request.form['username']
    ) or uerror == False or eerror == False or perror == False:
        return render_template("register.html",
                               error=True,
                               uerror=uerror,
                               eerror=eerror,
                               perror=perror)
    else:
        file = request.files['input_file']
        filename = photos.save(file)
        pdb = db_connection.Picturesdb()
        pdb.insert_into(filename)
        id = pdb.get_picture_id(filename)[0][0]
        userdb.insertInto([
            request.form['username'], request.form['email'],
            request.form['name'], request.form['phone_no'],
            request.form['dob'], id, request.form['gender'], "",
            request.form['bio'], 0, request.form['password'],
            request.form['city'], "", request.form['link']
        ])
        return redirect(url_for('index'))
Ejemplo n.º 2
0
 def __init__(self, post_id, username):
     self.db = db_connection.Postsdb()
     pdb = db_connection.Picturesdb()
     self.post_id = post_id
     self.username = self.db.get_username(self.post_id)
     self.likes = self.db.get_likes_count(self.post_id)
     self.caption = self.db.get_caption(self.post_id)
     comment_id = self.db.get_comment_id(self.post_id)
     self.comment_id = [comment for (comment, ) in comment_id]
     print(self.comment_id)
     self.liked = self.db.if_liked(username, self.post_id)
     self.picture_id = self.db.get_picture_id(self.post_id)[0][0]
     print(self.picture_id)
     self.picture = Picture(self.picture_id)
Ejemplo n.º 3
0
def profile(username):
    selfUser.update()
    if username == selfUser.getUsername():
        User = selfUser
    else:
        User = user_demo.user_demo(username)
    ids = User.get_post_ids()
    posts = []
    picture_id = User.get_picture_id()
    picture = ""
    if picture_id == 0:
        picture = 'avatar.png'
    else:
        db = db_connection.Picturesdb()
        picture = db.get_picture(picture_id)[0][0]
    print(picture)
    for id in ids:
        post = user_demo.Post(id, User.getUsername())
        posts.append(post.get_info())
        print(User.check_stories())
    return render_template("profile.html",
                           user="******",
                           info=[
                               User.getName(),
                               User.getUsername(),
                               User.getLocation(),
                               User.getFollowing(),
                               User.getFollower(),
                               User.getLink(),
                               User.getBio(),
                               User.getUsername() != selfUser.getUsername(),
                               selfUser.check_if_following(User.getUsername()),
                               User.check_stories(), picture
                           ],
                           posts=posts,
                           username=selfUser.getUsername())
Ejemplo n.º 4
0
 def set_picture(self, picture):
     db = db_connection.Picturesdb()
     db.insert_into(picture)
     id = db.get_picture_id(picture)[0][0]
     self.db.updatePicture_id(id, self.username)
     self.picture_id = id
Ejemplo n.º 5
0
 def __init__(self, picture_id):
     self.picture_id = picture_id
     self.db = db_connection.Picturesdb()
     self.picture = self.db.get_picture(self.picture_id)
     self.date = self.db.get_datee(self.picture_id)
     self.time = self.db.get_time(self.picture_id)