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)
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)
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)
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'])
def tester_method(): email=request.form['email'] print(email) user=User.get_by_email(email) Database.update("users",{"email":email},{"printdata":"no"}) return "done"
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)
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)
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))
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)
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']})
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)
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)
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)
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)
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)
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.")
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)
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)
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)
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)
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)
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))
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))
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))
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')
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)
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))
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')
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)
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')
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))
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')
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)
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)
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))
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))
def eigth_question(): email = session['email'] username = User.get_by_email(email) return render_template('ques8.html', user = username.email, id = username.score_id)
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)