def post(self, vanity_url=None, operation=None, provider_key=None): provider = db.get_provider_from_vanity_url(vanity_url) if operation == 'invite' : form = ProviderInviteForm().get_form(self.request.POST) if form.validate(): invite = Invite() form.populate_obj(invite) # check if the target email is an existing user target_provider = db.get_provider_from_email(invite.email) if target_provider: # already a member, just make a connection request self.redirect('/%s/connect' % target_provider.vanity_url) else: # new person # associate provider to invite invite.provider = provider.key # create a token for this invite that will be used to pre-populate the signup form invite.token = self.create_token_oldstyle(invite.email) # save invite.put() # create an invite url url_obj = urlparse.urlparse(self.request.url) invite_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/invite/' + invite.token, '', '', '')) logging.info('(ProviderNetworkHandler.post) unique invite URL:' + invite_url) # send the actual email... mail.email_invite(self.jinja2, invite, invite_url) # all good msg = _("Invitation sent to") message = msg + " %s %s" % (invite.first_name, invite.last_name) # new form for next invite provider_invite_form = ProviderInviteForm().get_form() self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form) else: self.render_template("provider/network.html", provider=provider, provider_invite_form=form) else: # post unknown operation provider_invite_form = ProviderInviteForm().get_form() self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)
def get_invite_from_email(email): return Invite.query(Invite.email == email).get()
def fetch_invites(): return Invite.query().order(-Invite.created_on)
def get_invite_from_token(token): return Invite.query(Invite.token == token).get()
def post(self, vanity_url=None, operation=None, provider_key=None): provider = db.get_provider_from_vanity_url(vanity_url) if operation == 'invite': form = ProviderInviteForm().get_form(self.request.POST) if form.validate(): invite = Invite() form.populate_obj(invite) # check if the target email is an existing user target_provider = db.get_provider_from_email(invite.email) if target_provider: # already a member, just make a connection request self.redirect('/%s/connect' % target_provider.vanity_url) else: # new person # associate provider to invite invite.provider = provider.key # create a token for this invite that will be used to pre-populate the signup form invite.token = self.create_token_oldstyle(invite.email) # save invite.put() # create an invite url url_obj = urlparse.urlparse(self.request.url) invite_url = urlparse.urlunparse( (url_obj.scheme, url_obj.netloc, '/invite/' + invite.token, '', '', '')) logging.info( '(ProviderNetworkHandler.post) unique invite URL:' + invite_url) # send the actual email... mail.email_invite(self.jinja2, invite, invite_url) # all good msg = _("Invitation sent to") message = msg + " %s %s" % (invite.first_name, invite.last_name) # new form for next invite provider_invite_form = ProviderInviteForm().get_form() self.render_template( "provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form) else: self.render_template("provider/network.html", provider=provider, provider_invite_form=form) else: # post unknown operation provider_invite_form = ProviderInviteForm().get_form() self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)