コード例 #1
0
ファイル: Tutees.py プロジェクト: nikko0327/Ninja-Tutor
  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
                                                                  }))
コード例 #2
0
ファイル: Tutees.py プロジェクト: nikko0327/Ninja-Tutor
 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
                                                                   }))
コード例 #3
0
ファイル: Tutees.py プロジェクト: nikko0327/Ninja-Tutor
  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
      }))
コード例 #4
0
ファイル: Payment.py プロジェクト: nikko0327/Ninja-Tutor
  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
コード例 #5
0
ファイル: Conversation.py プロジェクト: nikko0327/Ninja-Tutor
 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
                                                                    }))
コード例 #6
0
ファイル: Tutees.py プロジェクト: nikko0327/Ninja-Tutor
  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
                                                                  }))
コード例 #7
0
ファイル: Payment.py プロジェクト: nikko0327/Ninja-Tutor
  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

                                                                        }))
コード例 #8
0
ファイル: main.py プロジェクト: nikko0327/Ninja-Tutor
  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
                                        }))
コード例 #9
0
ファイル: main.py プロジェクト: nikko0327/Ninja-Tutor
 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}))
コード例 #10
0
ファイル: Conversation.py プロジェクト: nikko0327/Ninja-Tutor
  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
                                                                            }))
コード例 #11
0
ファイル: Tutors.py プロジェクト: nikko0327/Ninja-Tutor
  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
                                                    }))