Пример #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
Пример #2
0
   def getClubApi(self,request):
        print("Request entity is",request)
        retClub = ClubMiniForm()
        if request:
             retClub = getClub(request)

        return retClub
Пример #3
0
def _copyProfileToForm(prof):
    pf = ProfileMiniForm()
    for field in pf.all_fields():
        if hasattr(prof, field.name):
            if field.name == 'collegeId':
                collegeId = getattr(prof, field.name)
                print "College Id"
                print collegeId
                setattr(pf, field.name, str(collegeId.id()))
            elif field.name == 'clubsJoined':
                pylist = []
                for x in prof.clubsJoined:
                    pylist.append(str(x.id()))
                    setattr(pf, field.name, pylist)
            elif field.name == 'follows':
                pylist = []
                for x in prof.follows:
                    pylist.append(str(x.id()))
                    setattr(pf, field.name, pylist)
            elif field.name == 'pid':
                setattr(pf, field.name, str(prof.key.id()))
            else:
                setattr(pf, field.name, getattr(prof, field.name))
        else:
            if field.name == 'club_names':
                pylist = []
                for x in prof.clubsJoined:
                    ret_club = x.get()
                    #ret_club = obj.get()
                    format_club = ClubMiniForm()
                    format_club.name = ret_club.name
                    format_club.abbreviation = ret_club.abbreviation
                    format_club.admin = ret_club.admin.get().name
                    format_club.collegeName = ret_club.collegeId.get().name
                    format_club.description = ret_club.description
                    format_club.club_id = str(ret_club.key.id())
                    pylist.append(format_club)
                setattr(pf, field.name, pylist)

            if field.name == 'follows_names':
                pylist = []
                for x in prof.follows:
                    clubs = x.get()
                    pylist.append(clubs.name)
                setattr(pf, field.name, pylist)

            if field.name == 'pid':
                setattr(pf, field.name, str(prof.key.id()))

    pf.check_initialized()
    return pf
Пример #4
0
def _copyProfileToForm(prof):
        pf = ProfileMiniForm()
        for field in pf.all_fields():
            if hasattr(prof, field.name):
                if field.name=='collegeId':
                    collegeId=getattr(prof,field.name)
                    print "College Id"
                    print collegeId
                    setattr(pf,field.name,str(collegeId.id()))
                elif field.name=='clubsJoined':
                    pylist=[]
                    for x in prof.clubsJoined:
                        pylist.append(str(x.id()))
                        setattr(pf, field.name, pylist)
                elif field.name=='follows':
                    pylist=[]
                    for x in prof.follows:
                        pylist.append(str(x.id()))
                        setattr(pf, field.name, pylist)
                elif field.name=='pid':
                    setattr(pf, field.name, str(prof.key.id()))
                else:
                    setattr(pf, field.name, getattr(prof, field.name))
            else:
                if field.name=='club_names':
                    pylist=[]
                    for x in prof.clubsJoined:
                        ret_club = x.get()
                        #ret_club = obj.get()
                        format_club = ClubMiniForm()
                        format_club.name = ret_club.name
                        format_club.abbreviation = ret_club.abbreviation
                        format_club.admin = ret_club.admin.get().name
                        format_club.collegeName = ret_club.collegeId.get().name
                        format_club.description = ret_club.description
                        format_club.club_id = str(ret_club.key.id())
                        pylist.append(format_club)
                    setattr(pf, field.name, pylist)

                if field.name=='follows_names':
                    pylist=[]
                    for x in prof.follows:
                        clubs = x.get()
                        pylist.append(clubs.name)
                    setattr(pf, field.name, pylist)

                if field.name=='pid':
                    setattr(pf, field.name, str(prof.key.id()))

        pf.check_initialized()
        return pf
Пример #5
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.admin = ret_club.admin.get().name

                   format_club.collegeName = ret_club.collegeId.get().name

                   format_club.description = ret_club.description

                   format_club.club_id = str(ret_club.key.id())


                   list_of_clubs.list.append(format_club)





        return list_of_clubs
Пример #6
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
        return retClub
Пример #7
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
Пример #8
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
Пример #9
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