def post(self, post_reference): post = RequestPost.query(RequestPost.reference == post_reference).get() user = self.user_model if post: post.title = cgi.escape(self.request.get('title')) post.subject = cgi.escape(self.request.get('subject')) post.price = cgi.escape(self.request.get('price')) post.tutor_time = cgi.escape(self.request.get('time')) post.tutor_date = cgi.escape(self.request.get('date')) post.put() viewer = self.user_model #qry = RequestPost.query(RequestPost.reference == post_reference) #self.response.out.write(template.render('views/requestDetail.html',{'onePost': qry, 'viewer': viewer})) qry = RequestPost.query() notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10) notis_count = len(notifications) #self.redirect('/requests/{}'.format(post.reference)) self.response.out.write(template.render('views/requests.html',{'requestsList': qry, 'notifications': notifications, 'notis_count': notis_count, 'user': user }))
def post(self, post_reference): post = RequestPost.query(RequestPost.reference == post_reference).get() if post: post.title = cgi.escape(self.request.get('title')) post.subject = cgi.escape(self.request.get('subject')) post.price = cgi.escape(self.request.get('price')) post.tutor_time = cgi.escape(self.request.get('time')) post.tutor_date = cgi.escape(self.request.get('date')) post.put() viewer = self.user_model qry = RequestPost.query(RequestPost.reference == post_reference) self.response.out.write(template.render('views/requestDetail.html',{'onePost': qry, 'viewer': viewer}))
def post(self): post = RequestPost.query(RequestPost.reference == cgi.escape(self.request.get('post_reference'))).get() requester = User.query(User.username == cgi.escape(self.request.get('requester'))).get() applicant = User.query(User.username == cgi.escape(self.request.get('applicant'))).get() price_offer = cgi.escape(self.request.get('price_offer')) #create a notify message notifymsg = NotifiedMessage() notifymsg.read = False notifymsg.person_reference = requester.username notifymsg.object_reference = post.reference notifymsg.content = " offered $" + price_offer + " for " notifymsg.price = price_offer notifymsg.initiator = applicant.username #push to requester's noti box #logging.info(notifymsg) if applicant.key not in post.job_applicants: post.job_applicants.append(applicant.key) post.price_offers_new.append(price_offer) post.list_of_applicants.append(applicant.username) post.num_applicants = post.num_applicants + 1 post.put() notifymsg.put()
def post(self): post = RequestPost.query(RequestPost.reference == cgi.escape(self.request.get('post_reference'))).get() notifymsg = NotifiedMessage() if post: table_row_userid = cgi.escape(self.request.get('table_row_userid')) q = User.query(User.username == table_row_userid) tutor = q.get() post.tutor_paypal_email = tutor.paypal_email post.final_provider = table_row_userid index = post.list_of_applicants.index(table_row_userid) post.final_price = float(post.price_offers_new[index]) * float(post.duration) post.request_is_done = True notifymsg.read = False notifymsg.person_reference = table_row_userid notifymsg.object_reference = post.reference notifymsg.content = " accepted offer for " notifymsg.price = str(post.final_price) notifymsg.initiator = post.requester notifymsg.put() post.put()
def get(self, post_reference): viewer = self.user_model qry = RequestPost.query(RequestPost.reference == post_reference).get() applicants = [] class Applicants(): def __init__(self): self.first_name = "" self.username = "" self.number_of_stars = "" self.offer_price = "" i = 0 price_offers_new = [] price_offers_new = qry.price_offers_new for oneApp in qry.job_applicants: one = User.get_by_id(oneApp.id()) applicant = Applicants() applicant.first_name = one.first_name applicant.username = one.username applicant.number_of_stars = one.number_of_stars applicant.offer_price = qry.price_offers_new[i] i = i + 1 applicants.append(applicant) self.response.out.write(template.render('views/requestDetail.html',{ 'onePost': qry, 'applicants': applicants, 'viewer':viewer}))
def post(self): post = RequestPost.query(RequestPost.reference == cgi.escape(self.request.get('post_reference'))).get() requester = User.query(User.username == cgi.escape(self.request.get('requester'))).get() applicant = User.query(User.username == cgi.escape(self.request.get('applicant'))).get() price_offer = cgi.escape(self.request.get('price_offer')) if applicant.key not in post.job_applicants: post.job_applicants.append(applicant.key) post.price_offers_new.append(price_offer) post.list_of_applicants.append(applicant.username) post.num_applicants = post.num_applicants + 1 post.put()
def get(self, post_reference): viewer = self.user_model qry = RequestPost.query(RequestPost.reference == post_reference).get() notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10) notis_count = len(notifications) msg_count = viewer.msg_count applicants = [] class Applicants(): def __init__(self): self.first_name = "" self.last_name = "" self.username = "" self.number_of_stars = "" self.offer_price = "" i = 0 price_offers_new = [] price_offers_new = qry.price_offers_new for oneApp in qry.job_applicants: one = User.get_by_id(oneApp.id()) applicant = Applicants() applicant.first_name = one.first_name applicant.username = one.username applicant.last_name = one.last_name applicant.number_of_stars = one.number_of_stars applicant.offer_price = qry.price_offers_new[i] i = i + 1 applicants.append(applicant) #when request is paid self.response.out.write(template.render('views/requestDetail.html',{ 'onePost': qry, 'applicants': applicants, 'viewer':viewer, 'notifications': notifications, 'notis_count': notis_count, 'msg_count': msg_count }))
def post(self): value_sent = int(cgi.escape(self.request.get('value'))) tutee = cgi.escape(self.request.get('tutee')) tutor = cgi.escape(self.request.get('tutor')) post_ref = cgi.escape(self.request.get('postref')) query = RequestPost.query(RequestPost.reference == post_ref).get() tutee_profile = User.query(User.username == tutee).get() if query: query.onlytwopeoplecanStar.append(tutor) if tutee_profile: tutee_profile.number_of_stars += value_sent query.put() tutee_profile.put()
def post(self): post = RequestPost.query(RequestPost.reference == cgi.escape(self.request.get('post_reference'))).get() if post: table_row_userid = cgi.escape(self.request.get('table_row_userid')) q = User.query(User.username == table_row_userid) tutor = q.get() post.tutor_paypal_email = tutor.paypal_email post.final_provider = table_row_userid index = post.list_of_applicants.index(table_row_userid) post.final_price = float(post.price_offers_new[index]) * float(post.duration) post.request_is_done = True post.put()
def get(self): user = self.user_model open_request = self.request.get("open_request") highest_offer = self.request.get("highest_offer") newest_checkbox = self.request.get("newest_checkbox") qry = [] qry = RequestPost.query() if open_request: qry = qry.filter(RequestPost.request_is_done == False) if highest_offer: #qry = qry.order(RequestPost.price) qry = qry.order(-RequestPost.float_price) if newest_checkbox: #qry = qry.order(RequestPost.price) qry = qry.order(-RequestPost.date_created) #qry = RequestPost.query() notifications = NotifiedMessage.query(NotifiedMessage.person_reference == user.username).fetch(10) notis_count = len(notifications) msg_count = user.msg_count self.response.out.write(template.render('views/requests.html',{'requestsList': qry, 'notifications': notifications, 'notis_count': notis_count, 'user': user, 'open_request':open_request, 'highest_offer':highest_offer, 'newest_checkbox': newest_checkbox, 'msg_count': msg_count }))
def post(self): post = RequestPost.query(RequestPost.reference == cgi.escape(self.request.get('post_reference'))).get() #that post requester = cgi.escape(self.request.get('requester')) #tutee's name applicant = cgi.escape(self.request.get('applicant')) #tutor's name
def get(self, profile_id): viewer = self.user_model q = User.query(User.username == profile_id) user = q.get() profile = Profile.query(Profile.owner == user.key).get() #if profile isn't created, create one if not profile: profile = Profile() profile.owner = user.key profile.about = "I'm new to Techeria. Add me!" profile.put() TutorPosts = RequestPost.query(RequestPost.requester == profile_id).fetch() user.jobpostings = len(TutorPosts) # for starring and stuff starQry = RequestPost.query(RequestPost.payment_is_done == True) tutors_who_can_rate = [] tutees_who_can_rate = [] for a in starQry: tutors_who_can_rate.append(a.final_provider) tutees_who_can_rate.append(a.requester) #Get Notifications notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10) notis_count = len(notifications) trl = Transaction.query() transactions_list = [] for oneTransaction in trl: if viewer.username in oneTransaction.testPeoplewhocanseethis: transactions_list.append(oneTransaction) #Get Emails msg_count = viewer.msg_count posts_that_are_paid = RequestPost.query(RequestPost.payment_is_done == True).fetch() posts_tutors_applied_to = RequestPost.query().fetch() #payments history #for onePaid in PaidPosts: #if onePaid.final_provider == user.username: #posts_that_are_paid = PaidPosts skill_list = [] endorsements = Endorsement.query(Endorsement.endorsee == user.key).fetch() endorsement_details = EndorsementDetails.query(EndorsementDetails.endorsee == user.key).fetch() user.endorsement_count = len(endorsement_details) for skill in user.skills: skill = skill.get() if skill is not None: endorsement_list = [] endorsement_list.append(skill) #Get endorsement messages #Add number # count = 0 for x in endorsements: if x.skill == skill.key: count=x.endorsement_count endorsement_list.append(count) skill_list.append(endorsement_list) connection_list = [] """Get friend count """ counter = 0 for connection in user.friends: connection = User.get_by_id(connection.id()) counter+=1 user.friend_count = counter user.put() # Get Nested Comments comments = Comment.query(Comment.root==True, ndb.OR(Comment.recipient_key == user.key, Comment.sender_key == user.key)).order(-Comment.time).fetch(100) index = 0 while index < len(comments): children = Comment.query(Comment.parent == comments[index].key).fetch() index += 1 comments[index:index] = children if user: self.response.out.write(template.render('views/profile.html', {'user':user, 'comments': comments, 'viewer':viewer, 'skills':skill_list, 'profile':profile, 'endorsements':endorsement_details, 'TutorPosts': TutorPosts, 'posts_tutors_applied_to': posts_tutors_applied_to, 'posts_that_are_paid': posts_that_are_paid, 'notifications': notifications, 'notis_count': notis_count, 'transactions_list': transactions_list, 'tutors_who_can_rate': tutors_who_can_rate, 'tutees_who_can_rate': tutees_who_can_rate, 'msg_count': msg_count }))
def get(self, profile_id): viewer = self.user_model q = User.query(User.username == profile_id) user = q.get() profile = Profile.query(Profile.owner == user.key).get() #if profile isn't created, create one if not profile: profile = Profile() profile.owner = user.key profile.about = "I'm new to Techeria. Add me!" profile.put() TutorPosts = RequestPost.query(RequestPost.requester == profile_id).fetch() user.jobpostings = len(TutorPosts) #posts_tutors_applied_to = [] posts_tutors_applied_to = "" AllPosts = RequestPost.query() for onePost in AllPosts: if user.username in onePost.list_of_applicants: posts_tutors_applied_to = RequestPost.query().fetch() user.jobsapplied = len(posts_tutors_applied_to) skill_list = [] endorsements = Endorsement.query(Endorsement.endorsee == user.key).fetch() endorsement_details = EndorsementDetails.query(EndorsementDetails.endorsee == user.key).fetch() user.endorsement_count = len(endorsement_details) for skill in user.skills: skill = skill.get() if skill is not None: endorsement_list = [] endorsement_list.append(skill) #Get endorsement messages #Add number # count = 0 for x in endorsements: if x.skill == skill.key: count=x.endorsement_count endorsement_list.append(count) skill_list.append(endorsement_list) connection_list = [] """Get friend count """ counter = 0 for connection in user.friends: connection = User.get_by_id(connection.id()) counter+=1 user.friend_count = counter user.put() # Get Nested Comments comments = Comment.query(Comment.root==True, ndb.OR(Comment.recipient_key == user.key, Comment.sender_key == user.key)).order(-Comment.time).fetch(100) index = 0 while index < len(comments): children = Comment.query(Comment.parent == comments[index].key).fetch() index += 1 comments[index:index] = children if user: self.response.out.write(template.render('views/profile.html', {'user':user, 'comments': comments, 'viewer':viewer, 'skills':skill_list, 'profile':profile, 'endorsements':endorsement_details, 'TutorPosts': TutorPosts, 'posts_tutors_applied_to': posts_tutors_applied_to }))
def post(self): user = self.user_model title = cgi.escape(self.request.get('title')) subject = cgi.escape(self.request.get('subject')) price = cgi.escape(self.request.get('price')) tutor_time = cgi.escape(self.request.get('time')) url = cgi.escape(self.request.get('url')) tutor_date = cgi.escape(self.request.get('date')) duration = int(cgi.escape(self.request.get('duration'))) tags = cgi.escape(self.request.get('tags')) post = RequestPost() post.title = title post.subject = subject post.price = price post.float_price = float(price) post.duration = duration redirect_link = '/requests' post.url = url post.url_host = urlparse(url).hostname post.reference = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)) post.tutor_date = tutor_date post.tutor_time = tutor_time post.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST post.user = user post.requester = user.username # tagging thing post.tags = tags.split(",") for oneTagPerson in post.tags: notifymsg = NotifiedMessage() notifymsg.read = False notifymsg.person_reference = oneTagPerson notifymsg.object_reference = post.reference notifymsg.content = " tagged you in " notifymsg.initiator = post.requester notifymsg.put() post.put() qry = RequestPost.query() self.response.out.write(template.render('views/requests.html',{'requestsList': qry, 'user': user})) #alert was here #<div id="message"> #<div class="alert alert-success"> #<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> #<strong>job request has been posted!!</strong> #</div> #</div> self.response.out.write(""" <style> #message { position:fixed; top: 90px; width: 100%; align: left } </style> <script> setTimeout(function(){ $("#message").hide(); redirect_link = '/requests' window.location.href = redirect_link; }, 1); </script> """)
def get(self): qry = RequestPost.query() self.response.out.write(template.render('views/requests.html',{'requestsList': qry}))
def post(self): user = self.user_model title = cgi.escape(self.request.get('title')) subject = cgi.escape(self.request.get('subject')) price = cgi.escape(self.request.get('price')) tutor_time = cgi.escape(self.request.get('time')) url = cgi.escape(self.request.get('url')) tutor_date = cgi.escape(self.request.get('date')) duration = int(cgi.escape(self.request.get('duration'))) post = RequestPost() post.title = title post.subject = subject post.price = price post.duration = duration redirect_link = '/requests' post.url = url post.url_host = urlparse(url).hostname post.reference = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)) post.tutor_date = tutor_date post.tutor_time = tutor_time post.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST post.user = user post.requester = user.username post.put() qry = RequestPost.query() self.response.out.write(template.render('views/requests.html',{'requestsList': qry})) self.response.out.write(""" <div id="message"> <div class="alert alert-success"> <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> <strong>job request has been posted!!</strong> </div> </div> <style> #message { position:fixed; top: 45px; left: 0; width: 100%; align: center } </style> <script> setTimeout(function(){ $("#message").hide(); redirect_link = '/requests' window.location.href = redirect_link; }, 1700); </script> """)
def post(self): post_reference = cgi.escape(self.request.get('post_reference')) post = RequestPost.query(RequestPost.reference == post_reference).get() post.key.delete() self.response.out.write(template.render('views/profile.html',{}))
def post(self, mode =""): # Nothing to do here, content script will pick up accesstoken from here if mode == "ipn": logging.info(self.request.body) result = urlfetch.fetch( ipn_sandbox_url, payload = "cmd=_notify-validate&" + self.request.body, method=urlfetch.POST, validate_certificate=True ) logging.info(result.content) if result.status_code == 200 and result.content == 'VERIFIED': # OK ipn_values = cgi.parse_qs(self.request.body) debug_msg = '\n'.join(["%s=%s" % (k,'&'.join(v)) for (k,v) in ipn_values.items()]) #logging.info("from tung with love") item_number = cgi.escape(self.request.get('item_number')) # get stuff transaction_id = str(cgi.escape(self.request.get('txn_id'))) payer_email = str(cgi.escape(self.request.get('payer_email'))) receiver_email = str(cgi.escape(self.request.get('receiver_email'))) item_amount = str(cgi.escape(self.request.get('payment_gross'))) sales_tax = str(cgi.escape(self.request.get('tax'))) shipping = str(cgi.escape(self.request.get('shipping'))) handling = str(cgi.escape(self.request.get('mc_fee'))) quantity = str(cgi.escape(self.request.get('quantity'))) item_name = str(cgi.escape(self.request.get('item_name'))) date = str(cgi.escape(self.request.get('payment_date'))) status = str(cgi.escape(self.request.get('payment_status'))) payment_type = str(cgi.escape(self.request.get('payment_type'))) ### Change Request to done post = RequestPost.query(RequestPost.reference == item_number).get() #that post if post: post.payment_is_done = True ## Notify tutee notifymsg = NotifiedMessage() notifymsg.read = False notifymsg.person_reference = post.requester notifymsg.object_reference = item_number notifymsg.content = " paid " + item_amount + ", click to give feedback" notifymsg.price = item_amount notifymsg.initiator = post.requester notifymsg.put() # ## Notify tutor notifymsg2 = NotifiedMessage() notifymsg2.read = False notifymsg2.person_reference = post.final_provider notifymsg2.object_reference = item_number notifymsg2.content = " paid " + item_amount + ", click to give feedback " notifymsg2.price = item_amount notifymsg2.initiator = post.requester notifymsg2.put() ### Create Transaction Object newtransaction = Transaction() newtransaction.transaction_id = transaction_id newtransaction.payer_email = payer_email newtransaction.receiver_email = receiver_email newtransaction.item_amount = item_amount newtransaction.sales_tax = sales_tax newtransaction.shipping = shipping newtransaction.handling = handling newtransaction.quantity = quantity newtransaction.item_name = item_name newtransaction.item_number = item_number newtransaction.date = date newtransaction.status = status newtransaction.payment_type = payment_type newtransaction.tutee_username = post.requester newtransaction.tutor_username = post.final_provider newtransaction.testPeoplewhocanseethis.append(post.requester) newtransaction.testPeoplewhocanseethis.append(post.final_provider) newtransaction.put() post.put() self.response.out.write(debug_msg) else: logging.error('Could not fetch %s (%i)' % (url, result.status_code,)) else: logging.error("Unknown mode for POST request!")