Ejemplo 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()
Ejemplo 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()
Ejemplo n.º 3
0
  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
                                                                  }))
Ejemplo n.º 4
0
 def get(self):
   user = self.user_model
   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/postRequest.html',
                                                               {'notifications': notifications,
                                                                   'notis_count': notis_count,
                                                                   'msg_count': msg_count
                                                                   }))
Ejemplo n.º 5
0
  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
      }))
Ejemplo n.º 6
0
  def get(self, transaction_ref):
    viewer = self.user_model

    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10)
    notis_count = len(notifications)
    msg_count = viewer.msg_count

    qry = Transaction.query(Transaction.transaction_id == transaction_ref).get() #that post
    if qry:
      print "yes"

    if viewer.username in qry.testPeoplewhocanseethis:
      self.response.out.write(template.render('views/transactionDetail.html',{'Onetransaction' : qry,
                                                                              'notifications': notifications,
                                                                              'notis_count': notis_count,
                                                                              'msg_count': msg_count
                                                                              }))
    else:
      self.response.out.write(template.render('views/404notfound.html',{})) #prevent people other than tutor and tutee to see this transaction
Ejemplo n.º 7
0
 def get(self):
    logging.info("hi")
    user = self.user_model
    user.msg_count = 0
    msg_count = user.msg_count
    user.put()
    conversations = Conversation.query(ndb.OR(
        user.username == Conversation.sender, 
        user.username == Conversation.recipient))

    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == user.username).fetch(10)
    notis_count = len(notifications)
    



    self.response.out.write(template.render('views/messages.html', {'viewer': user, 
                                                                    'conversations': conversations,
                                                                    'notifications': notifications,
                                                                    'notis_count': notis_count,
                                                                    'msg_count': msg_count
                                                                    }))
Ejemplo n.º 8
0
  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
                                                                  }))
Ejemplo n.º 9
0
  def get(self):
    tx            = cgi.escape(self.request.get('tx'))
    st            = cgi.escape(self.request.get('st'))
    amt           = cgi.escape(self.request.get('amt'))
    item_number   = cgi.escape(self.request.get('item_number'))

           
    #self.response.out.write(': ' + tx)
    #self.response.out.write(': ' + st)
    #self.response.out.write(': ' + amt)
    #self.response.out.write(': ' + item_number)
    viewer = self.user_model
    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch(10)
    notis_count = len(notifications)
    msg_count = viewer.msg_count

    self.response.out.write(template.render('views/requestPlaced.html',{

                                                                              'notifications': notifications,
                                                                              'notis_count': notis_count,
                                                                              'msg_count': msg_count

                                                                        }))
Ejemplo n.º 10
0
  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
                                        }))
Ejemplo n.º 11
0
 def get(self):
   viewer = self.user_model
   notifications = NotifiedMessage.query(NotifiedMessage.person_reference == viewer.username).fetch()
   self.response.out.write(template.render('views/notifsFullview.html',{'notifications': notifications}))
Ejemplo n.º 12
0
  def get(self, conv_reference):
    user = self.user_model
    #parse string
    #get messages
    temp_query = conv_reference.strip()
    temp = temp_query.split('&')

    msg_count = user.msg_count


    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == user.username).fetch(10)
    notis_count = len(notifications)

    string1 = str(temp[0])
    string1 = str(string1).replace('[','').replace(']','')
    string1 = str(string1).replace("'",'').replace("'",'')
    string1 = str(string1).replace(" ","")
    string1 = str(string1).replace(","," ")

    string2 = str(temp[1:2])
    string2 = str(string2).replace('[','').replace(']','')
    string2 = str(string2).replace("'",'').replace("'",'')
    string2 = str(string2).replace(" ","")
    string2 = str(string2).replace(","," ")


    #logging.info(string2 + " " + string1)
    #logging.info(string1 + " " + string2)

    temp1 = " ".join((string1, string2))    #conv_ref
    temp2 = " ".join((string2, string1))    #conv_ref_inverse

    if user.username != string1 and user.username != string2:
        self.response.out.write(template.render('views/404notfound.html',{}))

    else:



        conversation_qry = Conversation.query(ndb.OR(Conversation.owners == temp1, Conversation.owners == temp2)).get()

        messages = []

        if conversation_qry:
            for oneMessage in conversation_qry.children:
                logging.info(oneMessage.get())
                messages.append(oneMessage.get())

        else:
            logging.info("not found")


        #self.response.out.write(template.render('views/404notfound.html',{})) #prevent people other than tutor and tutee to see this transaction
        self.response.out.write(template.render('views/readMessage.html', {'messages': messages, 
                                                                            'user': user, 
                                                                            'temp2': temp2, 
                                                                            'temp1': temp1,
                                                                            'notifications': notifications,
                                                                            'notis_count': notis_count,
                                                                            'msg_count': msg_count
                                                                            }))
Ejemplo n.º 13
0
  def get(self):
    user = self.user_model
    mylist = []
    subject_query     = self.request.get("subj")
    language_query    = self.request.get("lang")
    school_query      = self.request.get("school")
    zip_query         = self.request.get("zip_code")
    name_query        = self.request.get("name")
    school_query      = self.request.get("school")
    available_today   = self.request.get("available_today")
    available_tmr     = self.request.get("available_tmr")
    available_wk      = self.request.get("available_wk")
    min_price         = self.request.get("min_price")
    max_price         = self.request.get("max_price")
    order             = self.request.get("order")



    checked_today = False
    checked_tmr = False
    checked_wk = False


    qry = []

    qry = User.query(User.verified==True)

    if subject_query:
      logging.info(subject_query)
      qry = User.query()
      qry = qry.filter(User.subject_list == subject_query)

    if language_query:
      logging.info(language_query)
      qry = qry.filter(User.second_language == language_query)

    if zip_query:
      logging.info(zip_query)
      qry = qry.filter(User.zip_code == zip_query)

    temp = []
    if name_query:
      #logging.info(name_query)
      buffs = name_query.split(" ")
      for oneWord in buffs:
        logging.info(oneWord)
      #low_temp = oneWord.strip().lower() 
        #temp =  User.query(User.lower_last_name == oneWord)
        temp =  User.query(
          ndb.OR(User.lower_last_name == oneWord, User.lower_first_name == oneWord),
          ndb.AND(User.verified == True)
          )
                  
      qry = temp
        #qry =  qry.filter(ndb.OR(User.lower_last_name != oneWord, User.lower_last_name == oneWord))
        #qry =  qry.filter(ndb.OR(User.lower_last_name != oneWord, User.lower_last_name != oneWord))


        #lower first 
        #logging.info(low_temp)
        #qry.filter(ndb.OR(User.lower_first_name == low_temp, User.lower_last_name == low_temp))
        #qry.filter(User.lower_last_name == low_temp)
      #for oneWord in buffs:
        #low_temp = oneWord.strip().lower() 
        #qry = qry.filter(User.lower_last_name == oneWord)
        #lower first 
        #logging.info(low_temp)

    if school_query:
      logging.info(school_query)
      qry = qry.filter(User.school == school_query)

    if available_today:
      qry = qry.filter(User.available_today == True)
      checked_today = True

    if available_tmr:
      qry = qry.filter(User.available_tmr == True)
      checked_tmr = True

    if available_wk:
      qry = qry.filter(User.available_wk == True)
      checked_wk = True

    if max_price and min_price:
      qry = qry.filter(ndb.AND(User.rate_per_hour >= float(min_price), User.rate_per_hour <= float(max_price)))
      logging.info(min_price + ' and ' + max_price)

    if order:
      if order == "high":
        logging.info("very high")
        qry = qry.order(-User.number_of_stars)

      elif order == "low":
        logging.info("very low")
        qry = qry.order(User.number_of_stars)

      else:
        logging.info("date")
        qry = qry.order(-User.created)


    #qry = User.query().order(-User.number_of_stars)
    notifications = NotifiedMessage.query(NotifiedMessage.person_reference == user.username).fetch(10)
    notis_count = len(notifications)
    msg_count = user.msg_count

    mylist.append('Roger');
    self.response.out.write(template.render('views/tutorsList.html',{
                                                    'tutorsList': qry,
                                                    'notifications': notifications,
                                                    'notis_count': notis_count,
                                                    'min_price': min_price,
                                                    'max_price': max_price,
                                                    'checked_today': checked_today,
                                                    'checked_tmr': checked_tmr,
                                                    'checked_wk': checked_wk,
                                                    'msg_count': msg_count
                                                    }))
Ejemplo n.º 14
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!")
Ejemplo n.º 15
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>
      """)