Example #1
0
def get_all_posts():
    user = User.get_by_email(session['email'])
    pulls = Pull.find_by_author_id(user.id)
    posts = []
    for pull in pulls:
        posts = posts + Post.from_mongo(pull._id)
    return render_template('all_posts.html', posts=posts)
Example #2
0
def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()
    return render_template("user_blogs.html", blogs=blogs, email=user.email)
Example #3
0
def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()
    return render_template('user_blogs.html', blogs=blogs, email=user.email)
Example #4
0
def user_blog(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()
    return render_template('user_blog.html', blogs=blogs, user_email = session['email'])
Example #5
0
File: app.py Project: hg0605/iprint
def tester_method():

    email=request.form['email']
    print(email)
    user=User.get_by_email(email)
    Database.update("users",{"email":email},{"printdata":"no"})
    return "done"
Example #6
0
def register_user():
    if request.method == 'GET':
        if session['email'] is None:
            return make_response(home_template())
        else:
            return make_response(start_pull())
    else:
        email = request.form['email']
        password = request.form['password']
        if not all([(re.match(
                r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email)),
                    (len(password) > 7)]):
            msg = "All users must have a valid email,\nand a password with a minimum of 8 characters."
            session['email'] = None
            return render_template('register.html', msg=msg)
        else:
            if Database.find_one("users", {"email": email}) is None:
                hash_pass = hashlib.sha256(password.encode()).hexdigest()
                # Get the user's credentials
                User.register(email, hash_pass)
                user = User.get_by_email(email)
                #scraping = Scraping()
                #scraping.save_to_mongo()
                # Register the user using the method in the User object. This sets the session email, and saves the user to Mongo.
                return make_response(start_pull())
            else:
                msg = """This email address is already in use. <a href="/login">Already have an account?</a>"""
                return render_template('register.html', msg=msg)
Example #7
0
def user_blogs(user_id=None):
    if user_id:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()

    return render_template('user_blogs.html', email=user.email, blogs=blogs)
Example #8
0
def register_user():
    email = request.form['email']
    password = request.form['password']

    User.register(email, password)
    user = User.get_by_email(email)

    return make_response(user_blogs(user._id))
Example #9
0
def refresh():
    posts = request.args.get('post')
    pull = request.args.get('pull')
    template = 'pulls.html'
    user = User.get_by_email(session['email'])
    pulls = Pull.find_by_author_id(user.id)
    ScheduledTasks.update_posts(pulls)
    return render_template(template, posts=posts, pull=pull, pulls=pulls)
Example #10
0
File: app.py Project: hg0605/iprint
def test_method():
    email=request.form['email']
    print(email)
    user=User.get_by_email(email)
    print (user.json())
    k=user.json()
    k['_id']=str(k['_id'])
    return jsonify({"status":k['printdata']})
Example #11
0
def author_blogs(author_id, ):
    user = User.get_by_id(author_id)
    user_email = User.get_by_email(session['email'])
    user_blogs = user_email.get_blogs()
    blogs = user.get_blogs()
    return render_template('user_author_blogs.html',
                           blogs=blogs,
                           user_blogs=user_blogs)
Example #12
0
File: app.py Project: anbax2000/RMI
def profileLanding():
    email = session['email']
    if email is not None:
        user = User.get_by_email(email)
        if user.designation == "Admin":
            return render_template('profile_admin.html', user=user)
        else:
            return render_template('profile.html', user=user)
Example #13
0
def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)  # find the user with submitted id
    else:
        user = User.get_by_email(session['email'])

    blogs = user.get_blogs()  # get user's blogs

    return render_template("user_blogs.html", blogs=blogs, email=user.email)
Example #14
0
def user_home(user=None):
    if session['email'] is not None:
        blogs = Database.find(collection='blogs', query=({}))
        user = User.get_by_email(session['email'])
        user_blogs = user.get_blogs()
        return render_template('user_home.html',
                               user=user,
                               blogs=blogs,
                               user_blogs=user_blogs)
Example #15
0
def user_blogs(user_id=None):
    """Show user's blogs on navigation to the blogs page"""
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()

    return render_template('user_blogs.html', blogs=blogs, email=user.email)
Example #16
0
def user_goals(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])

    goals = user.get_goal(user._id)

    return render_template("goals.html", goals=goals, email=user.email)
def main():
    Database.initialize()
    user = User.get_by_email('filonich.v@')

    user.new_post("8c3644e7aa2a490a9e0c36b8b7279737", "Racism",
                  "Racism is probably bad, yo know.")

    user.new_post("8c3644e7aa2a490a9e0c36b8b7279737", "Leninism",
                  "Leninism in probably good, yo know.")
Example #18
0
def user_blogs(user_id=None):
    """ Get the blog of a particular user """
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()

    return render_template("user_blogs.html", blogs=blogs, email=user.email)
Example #19
0
def register_user():
    name = request.form['name']
    email = request.form['email']
    password = request.form['password']

    User.register(name, email, password)
    user = User.get_by_email(email)

    return render_template("profile.html", name=user.name)
Example #20
0
File: app.py Project: kfnawaz/iahub
def process_listing(user_id=None):
    if user_id is not None:
        user =  User.get_by_user_id(user_id)
    else:
        user =  User.get_by_email(session['email'])

    processes = Process.get_all()

    return render_template("processes.html", processes=processes, email=user.email)
Example #21
0
def user_dailys(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])

    dailys = user.get_daily(user._id)

    return render_template("dailys.html", dailys=dailys, email=user.email)
Example #22
0
def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session["email"])
    blogs = user.get_blogs()

    return render_template("user_blogs.html",
                           blogs=blogs,
                           first_name=user.first_name)
Example #23
0
def create_new_post(blog_id):
    if request.method == 'GET':
        return render_template('new_post.html', blog_id=blog_id)
    else:
        title = request.form['title']
        content = request.form['content']
        user = User.get_by_email(session['email'])
        new_post = Post(blog_id, content, title, user.email)
        new_post.save_to_mongo()
        return make_response(blog_posts(blog_id))
Example #24
0
def create_new_blog():
    if request.method=='GET':
        return render_template('new_blog.html')
    else:
        title=request.form['title']
        description=request.form['description']
        user=User.get_by_email(session['email'])
        blog=Blog(user.email,title,description,user._id)
        blog.save_to_mongo()
        return make_response(user_blogs(user._id))
Example #25
0
def create_new_post(blog_id):
    if request.method=='GET':
        return render_template('new_post.html',blog_id=blog_id)
    else:
        title=request.form['title']
        content=request.form['content']
        user=User.get_by_email(session['email'])
        new_post=Post(blog_id,title,content,user.email)
        new_post.save_to_mongo()
        return make_response(blog_posts(blog_id))
Example #26
0
File: app.py Project: anbax2000/RMI
def render_roads_prop():
    email = session['email']
    if email is not None:
        user = User.get_by_email(email)
        if user.block == "ALL":
            return render_template('new_prop_add.html', block=user.block)
        else:
            return render_template('new_prop_add_block.html', block=user.block)
    else:
        return render_template('login_fail.html')
Example #27
0
def price_drops():
    user = User.get_by_email(session['email'])
    pulls = Pull.find_by_author_id(user.id)
    posts_list = []
    for pull in pulls:
        posts = Post.from_mongo(pull._id)
        for post in posts:
            if len(post.prices) > 1:
                posts_list.append(post)
    return render_template('price_drops.html', posts=posts_list)
Example #28
0
def create_new_blog():
    if request.method == 'GET':
        return render_template('new_blog.html')
    else:
        title = request.form['title']
        description = request.form['description']
        user = User.get_by_email(session.get('email'))
        user.new_blog(title, description)

        return make_response(user_blogs(user._id))
Example #29
0
def logout_user(user_id=None):
    """Logout the user"""
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])

    user.logout()

    render_template('logout.html')
Example #30
0
def starred_posts():
    user = User.get_by_email(session['email'])
    pulls = Pull.find_by_author_id(user.id)
    posts = []
    for pull in pulls:
        try:
            posts = posts + Post.get_starred_posts(pull._id)
        except TypeError:
            continue
    return render_template('starred_posts.html', posts=posts)
Example #31
0
def roads_para_update():
    email = session['email']
    if email is not None:
        user = User.get_by_email(email)
        if user.block == "ALL":
                return render_template('view_road_properties_all.html', block=user.block)
        else:
                return render_template('view_road_properties_block.html', block=user.block)
    else:
        return render_template('login_fail.html')
Example #32
0
def create_new_blog():
    if request.method == 'GET':
        return render_template('new_blog.html')
    else:
        title = request.form['title']
        description = request.form['description']
        user = User.get_by_email(session['email'])
        new_blog = Blog(user.email, title, description, user._id)
        new_blog.save_to_mongo()
        return make_response(user_blogs(user._id))
Example #33
0
def roads_img_list():
    email = session['email']
    if email is not None:
        user = User.get_by_email(email)
        if user.block == "ALL":
            return render_template('view_roads_image.html', block=user.block)
        else:
            return render_template('view_roads_image_block.html', block=user.block)
    else:
        return render_template('login_fail.html')
Example #34
0
def user_blogs(user_id=None):
    print "user_id is " + str(
        user_id) + "session[email] is: " + session['email']
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        print "Getting User class by session email!!!"
        user = User.get_by_email(session['email'])

    blogs = user.get_blogs()
    return render_template("user_blogs.html", blogs=blogs, email=user.email)
Example #35
0
def user_blogs_list(user_id=None):
    # Note: This breaks if a user is not logged in

    if user_id is None:
        user = User.get_by_email(session["email"])
    else:
        user = User.get_by_id(user_id)
    blogs = user.get_blogs() # A list of Blog objects
    email = user.email

    return render_template("user_blogs.html", blogs=blogs, email=email)
Example #36
0
def create_new_blog():
    #user came in directly from a url; so show them the create new from
    if request.method == 'GET':
        return render_template('new_blog.html')
    else:
        title= request.form['title']
        description= request.form['description']
        user = User.get_by_email(session['email'])

        new_blog=Blog(user.email, title, description, user._id)
        new_blog.save_to_mongo()
        #the below returns or calls user_blogs
        return make_response(user_blogs(user._id))
Example #37
0
def create_new_post(blog_id):
    #user came in directly from a url; so show them the create new from
    if request.method == 'GET':
        return render_template('new_post.html', blog_id=blog_id)
    else:
        title= request.form['title']
        content= request.form['content']
        user = User.get_by_email(session['email'])

        new_post = Post(blog_id, title, content, user.email)
        new_post.save_to_mongo()
        print(blog_id)
        #the below returns or calls user_blogs
        return make_response(blog_posts(blog_id))
Example #38
0
def eigth_question():
    email = session['email']
    username = User.get_by_email(email)
    return render_template('ques8.html', user = username.email, id = username.score_id)
Example #39
0
def get_all_scores(_id):
    email = session['email']
    username = User.get_by_email(email)
    scores = Score.get_from_mongo_score(_id)
    return render_template('score_list.html', scores = scores, user = username.email, id = username._id)