def get(self, uuid): invite = InviteCode.gql("WHERE uuid=:1", uuid).get() if invite == None: logging.error("invite not found: " + uuid) self.error(500) return if self.currentuser == None: self.currentuser = UserInfo(user=users.get_current_user()) self.currentuser.put() relationship = GroupUserInfo.gql("WHERE user=:1 AND group=:2", self.currentuser, invite.group).get() if relationship == None: relationship = GroupUserInfo(user=self.currentuser, group=invite.group, groupname=invite.group.shortname) relationship.put() invite.delete() if is_empty(self.currentuser.nickname): self.render('edit_profile') return self.redirect('/' + invite.group.shortname)
def get(self): threshold = datetime.now() - timedelta(1) keys = ReplyTo.all().filter('date <', threshold) count = keys.count() db.delete(keys) logging.info('Daily cronjob: deleted %d ReplyTo entitite(s).' % count) threshold = datetime.now() - timedelta(90) keys = InviteCode.all().filter('created <', threshold) count = keys.count() db.delete(keys) logging.info('Daily cronjob: deleted %d InviteCode entitie(s).' % count)
def post(self): email_address = cgi.escape(self.request.get('email')) if not is_email_valid(email_address): self.render("invite", {'notification': 'invalid email address'}) invite = InviteCode(uuid=uuid4().hex, group=self.currentgroup) invite_link = "http://www.lunchdiscussion.com/invite/" + invite.uuid email = mail.EmailMessage(sender="*****@*****.**") email.subject = "%s invited you to Lunchdiscussion.com" % self.currentuser.nickname email.body = """%s invited you to join the "%s" group on Lunchdiscussion.com follow this link: %s to join the group.""" % (self.currentuser.nickname, self.currentgroup.fullname, invite_link) email.to = email_address #email.to = "paul <*****@*****.**>" email.send() invite.put() logging.info(invite_link) self.render('invite', notification='invite sent to %s!' % email_address)