def get(self): one_month_ago = datetime.datetime.now() - datetime.timedelta(days=30) old_pending_requests = MeetingRequest.query( MeetingRequest.state == 'pending' and MeetingRequest.created < one_month_ago ).order(MeetingRequest.created).fetch(100) users_notified = set() for request in old_pending_requests: parent_key = request.key.parent() if parent_key not in users_notified: users_notified.add(parent_key) user_email = parent_key.get().email self.send_notification_email_user(user_email)
def get(self): one_month_ago = datetime.datetime.now() - datetime.timedelta(days=30) old_pending_requests = MeetingRequest.query( MeetingRequest.state == 'pending' and MeetingRequest.created < one_month_ago).order( MeetingRequest.created).fetch(100) users_notified = set() for request in old_pending_requests: parent_key = request.key.parent() if parent_key not in users_notified: users_notified.add(parent_key) user_email = parent_key.get().email self.send_notification_email_user(user_email)
def meetingFinished(self): # Email information sender_address = 'Lunch Mate <*****@*****.**>' subject = 'How was your meeting' body = 'Rate your last meeting!' # Get the message from pub/sub message = json.loads(urllib.unquote(self.request.body).rstrip('=')) message_data = base64.b64decode(str(message['message']['data'])) attributes = message['message']['attributes'] if len(attributes) == 0: return meeting_id = attributes['meeting_id'] # Get all accepted meeting requests query = MeetingRequest.for_meeting(int(meeting_id), 'accepted') for request in query: attendee = request.key.parent().get() if attendee is not None and mail.is_email_valid(attendee.email): mail.send_mail(sender_address, attendee.email, subject, body)