Example #1
0
   def getClubListApiofAdmin(self,request):
               #Make new api for GetList of clubs you are admin of.
               #Take PID and return all clubs he is admin of.
               #Return response just like getClubList response
               profileKey = ndb.Key('Profile',int(request.pid))
               profile = profileKey.get()
               list_of_clubs = ClubListResponse()
               for obj in profile.admin:
                   ret_club = obj.get()
                   format_club = ClubMiniForm()
                   format_club.name = ret_club.name
                   format_club.abbreviation = ret_club.abbreviation
                   format_club.collegeName = ret_club.collegeId.get().name
                   format_club.name = ret_club.admin.get().name
                   format_club.description = ret_club.description
                   format_club.club_id = str(ret_club.key.id())
                   format_club.isMember = "Y"
                   format_club.isFollower = "Y"
                   list_of_clubs.list.append(format_club)





               return list_of_clubs
Example #2
0
   def getClubListApi(self,request):
        list_of_clubs = ClubListResponse()
        print("Request entity is",request)

        if request:


            collegeKey = ndb.Key('CollegeDb',int(request.college_id))
            college = collegeKey.get()

            if(college):


                for obj in college.group_list :
                   ret_club = obj.get()
                   format_club = ClubMiniForm()
                   format_club.name = ret_club.name
                   format_club.abbreviation = ret_club.abbreviation
                   format_club.collegeName = ret_club.collegeId.get().name
                   format_club.name = ret_club.admin.get().name
                   format_club.description = ret_club.description
                   format_club.club_id = str(ret_club.key.id())
                   if(request.pid != None):
                         format_club.isMember = "N"
                         format_club.isFollower = "N"
                         profileKey = ndb.Key('Profile',int(request.pid))
                         print ("retrieved profile key is ", profileKey)

                         if (profileKey in ret_club.follows):
                             format_club.isFollower = "Y"
                         if (profileKey in ret_club.members):
                             format_club.isMember = "Y"


                   list_of_clubs.list.append(format_club)





        return list_of_clubs
Example #3
0
def getClub(request=None):

    retClub = ClubMiniForm()
    clubKey = ndb.Key('Club', int(request.club_id))
    club = clubKey.get()

    print("The retrieved club is", club)

    collegeidret = club.collegeId
    adminret = club.admin
    print("Admin ret", adminret)

    if club:
        college = CollegeDb.query(
            CollegeDb.collegeId == collegeidret.get().collegeId).fetch(1)

        print("Club id is", club.key.id())
        retClub.club_id = str(club.key.id())
        retClub.admin = adminret.get().name
        retClub.abbreviation = club.abbreviation
        retClub.name = club.name
        retClub.collegeName = college[0].name
        retClub.description = club.description
        retClub.photoUrl = club.photoUrl
        retClub.membercount = str(len(club.members))
        retClub.followercount = str(len(club.follows))

        if (request.pid != None):
            retClub.isMember = "N"
            retClub.isFollower = "N"
            profileKey = ndb.Key('Profile', int(request.pid))
            print("retrieved profile key is ", profileKey)

            if (profileKey in club.follows):
                retClub.isFollower = "Y"
            if (profileKey in club.members):
                retClub.isMember = "Y"

        #print retClub.members
    return retClub
Example #4
0
def getClub(request=None):

    retClub = ClubMiniForm()
    clubKey = ndb.Key("Club", int(request.club_id))
    club = clubKey.get()

    print("The retrieved club is", club)

    collegeidret = club.collegeId
    adminret = club.admin
    print("Admin ret", adminret)

    if club:
        college = CollegeDb.query(CollegeDb.collegeId == collegeidret.get().collegeId).fetch(1)

        print("Club id is", club.key.id())
        retClub.club_id = str(club.key.id())
        retClub.admin = adminret.get().name
        retClub.abbreviation = club.abbreviation
        retClub.name = club.name
        retClub.collegeName = college[0].name
        retClub.description = club.description
        retClub.photoUrl = club.photoUrl
        retClub.membercount = str(len(club.members))
        retClub.followercount = str(len(club.follows))

        if request.pid != None:
            retClub.isMember = "N"
            retClub.isFollower = "N"
            profileKey = ndb.Key("Profile", int(request.pid))
            print("retrieved profile key is ", profileKey)

            if profileKey in club.follows:
                retClub.isFollower = "Y"
            if profileKey in club.members:
                retClub.isMember = "Y"

        # print retClub.members
    return retClub