当前位置: 首页>>代码示例>>Python>>正文


Python Profile.about方法代码示例

本文整理汇总了Python中models.Profile.about方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.about方法的具体用法?Python Profile.about怎么用?Python Profile.about使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Profile的用法示例。


在下文中一共展示了Profile.about方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import about [as 别名]
  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
                                        }))
开发者ID:cthavy,项目名称:Ninja-Frontend,代码行数:68,代码来源:main.py

示例2: get

# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import about [as 别名]
  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
                                        }))
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:102,代码来源:main.py


注:本文中的models.Profile.about方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。