def joinClubApi(self,request): if request: clubKey = ndb.Key('Club',int(request.club_id)) club = clubKey.get() profileKey = ndb.Key('Profile',int(request.from_pid)) profile = profileKey.get() if (club and profile and profileKey not in club.members): joinCreationObj = Join_Creation() joinCreationObj.from_pid = profileKey joinCreationObj.to_pid = club.admin to_pidProfile = joinCreationObj.to_pid.get() joinCreationObj.club_id = clubKey joinCreationObj.timestamp = dt.datetime.now().replace(microsecond = 0) print("join obj",joinCreationObj) joinCreationObjKey = joinCreationObj.put() newNotif = Notifications( clubName = club.name, clubId = club.key, clubphotoUrl = club.photoUrl, to_pid = joinCreationObj.to_pid, type = "Join Request", timestamp = joinCreationObj.timestamp ) print("Notification to be inserted in join approval",newNotif) newNotifKey = newNotif.put() data = {'message': profile.name + " wishes to join","title": club.name} print (data) gcmId = to_pidProfile.gcmId gcm_message = GCMMessage(gcmId, data) gcm_conn = GCMConnection() gcm_conn.notify_device(gcm_message) return message_types.VoidMessage()