コード例 #1
0
ファイル: ProfileAPI_v1.py プロジェクト: RJJ11/SAMPLE
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 == 'clubNames':
                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.adminName = ret_club.admin.get().name
                    format_club.collegeName = ret_club.collegeId.get().name
                    format_club.description = ret_club.description
                    format_club.clubId = str(ret_club.key.id())
                    pylist.append(format_club)
                setattr(pf, field.name, pylist)

            if field.name == 'followsNames':
                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
コード例 #2
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=='clubNames':
                    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.adminName = ret_club.admin.get().name
                        format_club.collegeName = ret_club.collegeId.get().name
                        format_club.description = ret_club.description
                        format_club.clubId = str(ret_club.key.id())
                        pylist.append(format_club)
                    setattr(pf, field.name, pylist)

                if field.name=='followsNames':
                    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
コード例 #3
0
ファイル: ClubAPI_v1.py プロジェクト: sid-reddevil1803/SAMPLE
def getClub(request=None):

        retClub = ClubMiniForm()
        clubKey = ndb.Key('Club',int(request.clubId))
        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.clubId = str(club.key.id())
             retClub.adminName = 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
コード例 #4
0
ファイル: ClubAPI_v1.py プロジェクト: RJJ11/SAMPLE
def getClub(request=None):

    retClub = ClubMiniForm()
    clubKey = ndb.Key('Club', int(request.clubId))
    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.clubId = str(club.key.id())
        retClub.adminName = 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