Exemplo n.º 1
0
  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()
Exemplo n.º 2
0
  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()
Exemplo n.º 3
0
  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!")
Exemplo n.º 4
0
  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">&times;</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>
      """)