Esempio n. 1
0
    def render_GET(self, request):
        # FIXME: escape the short and full names
        productlist = ''.join(['<li><a href="/signup/%s">%s</a>' % (p['short_name'], p['full_name'])
                               for p in self.products if p['listed']])

        tmpl = env.get_template('signup.html')
        request.setResponseCode(200)
        return tmpl.render(productlist=productlist).encode('utf-8')
    def render(self, request):
        print >>self.out, "Yay, another potential customer:", request.args
        email = self.get_arg(request, 'Email')
        productname = self.get_arg(request, 'ProductName')
        productfullname = self.get_arg(request, 'ProductFullName')

        if productname in ACTIVE_PRODUCTS:
            signup_url = SIGNUP_BASE_URL + productname
            valid_email_template = 'valid_email_activeproduct.html'
        else:
            signup_url = None
            valid_email_template = 'valid_email_inactiveproduct.html'

        append_record(self.basefp.child(EMAILS_FILE), email, productname)

        request.setResponseCode(200)

        if email and VALID_EMAIL_RE.match(email):
            tmpl = env.get_template(valid_email_template)
            (start, _, rest) = tmpl.render(productname=productname, productfullname=productfullname).encode('utf-8').partition("MAGIC")
            request.write(start)

            d = defer.succeed(None)
            d.addCallback(lambda ign: send_autoreply(email, productfullname, signup_url))
            def _sent(ign):
                request.write("We've just sent you an email to check that you can receive email from us.")
                request.write(rest)
            def _error(f):
                request.write("We weren't able to send email to the address you provided. This could be a problem on "
                              "our end, but please check the address. We've recorded the address anyway so that we can "
                              "try again manually.")
                request.write(rest)
                print >>self.out, str(f)
            d.addCallbacks(_sent, _error)
            d.addBoth(lambda ign: request.finish())
            def _err(f):
                print >>self.out, str(f)
            d.addErrback(_err)
            return NOT_DONE_YET
        else:
            tmpl = env.get_template('invalid_email.html')
            return tmpl.render(productname=productname, productfullname=productfullname).encode('utf-8')
Esempio n. 3
0
def signed_up(claim, request):
    # Return a page notifying the user that they've been charged and their
    # service is being set up.
    tmpl = env.get_template('payment_verified.html')
    request.write(
        tmpl.render({
            "productfullname": "Simple Secure Storage Service",
            "productname": "S4",
            "activationinfo": claim.describe(env),
        }).encode('utf-8'), )
    request.finish()
    def render(self, request):
        # The expected HTTP method is a POST from the <form> in templates/subscription_signup.html.
        # render_POST is handled by the HandlerBase parent which calls this this method after logging
        # the request.

        # Get information needed to create the new stripe subscription to the S4 plan
        stripe_api_key, stripe_authorization_token, user_email = self.get_creation_parameters(request)
        try:
            # Invoke card charge by requesting subscription to recurring-payment plan.
            customer = self.create_customer(stripe_api_key, stripe_authorization_token, user_email)
        except RenderErrorDetailsForBrowser as e:
            tmpl = env.get_template('s4-subscription-form.html')
            return tmpl.render({"errorblock": e.details}).encode('utf-8', 'replace')

        # Log that a new subscription has been created (at stripe).
        subscriptions_fp = self.basefp.child(SUBSCRIPTIONS_FILE)
        append_record(subscriptions_fp, customer.subscription.id)
        # Initiate the provisioning service
        self.run_full_signup(customer, request)
        # Return the a page notifying the user that they've been charged and their service is being set up.
        tmpl = env.get_template('payment_verified.html')
        return tmpl.render({"productfullname": "Simple Secure Storage Service", "productname":"S4"}).encode('utf-8')
Esempio n. 5
0
    def render(self, request):
        # The expected HTTP method is a POST from the <form> in templates/subscription_signup.html.
        # render_POST is handled by the HandlerBase parent which calls this this method after logging
        # the request.

        if request.method != 'POST':
            tmpl = env.get_template('s4-subscription-form.html')
            msg = (
                "Your browser requested this page with {} but we expected a POST."
                "\n\nPlease try again.".format(request.method))
            return tmpl.render({"errorblock": msg}).encode('utf-8', 'replace')

        # Get information needed to create the new stripe subscription to the S4 plan
        stripe_authorization_token, user_email = self.get_creation_parameters(
            request)
        try:
            # Invoke card charge by requesting subscription to recurring-payment plan.
            customer = self.create_customer(stripe_authorization_token,
                                            user_email)
        except RenderErrorDetailsForBrowser as e:
            tmpl = env.get_template('s4-subscription-form.html')
            return tmpl.render({
                "errorblock": e.details
            }).encode('utf-8', 'replace')

        # Initiate the provisioning service
        subscription = customer.subscriptions.data[0]
        style = (request.getCookie(S4_SIGNUP_STYLE_COOKIE)
                 or "email").decode("ascii")
        signup = self._get_signup(style)
        d = signup.signup(
            customer.email.decode("utf-8"),
            customer.id.decode("utf-8"),
            subscription.id.decode("utf-8"),
            subscription.plan.id.decode("utf-8"),
        )
        d.addCallback(signed_up, request)
        d.addErrback(signup_failed, customer, self._mailer)
        return NOT_DONE_YET
Esempio n. 6
0
 def render_GET(self, request):
     tmpl = env.get_template('products.html')
     request.setResponseCode(200)
     return tmpl.render().encode('utf-8', 'replace')
Esempio n. 7
0
 def render_GET(self, request):
     tmpl = env.get_template('products.html')
     request.setResponseCode(200)
     return tmpl.render().encode('utf-8', 'replace')