def frontpage_top(): """ Returns index page and most voted/commented posts :return: """ subform = SubscribeForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() voteform = VoteForm() subid = 0 navlink = 5 currentbtcprice = db.session.query(BtcPrices).get(1) currentxmrprice = db.session.query(MoneroPrices).get(1) currentbchprice = db.session.query(BchPrices).get(1) currentltcprice = db.session.query(LtcPrices).get(1) # see if user leveled up and has a display to flash seeiflevelup = db.session.query(DisplayCoins).filter( DisplayCoins.user_id == current_user.id).all() if seeiflevelup is not None: for levelup in seeiflevelup: flash("You have leveled up to level: " + str(levelup.new_user_level), category='success') flash("Your have recieved 2 new coins", category='success') db.session.delete(levelup) db.session.commit() # Trending subforums trending = db.session.query(SubForums).order_by( SubForums.total_exp_subcommon.desc()).limit(10) # get unread messages if current_user.is_authenticated: thenotes = db.session.query(Notifications) thenotes = thenotes.filter(Notifications.user_id == current_user.id) thenotes = thenotes.order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0) thenotescount = thenotescount.count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 recmsgs = db.session.query(Messages) recmsgs = recmsgs.filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) recmsgs = recmsgs.count() sendmsgs = db.session.query(Messages) sendmsgs = sendmsgs.filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) sendmsgs = sendmsgs.count() themsgs = int(sendmsgs) + int(recmsgs) # getsubs user belongs too and add to list usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join( SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(current_user.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.room_deleted != 1) usersubforums = usersubforums.order_by((SubForums.id == 31).desc(), SubForums.subcommon_name) usersubforums = usersubforums.all() seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session.query(SubForums) seeifownering = seeifownering.filter( SubForums.creator_user_id == current_user.id) seeifownering = seeifownering.filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() mainpostform = MainPostForm( CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 userbusiness = db.session.query(Business) userbusiness = userbusiness.filter(Business.user_id == current_user.id) userbusinesses = userbusiness.all() userbusinessescount = userbusiness.count() bizfollowing = db.session.query(BusinessFollowers) bizfollowing = bizfollowing.join( Business, (BusinessFollowers.business_id == Business.id)) bizfollowing = bizfollowing.filter( current_user.id == BusinessFollowers.user_id) bizfollowing = bizfollowing.all() # list of subs user belongs too usersublist = [] for usersub in usersubforums: usersublist.append(usersub.subcommon_id) # query latest rooms new_rooms = db.session.query(SubForums) \ .filter(SubForums.id.notin_(usersublist), SubForums.room_deleted == 0, SubForums.room_suspended == 0, SubForums.room_banned == 0, SubForums.id != 1, SubForums.id != 14 ) \ .order_by(SubForums.created.desc()).limit(6) # query random rooms random_rooms = db.session.query(SubForums).filter( SubForums.id.notin_(usersublist), SubForums.room_deleted == 0, SubForums.room_suspended == 0, SubForums.room_banned == 0, SubForums.id != 1, SubForums.id != 14 ) \ .order_by(func.random()) \ .limit(6) # POSTS sub queries page = request.args.get('page', 1, type=int) posts = db.session.query(CommonsPost) posts = posts.filter(CommonsPost.subcommon_id.in_(usersublist)) posts = posts.filter(CommonsPost.subcommon_id != 1) posts = posts.filter(CommonsPost.hidden == 0) posts = posts.filter( or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) posts = posts.order_by(CommonsPost.highest_exp_reached.desc()) posts = posts.paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('frontpage.frontpage_mostactive', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('frontpage.frontpage_mostactive', page=posts.prev_num) \ if posts.has_prev else None return render_template( 'frontpage.html', now=datetime.utcnow(), currentbtcprice=currentbtcprice, currentxmrprice=currentxmrprice, currentbchprice=currentbchprice, currentltcprice=currentltcprice, # forms mainpostform=mainpostform, voteform=voteform, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, subform=subform, themsgs=themsgs, usersubforums=usersubforums, userbusinesses=userbusinesses, userbusinessescount=userbusinessescount, bizfollowing=bizfollowing, # general new_rooms=new_rooms, thenotescount=thenotescount, random_rooms=random_rooms, seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, thenotes=thenotes, subid=subid, navlink=navlink, # queries/pagination trending=trending, posts=posts.items, next_url=next_url, prev_url=prev_url, )
def main(user_name): # forms friendform = FriendForm() deleteposttextform = DeletePostTextForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() navlink = 1 wall_post_form = MainPostForm( CombinedMultiDict((request.files, request.form))) if user_name == 'A_Bot': user_name = "answer.cash" theuser = db.session\ .query(User)\ .filter(User.user_name == user_name)\ .first() if theuser is None: flash('User does not exist', category='warning') return redirect( url_for('profile.main', user_name=current_user.user_name)) if current_user.is_authenticated: # see if blocked isuserblocked = db.session\ .query(BlockedUser)\ .filter(BlockedUser.user_id == theuser.id, BlockedUser.blocked_user == current_user.id)\ .first() if isuserblocked: flash('User does not exist', category='warning') return redirect(url_for('index')) usersubforums = db.session\ .query(Subscribed)\ .join(SubForums, (Subscribed.subcommon_id == SubForums.id))\ .filter(theuser.id == Subscribed.user_id)\ .filter(SubForums.room_deleted != 1)\ .filter(SubForums.room_suspended != 1)\ .filter(SubForums.room_banned != 1)\ .all() guestsubforums = None seeifmodding = db.session.query(Mods)\ .filter(Mods.user_id == theuser.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session\ .query(SubForums)\ .filter(SubForums.creator_user_id == theuser.id)\ .filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() # get followers get_followers = db.session\ .query(User)\ .join(Followers, (User.id == Followers.followed_id))\ .filter(Followers.follower_id == theuser.id)\ .limit(9) # get users posts userposts = db.session\ .query(CommonsPost)\ .filter(theuser.id == CommonsPost.user_id)\ .filter(CommonsPost.hidden == 0)\ .filter(CommonsPost.muted == 0)\ .order_by(CommonsPost.created.desc()) posts = userposts.limit(50) postcount = userposts.count() follower_count = db.session\ .query(Followers)\ .filter(Followers.follower_id == theuser.id)\ .count() followed_count = db.session\ .query(Followers)\ .filter(Followers.followed_id == theuser.id)\ .count() expcount = db.session\ .query(ExpTable)\ .filter(ExpTable.user_id == theuser.id)\ .count() userexp = db.session\ .query(ExpTable)\ .filter(ExpTable.user_id == theuser.id)\ .order_by(ExpTable.id.desc())\ .limit(5) return render_template( 'users/profile/profile.html', seeifmod=seeifmod, postcount=postcount, moddingcount=moddingcount, ownercount=ownercount, usersubforums=usersubforums, guestsubforums=guestsubforums, seeifowner=seeifowner, wall_post_form=wall_post_form, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, friendform=friendform, deleteposttextform=deleteposttextform, posts=posts, theuser=theuser, user_name=user_name, navlink=navlink, get_followers=get_followers, follower_count=follower_count, followed_count=followed_count, expcount=expcount, userexp=userexp, )
def frontpage_mostactive(): """ Returns index page and most voted/commented posts :return: """ subform = SubscribeForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() subid = 0 navlink = 3 currentbchprice = db.session.query(BchPrices).get(1) # Trending subforums trending = db.session.query(SubForums).order_by( SubForums.total_exp_subcommon.desc()).limit(10) # get unread messages if current_user.is_authenticated: thenotes = db.session.query(Notifications) thenotes = thenotes.filter(Notifications.user_id == current_user.id) thenotes = thenotes.order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0) thenotescount = thenotescount.count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 recmsgs = db.session.query(Messages) recmsgs = recmsgs.filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) recmsgs = recmsgs.count() sendmsgs = db.session.query(Messages) sendmsgs = sendmsgs.filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) sendmsgs = sendmsgs.count() themsgs = int(sendmsgs) + int(recmsgs) # get subs user belongs too and add to list usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join( SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(current_user.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.room_deleted != 1) usersubforums = usersubforums.order_by((SubForums.id == 31).desc(), SubForums.subcommon_name) usersubforums = usersubforums.all() seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() mainpostform = MainPostForm( CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 # list of subs user belongs too usersublist = [] for usersub in usersubforums: usersublist.append(usersub.subcommon_id) # POSTS sub queries page = request.args.get('page', 1, type=int) posts = db.session.query(CommonsPost) posts = posts.filter(CommonsPost.subcommon_id.in_(usersublist)) posts = posts.filter(CommonsPost.subcommon_id != 1) posts = posts.filter(CommonsPost.hidden == 0) posts = posts.filter( or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) posts = posts.order_by(CommonsPost.comment_count.desc(), CommonsPost.created.desc()) posts = posts.paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('frontpage.frontpage_mostactive', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('frontpage.frontpage_mostactive', page=posts.prev_num) \ if posts.has_prev else None return render_template( 'frontpage.html', now=datetime.utcnow(), currentbchprice=currentbchprice, # forms mainpostform=mainpostform, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, subform=subform, # general thenotescount=thenotescount, seeifmod=seeifmod, moddingcount=moddingcount, thenotes=thenotes, subid=subid, themsgs=themsgs, navlink=navlink, usersubforums=usersubforums, # queries/pagination trending=trending, posts=posts.items, next_url=next_url, prev_url=prev_url, )
def frontpage_home(): """ Returns index page and most exp posts :return: """ subform = SubscribeForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() subid = 0 navlink = 1 currentbchprice = db.session.query(BchPrices).get(1) # get unread messages if current_user.is_authenticated: thenotes = db.session.query(Notifications) thenotes = thenotes.filter(Notifications.user_id == current_user.id) thenotes = thenotes.order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0) thenotescount = thenotescount.count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join( SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(current_user.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.room_deleted != 1) usersubforums = usersubforums.order_by((SubForums.id == 31).desc(), SubForums.subcommon_name) usersubforums = usersubforums.all() seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session.query(SubForums) seeifownering = seeifownering.filter( SubForums.creator_user_id == current_user.id) seeifownering = seeifownering.filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() if current_user.is_authenticated: mainpostform = MainPostForm( CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] else: mainpostform = None if current_user.is_authenticated: if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 else: post_18 = 0 allpost = 0 if current_user.is_authenticated: recmsgs = db.session.query(Messages) recmsgs = recmsgs.filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) recmsgs = recmsgs.count() sendmsgs = db.session.query(Messages) sendmsgs = sendmsgs.filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) sendmsgs = sendmsgs.count() themsgs = int(sendmsgs) + int(recmsgs) else: themsgs = 0 # list of subs user belongs too usersublist = [] for usersub in usersubforums: usersublist.append(usersub.subcommon_id) # query latest rooms new_rooms = db.session.query(SubForums) \ .filter(SubForums.id.notin_(usersublist), SubForums.room_deleted == 0, SubForums.room_suspended == 0, SubForums.room_banned == 0, SubForums.id != 1, SubForums.id != 14 ) \ .order_by(SubForums.created.desc()).limit(6) # query random rooms random_rooms = db.session.query(SubForums).filter( SubForums.id.notin_(usersublist), SubForums.room_deleted == 0, SubForums.room_suspended == 0, SubForums.room_banned == 0, SubForums.id != 1, SubForums.id != 14 ) \ .order_by(func.random()) \ .limit(6) page = request.args.get('page', 1, type=int) # POSTS sub queries where user is subbed to list # get posts by most exp posts = db.session.query(CommonsPost) posts = posts.filter(CommonsPost.subcommon_id.in_(usersublist)) posts = posts.filter(CommonsPost.subcommon_id != 1) posts = posts.filter(CommonsPost.hidden == 0) posts = posts.filter( or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) posts = posts.order_by(CommonsPost.hotness_rating_now.desc(), CommonsPost.created.desc()) posts = posts.paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('frontpage.frontpage_home', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('frontpage.frontpage_home', page=posts.prev_num) \ if posts.has_prev else None return render_template( 'frontpage.html', now=datetime.utcnow(), # forms subform=subform, thenotescount=thenotescount, mainpostform=mainpostform, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, # general new_rooms=new_rooms, random_rooms=random_rooms, seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, subid=subid, themsgs=themsgs, navlink=navlink, usersubforums=usersubforums, thenotes=thenotes, # pagination posts=posts.items, next_url=next_url, prev_url=prev_url, currentbchprice=currentbchprice, )
def followers_home(): """ Returns index page and most exp posts :return: """ try: subform = SubscribeForm() wall_post_form = MainPostForm(CombinedMultiDict((request.files, request.form))) banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() subid = 0 navlink = 3 currentbchprice = db.session\ .query(BchPrices)\ .get(1) thenotes = db.session\ .query(Notifications)\ .filter(Notifications.user_id == current_user.id)\ .order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0).count() thenotes = thenotes.limit(25) recmsgs = db.session\ .query(Messages)\ .filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1)\ .count() sendmsgs = db.session\ .query(Messages)\ .filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1)\ .count() themsgs = int(sendmsgs) + int(recmsgs) usersubforums = db.session\ .query(Subscribed)\ .join(SubForums, (Subscribed.subcommon_id == SubForums.id))\ .filter(current_user.id == Subscribed.user_id)\ .filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 )\ .order_by((SubForums.id == 31).desc(), SubForums.subcommon_name)\ .all() seeifmodding = db.session.query(Mods)\ .filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session\ .query(SubForums)\ .filter(SubForums.creator_user_id == current_user.id)\ .filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() # Most Recent Tippers recent_tippers_post = db.session.query(RecentTips) \ .order_by(RecentTips.created.desc()) \ .limit(3) # Trending subforums trending = db.session.query(SubForums) \ .order_by(SubForums.total_exp_subcommon.desc()) \ .limit(10) if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 # list of friends ids usersublist = [] usersubfriends = db.session\ .query(Followers) \ .filter(Followers.follower_id == current_user.id) \ .all() for userfriend in usersubfriends: usersublist.append(userfriend.followed_id) if current_user.is_authenticated: mainpostform = MainPostForm(CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = \ [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] else: mainpostform = None # POSTS sub queries where user is subbed to list # get posts by most exp page = request.args.get('page', 1, type=int) posts = db.session\ .query(CommonsPost)\ .filter(CommonsPost.hidden == 0)\ .filter(CommonsPost.user_id.in_(usersublist))\ .filter(or_(CommonsPost.age == post_18, CommonsPost.age == allpost))\ .order_by(CommonsPost.hotness_rating_now.desc(), CommonsPost.created.desc())\ .paginate(page, POSTS_PER_PAGE, False) next_url = url_for('followers.followers_home', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('followers.followers_home', page=posts.prev_num) \ if posts.has_prev else None except Exception as e: flash("There was an error") return redirect(url_for('index')) return render_template('followers.html', now=datetime.utcnow(), # forms subform=subform, mainpostform=mainpostform, wall_post_form=wall_post_form, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, # general seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, thenotescount=thenotescount, subid=subid, navlink=navlink, themsgs=themsgs, usersubforums=usersubforums, # queries/pagination trending=trending, thenotes=thenotes, # stats recent_tippers_post=recent_tippers_post, # pagination posts=posts.items, next_url=next_url, prev_url=prev_url, currentbchprice=currentbchprice, )
def create_post_room_all(userid): now = datetime.utcnow() id_pic1 = id_generator_picture1() wall_post_form = MainPostForm() uniqueid = id_generator(size=15) if request.method == 'POST': usersubforums = db.session \ .query(Subscribed) \ .join(SubForums, (Subscribed.subcommon_id == SubForums.id)) \ .filter(current_user.id == Subscribed.user_id) \ .all() wall_post_form.roomname.choices = [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] theuser = User.query \ .filter(User.id == userid) \ .first() getuser_timers = db.session \ .query(UserTimers) \ .filter_by(user_id=current_user.id) \ .first() user_stats = db.session \ .query(UserStats) \ .filter(UserStats.user_id == current_user.id) \ .first() if wall_post_form.validate_on_submit(): # see if user posted comment if wall_post_form.post_message.data == '': score_1 = 0 else: score_1 = 1 if wall_post_form.image_one.data: score_2 = 1 else: score_2 = 0 total_score = score_1 + score_2 if total_score == 0: flash("You need to post some content", category="success") return redirect((request.args.get('next', request.referrer))) getmatchingsubcommon = db.session \ .query(SubForums) \ .filter(SubForums.id == int(wall_post_form.roomname.data)) \ .first() chosen_subcommon_id = getmatchingsubcommon.id chosen_subcommon_name = getmatchingsubcommon.subcommon_name newpostnumber = user_stats.total_posts + 1 urlfound, urltitlefound, urldescriptionfound, urlimagefound = \ geturl(wall_post_form.post_message.data) transformed_text, notifyuser = \ transform_image_links_markdown(str(wall_post_form.post_message.data)) # add post to db newpost = CommonsPost( title=wall_post_form.post_title.data, user_id=theuser.id, user_name=theuser.user_name, # location realid=uniqueid, subcommon_id=chosen_subcommon_id, subcommon_name=chosen_subcommon_name, type_of_post=0, # text post_text=transformed_text, # url url_of_post=urlfound, url_description=urldescriptionfound, url_image=urlimagefound, url_title=urltitlefound, url_image_server='', # images image_server_1='', # stats total_exp_commons=0, highest_exp_reached=0, upvotes_on_post=0, comment_count=0, vote_timestamp=now, last_active=now, hotness_rating_now=0, page_views=0, # admin sticky=0, active=1, locked=0, hidden=0, muted=0, created=now, edited=now, ) getuser_timers.last_post = now user_stats.total_posts = newpostnumber db.session.add(user_stats) db.session.add(getuser_timers) db.session.add(newpost) db.session.commit() getusernodelocation = postnodelocation(x=newpost.id) postlocation = os.path.join(UPLOADED_FILES_DEST, current_disk, "post", getusernodelocation, str(newpost.id)) # image from url if urlfound: post_get_image(url=newpost.url_image, imagelocation=postlocation, thepost=newpost) # image From User if wall_post_form.image_one.data: mkdir_p(path=postlocation) filename = secure_filename( wall_post_form.image_one.data.filename) postimagefilepath = os.path.join(postlocation, filename) wall_post_form.image_one.data.save(postimagefilepath) # split file name and ending filenamenew, file_extension = os.path.splitext( postimagefilepath) # gets new 64 digit filename newfilename = id_pic1 + file_extension # puts new name with ending filenamenewfull = filenamenew + file_extension # gets aboslute path of new file newfilenamedestination = os.path.join(postlocation, newfilename) # renames file os.rename(filenamenewfull, newfilenamedestination) post_convert_image(imagelocation=postlocation, imagename=newfilename, thepost=newpost) if wall_post_form.image_one.data \ or (urlimagefound is not None and urlfound is not None): db.session.commit() if notifyuser is not None: # add info add_new_notification(user_id=notifyuser.id, subid=newpost.subcommon_id, subname=newpost.subcommon_name, postid=newpost.id, commentid=0, msg=32) # add exp points exppoint(user_id=current_user.id, category=1) return redirect((url_for('subforum.viewpost', subname=newpost.subcommon_name, postid=newpost.id))) else: flash("Post Creation Failure.", category="danger") for errors in wall_post_form.roomname.errors: flash(errors, category="danger") for errors in wall_post_form.post_message.errors: flash( "Message Failure...a message is required and 3- 5000 characters", category="danger") flash(errors, category="danger") for errors in wall_post_form.image_one.errors: flash(errors, category="danger") return redirect((request.args.get('next', request.referrer)))
def followers_newest(): """ Returns index page and newest posts :return: """ subform = SubscribeForm() wall_post_form = MainPostForm(CombinedMultiDict((request.files, request.form))) banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() subid = 0 navlink = 2 currentbchprice = db.session \ .query(BchPrices) \ .get(1) # Trending subfoums trending = db.session \ .query(SubForums) \ .order_by(SubForums.total_exp_subcommon.desc()) \ .limit(10) # get unread messages if current_user.is_authenticated: thenotes = db.session \ .query(Notifications) \ .filter(Notifications.user_id == current_user.id) \ .order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0).count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 recmsgs = db.session \ .query(Messages) \ .filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) \ .count() sendmsgs = db.session \ .query(Messages) \ .filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) \ .count() themsgs = int(sendmsgs) + int(recmsgs) seeifmodding = db.session.query(Mods) \ .filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session \ .query(SubForums) \ .filter(SubForums.creator_user_id == current_user.id) \ .filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() usersubforums = db.session \ .query(Subscribed) \ .join(SubForums, (Subscribed.subcommon_id == SubForums.id)) \ .filter(current_user.id == Subscribed.user_id) \ .filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 ) \ .all() if current_user.is_authenticated: if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 else: post_18 = 0 allpost = 0 # list of friends ids usersublist = [] usersubfriends = db.session \ .query(Followers) \ .filter(Followers.follower_id == current_user.id) \ .all() for userfriend in usersubfriends: usersublist.append(userfriend.followed_id) # POSTS sub queries page = request.args.get('page', 1, type=int) posts = db.session \ .query(CommonsPost) \ .filter(CommonsPost.hidden == 0) \ .filter(or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) \ .filter(CommonsPost.user_id.in_(usersublist)) \ .order_by(CommonsPost.created.desc()) \ .paginate(page,POSTS_PER_PAGE, False) next_url = url_for('followers.followers_newest', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('followers.followers_newest', page=posts.prev_num) \ if posts.has_prev else None return render_template('followers.html', now=datetime.utcnow(), currentbchprice=currentbchprice, # form wall_post_form=wall_post_form, subform=subform, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, # general thenotescount=thenotescount, thenotes=thenotes, themsgs=themsgs, seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, subid=subid, navlink=navlink, usersubforums=usersubforums, # queries/pagination trending=trending, posts=posts.items, next_url=next_url, prev_url=prev_url, )
def followers_top(): """ Returns index page and most voted/commented posts :return: """ subform = SubscribeForm() wall_post_form = MainPostForm(CombinedMultiDict((request.files, request.form))) banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() voteform = VoteForm() subid = 0 navlink = 5 currentbtcprice = db.session.query(BtcPrices).get(1) currentxmrprice = db.session.query(MoneroPrices).get(1) currentbchprice = db.session.query(BchPrices).get(1) currentltcprice = db.session.query(LtcPrices).get(1) # see if user leveled up and has a display to flash seeiflevelup = db.session.query(DisplayCoins).filter(DisplayCoins.user_id == current_user.id).all() if seeiflevelup is not None: for levelup in seeiflevelup: flash("You have leveled up to level: " + str(levelup.new_user_level), category='success') flash("Your have recieved 2 new coins", category='success') db.session.delete(levelup) db.session.commit() # Trending subforums trending = db.session.query(SubForums).order_by(SubForums.total_exp_subcommon.desc()).limit(10) # get unread messages if current_user.is_authenticated: thenotes = db.session.query(Notifications) thenotes = thenotes.filter(Notifications.user_id == current_user.id) thenotes = thenotes.order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0) thenotescount = thenotescount.count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 recmsgs = db.session.query(Messages) recmsgs = recmsgs.filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) recmsgs = recmsgs.count() sendmsgs = db.session.query(Messages) sendmsgs = sendmsgs.filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) sendmsgs = sendmsgs.count() themsgs = int(sendmsgs) + int(recmsgs) seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session.query(SubForums) seeifownering = seeifownering.filter(SubForums.creator_user_id == current_user.id) seeifownering = seeifownering.filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join(SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(current_user.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 ) usersubforums = usersubforums.all() if current_user.is_authenticated: if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 else: post_18 = 0 allpost = 0 # list of friends ids usersublist = [] usersubfriends = Followers.query.filter(Followers.follower_id == current_user.id).all() for userfriend in usersubfriends: usersublist.append(userfriend.followed_id) # POSTS sub queries page = request.args.get('page', 1, type=int) posts = db.session.query(CommonsPost) posts = posts.filter(CommonsPost.hidden == 0) posts = posts.filter(or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) posts = posts.filter(CommonsPost.user_id.in_(usersublist)) posts = posts.order_by(CommonsPost.highest_exp_reached.desc()) posts = posts.paginate(page, POSTS_PER_PAGE, False) next_url = url_for('followers.followers_mostactive', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('followers.followers_mostactive', page=posts.prev_num) \ if posts.has_prev else None return render_template('followers.html', now=datetime.utcnow(), currentbtcprice=currentbtcprice, currentxmrprice=currentxmrprice, currentbchprice=currentbchprice, currentltcprice=currentltcprice, # forms subform=subform, wall_post_form=wall_post_form, voteform=voteform, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, # general seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, thenotes=thenotes, thenotescount=thenotescount, subid=subid, themsgs=themsgs, navlink=navlink, usersubforums=usersubforums, # queries/pagination trending=trending, posts=posts.items, next_url=next_url, prev_url=prev_url, )
def followers_home(): """ Returns index page and most exp posts :return: """ try: subform = SubscribeForm() wall_post_form = MainPostForm(CombinedMultiDict((request.files, request.form))) banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() voteform = VoteForm() subpostcommentform = CreateCommentQuickForm() subid = 0 navlink = 3 currentbtcprice = db.session.query(BtcPrices).get(1) currentxmrprice = db.session.query(MoneroPrices).get(1) currentbchprice = db.session.query(BchPrices).get(1) currentltcprice = db.session.query(LtcPrices).get(1) thenotes = db.session.query(Notifications) thenotes = thenotes.filter(Notifications.user_id == current_user.id) thenotes = thenotes.order_by(Notifications.timestamp.desc()) thenotescount = thenotes.filter(Notifications.read == 0) thenotescount = thenotescount.count() thenotes = thenotes.limit(25) recmsgs = db.session.query(Messages) recmsgs = recmsgs.filter(Messages.rec_user_id == current_user.id, Messages.read_rec == 1) recmsgs = recmsgs.count() sendmsgs = db.session.query(Messages) sendmsgs = sendmsgs.filter(Messages.sender_user_id == current_user.id, Messages.read_send == 1) sendmsgs = sendmsgs.count() themsgs = int(sendmsgs) + int(recmsgs) usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join(SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(current_user.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 ) usersubforums = usersubforums.order_by((SubForums.id == 31).desc(), SubForums.subcommon_name) usersubforums = usersubforums.all() seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == current_user.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session.query(SubForums) seeifownering = seeifownering.filter(SubForums.creator_user_id == current_user.id) seeifownering = seeifownering.filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() # see if user leveled up and has a display to flash seeiflevelup = db.session.query(DisplayCoins).filter(DisplayCoins.user_id == current_user.id).all() if seeiflevelup is not None: for levelup in seeiflevelup: flash("You have leveled up to level: " + str(levelup.new_user_level), category='success') flash("Your have recieved 2 new coins", category='success') db.session.delete(levelup) db.session.commit() # stats for sidebar # all time top tippers for posts top_tippers_alltime_post_btc = db.session.query(BtcPostTips) \ .order_by(BtcPostTips.amount_usd.desc()) \ .limit(3) # top tippers this week seven_days_ago = datetime.today() - timedelta(days=7) top_tippers_pastweek_post_btc = db.session.query(BtcPostTips) \ .filter(BtcPostTips.created >= seven_days_ago) \ .order_by(BtcPostTips.amount_usd.desc()) \ .limit(3) # Most Recent Tippers recent_tippers_post = db.session.query(RecentTips) \ .order_by(RecentTips.created.desc()) \ .limit(3) # Trending subforums trending = db.session.query(SubForums) \ .order_by(SubForums.total_exp_subcommon.desc()) \ .limit(10) if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 # list of friends ids usersublist = [] usersubfriends = db.session.query(Followers)\ .filter(Followers.follower_id == current_user.id)\ .all() for userfriend in usersubfriends: usersublist.append(userfriend.followed_id) if current_user.is_authenticated: mainpostform = MainPostForm(CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = \ [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] else: mainpostform = None # POSTS sub queries where user is subbed to list # get posts by most exp page = request.args.get('page', 1, type=int) posts = db.session.query(CommonsPost) posts = posts.filter(CommonsPost.hidden == 0) posts = posts.filter(CommonsPost.user_id.in_(usersublist)) posts = posts.filter(or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) posts = posts.order_by(CommonsPost.hotness_rating_now.desc(), CommonsPost.created.desc()) posts = posts.paginate(page, POSTS_PER_PAGE, False) next_url = url_for('followers.followers_home', page=posts.next_num) \ if posts.has_next else None prev_url = url_for('followers.followers_home', page=posts.prev_num) \ if posts.has_prev else None except Exception as e: flash("There was an error") return redirect(url_for('index')) return render_template('followers.html', now=datetime.utcnow(), # forms subform=subform, subpostcommentform=subpostcommentform, mainpostform=mainpostform, voteform=voteform, wall_post_form=wall_post_form, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, # general seeifmod=seeifmod, moddingcount=moddingcount, seeifowner=seeifowner, ownercount=ownercount, thenotescount=thenotescount, subid=subid, navlink=navlink, themsgs=themsgs, usersubforums=usersubforums, # queries/pagination trending=trending, thenotes=thenotes, # stats top_tippers_alltime_post_btc=top_tippers_alltime_post_btc, top_tippers_pastweek_post_btc=top_tippers_pastweek_post_btc, recent_tippers_post=recent_tippers_post, # pagination posts=posts.items, next_url=next_url, prev_url=prev_url, currentbtcprice=currentbtcprice, currentxmrprice=currentxmrprice, currentbchprice=currentbchprice, currentltcprice=currentltcprice, )
def sub(subname): # forms reportform = ReportForm() subform = SubscribeForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() nsfwform = NSFWForm() navlink = 1 currentbchprice = db.session.query(BchPrices).get(1) # get the sub thesub = db.session \ .query(SubForums) \ .filter(func.lower(SubForums.subcommon_name) == subname.lower()) \ .first() if thesub is None: flash("Sub Doesnt Exist.", category="danger") return redirect(url_for('index')) if thesub.room_banned == 1: return redirect(url_for('subforum.sub_banned', subname=subname)) if thesub.room_suspended == 1: return redirect(url_for('subforum.sub_suspended', subname=subname)) if thesub.room_deleted == 1: return redirect(url_for('subforum.sub_deleted', subname=subname)) # get the stats substats = db.session \ .query(SubForumStats) \ .filter(SubForumStats.subcommon_name == subname.lower()) \ .first() # get sub customization subcustom_stuff = db.session \ .query(SubForumCustom) \ .filter(SubForumCustom.subcommon_id == thesub.id) \ .first() # get sub info box subinfobox = db.session \ .query(SubForumCustomInfoOne) \ .filter(func.lower(SubForumCustomInfoOne.subcommon_name) == subname.lower()) \ .first() subname = thesub.subcommon_name subid = int(thesub.id) mods = db.session \ .query(Mods) \ .filter(Mods.subcommon_id == subid) \ .all() if subcustom_stuff is None: subcustom_setup = None else: subcustom_setup = 1 # get unread messages if current_user.is_authenticated: thenotes = db.session \ .query(Notifications) \ .filter(Notifications.user_id == current_user.id) \ .order_by(Notifications.timestamp.desc()) \ .filter(Notifications.read == 0) thenotescount = thenotes.count() thenotes = thenotes.limit(25) else: thenotes = 0 thenotescount = 0 # see if user banned if current_user.is_authenticated: seeifbanned = db.session \ .query(Banned) \ .filter(current_user.id == Banned.user_id) \ .filter(Banned.subcommon_id == subid) \ .first() # if user on banned list turn him away if seeifbanned is not None: return redirect(url_for('banned', subname=subname)) # see if current user is a mod if current_user.is_authenticated: seeifmod = db.session \ .query(Mods) \ .filter(Mods.subcommon_id == subid) \ .filter(Mods.user_id == current_user.id) \ .first() if seeifmod is None: useramod = 0 else: useramod = 1 else: useramod = 0 # SIDEBAR if current_user.is_authenticated: # see if user is subscribed seeifsubbed = db.session.query(Subscribed) seeifsubbed = seeifsubbed.filter(current_user.id == Subscribed.user_id) seeifsubbed = seeifsubbed.filter(Subscribed.subcommon_id == subid) seeifsubbed = seeifsubbed.first() if seeifsubbed is None: seeifsubbed = 0 else: seeifsubbed = 1 # get users saved subcommons saved_subcommons = db.session.query(Subscribed) \ .filter(Subscribed.user_id == current_user.id) \ .all() # get users created subcommons created_subcommons = db.session.query(SubForums) \ .filter(SubForums.creator_user_id == current_user.id) \ .all() else: # if user isnt subscribed to anything seeifsubbed = None saved_subcommons = None created_subcommons = None if current_user.is_authenticated: usersubforums = db.session \ .query(Subscribed) \ .join(SubForums, (Subscribed.subcommon_id == SubForums.id)) \ .filter(current_user.id == Subscribed.user_id) \ .filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 ) \ .order_by((SubForums.id == 31).desc(), SubForums.subcommon_name) \ .all() guestsubforums = None else: guestsubforums = db.session \ .query(SubForums) \ .filter(SubForums.age_required == 0) \ .filter(SubForums.type_of_subcommon == 0) \ .filter(SubForums.room_banned == 0, SubForums.room_deleted == 0, SubForums.room_suspended == 0 ) \ .order_by(SubForums.total_exp_subcommon.desc()) \ .limit(20) usersubforums = None # if sub is private and user is a mod/owner if useramod: reportedposts = db.session \ .query(ReportedPosts) \ .filter(ReportedPosts.subcommon_name == subname) \ .count() reportedcomments = db.session \ .query(ReportedComments) \ .filter(ReportedComments.subcommon_name == subname) \ .count() else: reportedposts = 0 reportedcomments = 0 if current_user.is_authenticated: mainpostform = MainPostForm( CombinedMultiDict((request.files, request.form)), ) mainpostform.roomname.choices = \ [(str(row.subscriber.id), str(row.subscriber.subcommon_name)) for row in usersubforums] else: mainpostform = None # Get Stickies stickypostfrommods = db.session \ .query(CommonsPost) \ .filter(CommonsPost.subcommon_name == subname) \ .filter(CommonsPost.sticky == 1) \ .filter(CommonsPost.hidden == 0) \ .limit(2) # see if user is over age if current_user.is_authenticated: if current_user.over_age is False: post_18 = 0 allpost = 0 else: allpost = 0 post_18 = 1 else: post_18 = 0 allpost = 0 # POST QUERIES page = request.args.get('page', 1, type=int) posts = db.session \ .query(CommonsPost) \ .filter(CommonsPost.subcommon_name == subname) \ .filter(CommonsPost.hidden == 0) \ .filter(or_(CommonsPost.age == post_18, CommonsPost.age == allpost)) \ .filter(CommonsPost.sticky == 0) \ .order_by(CommonsPost.created.desc(), CommonsPost.hotness_rating_now.desc(), ) \ .paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('subforum.sub', subname=subname, page=posts.next_num) \ if posts.has_next else None prev_url = url_for('subforum.sub', subname=subname, page=posts.prev_num) \ if posts.has_prev else None return render_template( 'subforums/sub.html', now=datetime.utcnow(), mainpostform=mainpostform, nsfwform=nsfwform, subname=subname, thenotescount=thenotescount, subform=subform, subinfobox=subinfobox, subcustom_stuff=subcustom_stuff, subcustom_setup=subcustom_setup, stickypostfrommods=stickypostfrommods, navlink=navlink, reportform=reportform, banuserdeleteform=banuserdeleteform, thesub=thesub, subid=subid, substats=substats, usersubforums=usersubforums, guestsubforums=guestsubforums, thenotes=thenotes, saved_subcommons=saved_subcommons, created_subcommons=created_subcommons, seeifsubbed=seeifsubbed, mods=mods, useramod=useramod, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, reportedposts=reportedposts, reportedcomments=reportedcomments, posts=posts.items, next_url=next_url, prev_url=prev_url, currentbchprice=currentbchprice, )
def profile_other_posts_all(user_name): # forms friendform = FriendForm() voteform = VoteForm() deleteposttextform = DeletePostTextForm() banuserdeleteform = QuickBanDelete() lockpostform = QuickLock() deletepostform = QuickDelete() muteuserform = QuickMute() navlink = 2 wall_post_form = MainPostForm( CombinedMultiDict((request.files, request.form))) subpostcommentform = CreateCommentQuickForm() theuser = db.session.query(User).filter( User.user_name == user_name).first() if theuser is None: flash('User does not exist', category='warning') return redirect( url_for('profile.main', user_name=current_user.user_name)) # see if blocked if current_user.is_authenticated: isuserblocked = BlockedUser.query\ .filter(BlockedUser.user_id == theuser.id, BlockedUser.blocked_user == current_user.id)\ .first() if isuserblocked: flash('User does not exist', category='warning') return redirect(url_for('index')) useraddresses = SavedAddresses.query.filter( SavedAddresses.user_id == theuser.id).first() usersubforums = db.session.query(Subscribed) usersubforums = usersubforums.join( SubForums, (Subscribed.subcommon_id == SubForums.id)) usersubforums = usersubforums.filter(theuser.id == Subscribed.user_id) usersubforums = usersubforums.filter(SubForums.id != 1) usersubforums = usersubforums.filter(SubForums.age_required == 0) usersubforums = usersubforums.filter(SubForums.room_deleted != 1) usersubforums = usersubforums.filter(SubForums.room_suspended != 1) usersubforums = usersubforums.filter(SubForums.room_banned != 1) usersubforums = usersubforums.all() seeifmodding = db.session.query(Mods) seeifmodding = seeifmodding.filter(Mods.user_id == theuser.id) seeifmod = seeifmodding.all() moddingcount = seeifmodding.count() seeifownering = db.session.query(SubForums) seeifownering = seeifownering.filter( SubForums.creator_user_id == theuser.id) seeifownering = seeifownering.filter(SubForums.room_deleted != 1) seeifowner = seeifownering.all() ownercount = seeifownering.count() # get followers get_followers = db.session.query(User) get_followers = get_followers.join(Followers, (User.id == Followers.followed_id)) get_followers = get_followers.filter(Followers.follower_id == theuser.id) get_followers = get_followers.limit(9) # get users posts userposts = db.session.query(CommonsPost) userposts = userposts.filter(CommonsPost.subcommon_id == 1) userposts = userposts.filter(CommonsPost.user_name == theuser.user_name) userposts = userposts.filter(CommonsPost.poster_user_id != theuser.id) userposts = userposts.filter(CommonsPost.hidden == 0) userposts = userposts.order_by(CommonsPost.created.desc()) posts = userposts.limit(50) postcount = userposts.count() expcount = db.session.query(ExpTable).filter( ExpTable.user_id == theuser.id).count() userexp = db.session.query(ExpTable).filter( ExpTable.user_id == theuser.id).order_by(ExpTable.id.desc()).limit(5) return render_template( 'users/profile/profile_other.html', useraddresses=useraddresses, wall_post_form=wall_post_form, postcount=postcount, voteform=voteform, subpostcommentform=subpostcommentform, usersubforums=usersubforums, seeifmod=seeifmod, ownercount=ownercount, seeifowner=seeifowner, moddingcount=moddingcount, banuserdeleteform=banuserdeleteform, lockpostform=lockpostform, deletepostform=deletepostform, muteuserform=muteuserform, friendform=friendform, deleteposttextform=deleteposttextform, posts=posts, navlink=navlink, theuser=theuser, user_name=user_name, get_followers=get_followers, expcount=expcount, userexp=userexp, )