def userAccount(un): if 'username' in session: username = session['username'] if username == un: return redirect(url_for('account')) else: user = loginDB.getUser(un) #image = "defaultProfileImage.png" username = user[0][0] firstname = user[0][1] lastname = user[0][2] email = user[0][3] phone = user[0][4] password = user[0][5] image = user[0][6] userPost = postDB.getUserPost(un) return render_template("userAccount.html", username=username, firstname=firstname, lastname=lastname, email=email, phone=phone, image=image, password=password, userPost=userPost) else: return redirect(url_for('login'))
def editDetails(eid): if (request.cookies.get('email')): user = loginDB.getUser(request.cookies.get('email')) email = user[0][0] name = user[0][1] image = user[0][3] msg = "Data edited successfully!" DescriptionOfGoods = request.form.get("DescriptionOfGoods") HSNSAC = request.form.get("HSNSAC") Qty = float(request.form.get("Qty")) ExcRatePerUnit = round(float(request.form.get("ExcRatePerUnit")),2) Gst = round(float(request.form.get("Gst")),2) IncRatePerUnit = round((ExcRatePerUnit + (ExcRatePerUnit*Gst)/100),2) TaxableValue = round(((ExcRatePerUnit) * float(Qty)),2) totaltax = round((TaxableValue*(Gst))/100,2) Cgst=round(totaltax/2,2) Sgst=round(totaltax/2,2) TotalAmount = round((TaxableValue + totaltax),2) #exclRate = round((RatePerUnit - (RatePerUnit*Gst/100)),2) #TaxableValue = round(((exclRate) * float(Qty)),2) #totaltax = round(((RatePerUnit*float(Qty))-TaxableValue),2) #Cgst=round(totaltax/2,2) #Sgst=round(totaltax/2,2) #TotalAmount = round((TaxableValue + totaltax),2) employeedb.edit(eid,DescriptionOfGoods,HSNSAC,Qty,ExcRatePerUnit,IncRatePerUnit, Gst,TaxableValue,Cgst,Sgst,TotalAmount,email) return render_template("success.html",msg = msg, email=email, name=name, image=image) else: return redirect(url_for('login'))
def index(): if (request.cookies.get('email')): user = loginDB.getUser(request.cookies.get('email')) email = user[0][0] name = user[0][1] image = user[0][3] return render_template("getin.html",email=email,name=name,image=image) else: return redirect(url_for('login'))
def logout(): #session.pop('username', None) #flash('Successfully logged out !', "success") #return render_template("login.html") username = loginDB.getUser(request.cookies.get('username')) resp = make_response(render_template("login.html")) resp.set_cookie('username', expires=0) #resp.delete_cookie('username', path='/login', domain='127.0.0.1:5002') return resp
def getdata(row_id): if (request.cookies.get('email')): user = loginDB.getUser(request.cookies.get('email')) #email = user[0][0] name = user[0][1] image = user[0][3] data = employeedb.getdata(row_id) return render_template("edit.html", data=data, name=name, image=image) else: return redirect(url_for('login'))
def home(): if 'username' in session: user = loginDB.getUser(session['username']) image = user[0][6] post = postDB.getAllPost() #return render_template("index.html", post=post) return render_template("index.html", image=image, post=post) else: return redirect(url_for('login'))
def add(): if (request.cookies.get('email')): #email2 = request.cookies.get('email') #image2 = loginDB.userImage(email2) user = loginDB.getUser(request.cookies.get('email')) email = user[0][0] name = user[0][1] image = user[0][3] return render_template("add.html",email=email,name=name,image=image) else: return redirect(url_for('login'))
def deleterecord(row_id): if (request.cookies.get('email')): #id = request.form["id"] user = loginDB.getUser(request.cookies.get('email')) email = user[0][0] name = user[0][1] image = user[0][3] employeedb.delete(row_id) msg = "record successfully deleted!" return render_template("delete_record.html",msg = msg,email=email,name=name,image=image) else: return redirect(url_for('login'))
def view(): if (request.cookies.get('email')): #image = loginDB.userImage(request.cookies.get('email')) user = loginDB.getUser(request.cookies.get('email')) email = user[0][0] name = user[0][1] image = user[0][3] rows = employeedb.viewData(request.cookies.get('email')) return render_template("view.html",rows = rows,email=email,name=name,image=image) else: return redirect(url_for('login'))
def saveDetailsInc(): if (request.cookies.get('email')): msg = "msg" user = loginDB.getUser(request.cookies.get('email')) name = user[0][1] image = user[0][3] if request.method == "POST": #database variable names:- #DescriptionOfGoods #HSNSAC #Qty #RatePerUnit #Gst #TaxableValue #Cgst #Sgst #TotalAmount DescriptionOfGoods = request.form.get("DescriptionOfGoods") HSNSAC = request.form.get("HSNSAC") Qty = (request.form.get("Qty")) IncRatePerUnit = round(float(request.form.get("IncRatePerUnit")),2) Gst = round(float(request.form.get("Gst")),2) ExcRatePerUnit = round(((IncRatePerUnit*100)/(100+Gst)),2) TaxableValue = round(((ExcRatePerUnit) * float(Qty)),2) totaltax = round((TaxableValue*(Gst))/100,2) Cgst=round(totaltax/2,2) Sgst=round(totaltax/2,2) TotalAmount = round((TaxableValue + totaltax),2) #exclRate = round((RatePerUnit - (RatePerUnit*Gst/100)),2) #TaxableValue = round(((exclRate) * float(Qty)),2) #totaltax = round(((RatePerUnit*float(Qty))-TaxableValue),2) #Cgst=round(totaltax/2,2) #Sgst=round(totaltax/2,2) #TotalAmount = round((TaxableValue + totaltax),2)# email = request.cookies.get('email') employeedb.addData(DescriptionOfGoods,HSNSAC,Qty,ExcRatePerUnit,IncRatePerUnit,Gst,TaxableValue,Cgst,Sgst,TotalAmount,email) msg = "Data successfully Added" return render_template("success.html",msg = msg,email=email,name=name,image=image) else: msg = "We can not add the Data to the list" return render_template("success.html",msg = msg,email=email,name=name,image=image) else: return redirect(url_for('login'))
def commentOnReport(pid): if request.cookies.get('username'): username = request.cookies.get('username') user = loginDB.getUser(username) firstname = user[0][1] lastname = user[0][2] name = firstname + " " + lastname cmnt = request.form.get("commentBox") reportCommentDB.addReportComment(pid, name, cmnt) redirectUrl = '/report/' + str(pid) return redirect(redirectUrl) else: name = "Unknown User" cmnt = request.form.get("commentBox") reportCommentDB.addReportComment(pid, name, cmnt) redirectUrl = '/report/' + str(pid) return redirect(redirectUrl)
def account(): if 'username' in session: user = loginDB.getUser(session['username']) #image = "defaultProfileImage.png" firstname = user[0][1] lastname = user[0][2] email = user[0][3] phone = user[0][4] image = user[0][6] return render_template("account.html", firstname=firstname, lastname=lastname, email=email, phone=phone, image=image) else: return redirect(url_for('login'))
def market(): if request.cookies.get('username'): ads = [] username = request.cookies.get('username') user = loginDB.getUser(username) user_name = user[0][0] ads2 = marketDB.getAds() for i in range(len(ads2)): index2 = random.sample(range(0, len(ads2)), len(ads2)) for j in range(len(index2)): index = index2[j] ads.append(ads2[index]) return render_template("market.html", user_name=user_name, ads=ads, username=username) else: return redirect(url_for('login'))
def updateInfo(): if 'username' in session: user = loginDB.getUser(session['username']) #image = "defaultProfileImage.png" username = user[0][0] firstname = user[0][1] lastname = user[0][2] email = user[0][3] phone = user[0][4] password = user[0][5] image = user[0][6] return render_template("updateInfo.html", username=username, firstname=firstname, lastname=lastname, email=email, phone=phone, image=image, password=password) else: return redirect(url_for('login'))
def userAccount(un): if request.cookies.get('username'): #user = loginDB.getUser(session['username']) username = request.cookies.get('username') if username == un: return redirect(url_for('account')) else: follows = False user = loginDB.getUser(un) #image = "defaultProfileImage.png" sharedPosts = sharedDB.getSharedPosts(un) user_name = request.cookies.get('username') following = followDB.getFollowing(user_name) for i in range(len(following)): if (un == following[i][0]): follows = True username = user[0][0] firstname = user[0][1] lastname = user[0][2] email = user[0][3] phone = user[0][4] password = user[0][5] image = user[0][6] userPost = postDB.getUserPost(un) userPost.extend(sharedPosts) moments = momentsDB.getMomentsForAccount(un) return render_template("userAccount.html", moments=moments, follows=follows, user_name=user_name, username=username, firstname=firstname, lastname=lastname, email=email, phone=phone, image=image, password=password, userPost=userPost) else: return redirect(url_for('login'))
def home(): #if 'username' in session: if request.cookies.get('username'): post = [] #user = loginDB.getUser(session['username']) user = loginDB.getUser(request.cookies.get('username')) image = user[0][6] post2 = postDB.getAllPost() sharedPosts = sharedDB.getSharedPost() post2.extend(sharedPosts) for i in range(len(post2)): index2 = random.sample(range(0, len(post2)), len(post2)) for j in range(len(index2)): index = index2[j] post.append(post2[index]) resp = make_response( render_template("index.html", image=image, post=post)) #return render_template("index.html", post=post) #return render_template("index.html", image=image,post=post) return resp else: return redirect(url_for('login'))
def account(): if request.cookies.get('username'): #user = loginDB.getUser(session['username']) user = loginDB.getUser(request.cookies.get('username')) sharedPosts = sharedDB.getSharedPosts(request.cookies.get('username')) #image = "defaultProfileImage.png" following = followDB.getFollowingNames(request.cookies.get('username')) noOfFollowing = len(following) followers = followDB.getFollowerNames(request.cookies.get('username')) noOfFollowers = len(followers) username = user[0][0] firstname = user[0][1] lastname = user[0][2] email = user[0][3] phone = user[0][4] password = user[0][5] image = user[0][6] userPost = postDB.getUserPost(username) userPost.extend(sharedPosts) moments = momentsDB.getMomentsForAccount( request.cookies.get('username')) return render_template("account.html", moments=moments, noOfFollowers=noOfFollowers, noOfFollowing=noOfFollowing, following=following, followers=followers, username=username, firstname=firstname, lastname=lastname, email=email, phone=phone, image=image, password=password, userPost=userPost) else: return redirect(url_for('login'))