Пример #1
0
def createClub(request=None):

        #When createClubRequest is called

        print("Request Entity for Create Club ", request)
        clubRequest = Club_Creation()


        collegeId = ndb.Key('CollegeDb',int(request.college_id))
        college = CollegeDb.query(CollegeDb.key == collegeId).fetch(1)

        college_key = college[0].key



        if request and college :

            for field in ('abbreviation','club_name','from_pid','to_pid','isAlumni','collegeId','description'):


                if field == "abbreviation":
                    clubRequest.abbreviation = request.abbreviation
                elif field == "club_name":
                    clubRequest.club_name = request.club_name
                elif field == "description":
                    clubRequest.description = request.description

                elif field == "from_pid":
                     print("Entered from_pid")
                     profile =  Profile(
                            name = 'SiddharthSend',
                            email = '*****@*****.**',
                            phone = '7760531993',
                            isAlumni='N',
                            collegeId=college_key
                            )
                     profile_key = profile.put()
                     print("Finished frompid")
                     setattr(clubRequest, field, profile_key)
                elif field == "to_pid":
                     print("Entered To PID")
                     profile =  Profile(
                               name = 'SiddharthRec',
                               email = '*****@*****.**',
                               phone = '7760531994',

                               isAlumni='N',
                               collegeId=college_key
                               )
                     profile_key = profile.put()

                     setattr(clubRequest, field, profile_key)
                elif field == "isAlumni":
                     setattr(clubRequest, field, "N")
                elif field == "collegeId":
                     setattr(clubRequest, field, college_key)
            clubRequest.put()

        return clubRequest
Пример #2
0
   def superAdminFeed(self,request):
       pid = ndb.Key('Profile',int(request.pid))
       collegeId = ndb.Key('CollegeDb',int(request.collegeId))
       profile = pid.get()
       college = collegeId.get()
       list1=[]
       if collegeId in profile.superadmin:
           query = Club_Creation.query(Club_Creation.to_pid==pid).order(Club_Creation.timestamp)
           for x in query:
             list1.append(copyToSuperAdminList(x))
            

       return SuperAdminFeedResponse(items=list1)
Пример #3
0
def createClub(request=None):

    #When createClubRequest is called

    print("Request Entity for Create Club ", request)
    clubRequest = Club_Creation()

    collegeId = ndb.Key('CollegeDb', int(request.college_id))
    college = CollegeDb.query(CollegeDb.key == collegeId).fetch(1)

    college_key = college[0].key

    if request and college:

        for field in ('abbreviation', 'club_name', 'from_pid', 'to_pid',
                      'isAlumni', 'collegeId', 'description',
                      'approval_status', 'photoUrl', 'timestamp'):

            if field == "abbreviation":
                clubRequest.abbreviation = request.abbreviation
            elif field == "club_name":
                clubRequest.club_name = request.club_name
            elif field == "description":
                clubRequest.description = request.description

            elif field == "from_pid":
                profile_key = ndb.Key('Profile', int(request.from_pid))
                print("Finished frompid")
                setattr(clubRequest, field, profile_key)
            elif field == "to_pid":
                '''print("Entered To PID")
                     profile =  Profile(
                               name = 'SiddharthRec',
                               email = '*****@*****.**',
                               phone = '7760531994',
                               isAlumni='N',
                               collegeId=college_key
                               )'''
                #get the college of the from_pid guy
                #Get the email of the college
                #correspond it to the SUP profile
                #get his key and save it

                from_pid_key = ndb.Key('Profile', int(request.from_pid))
                from_profile = from_pid_key.get()

                print("From Profile is", from_profile)
                college_key = from_profile.collegeId
                college = college_key.get()

                email = college.sup_emailId

                print("Email is", email)

                query = Profile.query(Profile.email == email).fetch(1)

                if (query[0]):
                    to_pid_key = query[0].key
                    print("to_pid_key", to_pid_key)
                    setattr(clubRequest, field, to_pid_key)
            elif field == "isAlumni":
                setattr(clubRequest, field, "N")
            elif field == "collegeId":
                setattr(clubRequest, field, college_key)
            elif field == "approval_status":
                setattr(clubRequest, field, "N")
            elif field == "photoUrl":
                if (request.photoUrl):
                    setattr(clubRequest, field, str(request.photoUrl))

            elif field == "timestamp":
                print("Going to enter timestamp")
                setattr(clubRequest, field,
                        dt.datetime.now().replace(microsecond=0))

        clubRequest.put()

    return clubRequest
Пример #4
0
def createClub(request=None):

    # When createClubRequest is called

    print("Request Entity for Create Club ", request)
    clubRequest = Club_Creation()

    collegeId = ndb.Key("CollegeDb", int(request.college_id))
    college = CollegeDb.query(CollegeDb.key == collegeId).fetch(1)

    college_key = college[0].key

    if request and college:

        for field in (
            "abbreviation",
            "club_name",
            "from_pid",
            "to_pid",
            "isAlumni",
            "collegeId",
            "description",
            "approval_status",
            "photoUrl",
            "timestamp",
        ):

            if field == "abbreviation":
                clubRequest.abbreviation = request.abbreviation
            elif field == "club_name":
                clubRequest.club_name = request.club_name
            elif field == "description":
                clubRequest.description = request.description

            elif field == "from_pid":
                profile_key = ndb.Key("Profile", int(request.from_pid))
                print("Finished frompid")
                setattr(clubRequest, field, profile_key)
            elif field == "to_pid":
                """print("Entered To PID")
                     profile =  Profile(
                               name = 'SiddharthRec',
                               email = '*****@*****.**',
                               phone = '7760531994',
                               isAlumni='N',
                               collegeId=college_key
                               )"""
                # get the college of the from_pid guy
                # Get the email of the college
                # correspond it to the SUP profile
                # get his key and save it

                from_pid_key = ndb.Key("Profile", int(request.from_pid))
                from_profile = from_pid_key.get()

                print("From Profile is", from_profile)
                college_key = from_profile.collegeId
                college = college_key.get()

                email = college.sup_emailId

                print("Email is", email)

                query = Profile.query(Profile.email == email).fetch(1)

                if query[0]:
                    to_pid_key = query[0].key
                    print("to_pid_key", to_pid_key)
                    setattr(clubRequest, field, to_pid_key)
            elif field == "isAlumni":
                setattr(clubRequest, field, "N")
            elif field == "collegeId":
                setattr(clubRequest, field, college_key)
            elif field == "approval_status":
                setattr(clubRequest, field, "N")
            elif field == "photoUrl":
                if request.photoUrl:
                    setattr(clubRequest, field, str(request.photoUrl))

            elif field == "timestamp":
                print("Going to enter timestamp")
                setattr(clubRequest, field, dt.datetime.now().replace(microsecond=0))

        clubRequest.put()

    return clubRequest