def createClubRequest(self, request): collegeId = ndb.Key('CollegeDb',int(request.college_id)) print("Required College ID",collegeId) college_ret = collegeId.get() print("College Ret",college_ret) if(college_ret): club_ret = Club.query(Club.name == request.club_name).filter(Club.abbreviation == request.abbreviation).filter(Club.collegeId == college_ret.key).fetch(1) print("Club Ret",club_ret) if(len(club_ret) == 0): clubRequest = createClub(request) currentProfile = clubRequest.to_pid.get() newNotif = Notifications( clubName = clubRequest.club_name, clubphotoUrl = clubRequest.photoUrl, to_pid = clubRequest.to_pid, type = "Club Creation Request", timestamp = dt.datetime.now().replace(microsecond = 0) ) print("Notification to be inserted in club creation request",newNotif) newNotifKey = newNotif.put() data = {'message': clubRequest.club_name,"title": "Creation Request"} print (data) gcmId = currentProfile.gcmId gcm_message = GCMMessage(gcmId, data) gcm_conn = GCMConnection() gcm_conn.notify_device(gcm_message) print("Finished the clubRequest") return message_types.VoidMessage()
def createClubRequest(self, request): collegeId = ndb.Key('CollegeDb',int(request.college_id)) college_ret = CollegeDb.query(CollegeDb.key == collegeId).fetch(1) print("College Ret",college_ret[0]) if(college_ret): club_ret = Club.query(Club.name == request.club_name).filter(Club.abbreviation == request.abbreviation).filter(Club.collegeId == college_ret[0].key).fetch(1) print("Club Ret",club_ret) if(len(club_ret) == 0): clubRequest = createClub(request) print("Finished the clubRequest") '''newClub = createClubAfterApproval(clubRequest) print ("The new club is",newClub) #retClub = self.getClub(newClub)''' return message_types.VoidMessage()