def notification_subscribe_confirmation(code): 

    top_nav = get_top_nav()

    domain_name = None
    domain = None

    try:
        user, domain = user_domain_from_code(code)
        user.confirm_subscription(domain)

        # how to unsubscribe
        longest_downtime, average_downtime = domain.longest_average_downtime_in_past_30_days
        send_mail(
            user.email_address,
            "How to Unsubscribe",
            render_template("email/subscribe_complete.html",
                 domain_name = domain.name,
                 to_address = user.email_address,
                 unsubscribe_url = domain.get_unsubscribe_url(user),
                 site_url = config.site_url,
                 num_of_outages = domain.num_outages_in_past_30_days,
                 longest_outage = "%0.1f"  % longest_downtime,
                 average_downtime = "%0.1f"  % average_downtime,
                 diff = domain.num_outages_in_past_30_days_difference_from_average,
                 month = utils.past_30_days_text()
            ),
            images=[
                ['snapshot', domain.get_thumbnail_url(confirm=False)]
            ]
        )

        if user.new:
            user.new = False
            user.save()
            send_mail(
                user.email_address,
                "Your Account",
                render_template("email/user_account_info.html",
                    site_url = config.site_url,
                    username = user.email_address,
                    password = user.password
                )
            )

        errors = [] 
    except:
        errors = [True]

    return render_template('notification/subscribe_confirmation.html', **locals())        
    def GET(self, code):      
        domain_name = None

        domain = None
        try:
            user, domain = models.user_domain_from_code(code)
            user.confirm_subscription(domain)

            # how to unsubscribe
            longest_downtime, average_downtime = domain.longest_average_downtime_in_past_30_days
            mail.send(
                user.email_address,
                "How to Unsubscribe",
                "email/subscription_complete.tmpl",
                {
                    "domain_name": domain.name,
                    "to_address": user.email_address,
                    "from_address": config.mail['from_address'],
                    "unsubscribe_url": domain.get_unsubscribe_url(user),
                    "site_url": site_url,
                    "num_of_outages": domain.num_outages_in_past_30_days,
                    "longest_outage": "%0.1f" % longest_downtime,
                    "average_downtime": "%0.1f" % average_downtime,
                    "diff": domain.num_outages_in_past_30_days_difference_from_average,
                    "month": utils.past_30_days_text(),
                },
                images=[
                    ['snapshot', domain.get_thumbnail_url(confirm=True)]
                ]
            )
                
            self.page["errors"] = [] 
        except:
            self.page["errors"] = [True]

        self.page["domain,"] = domain
        self.page["breadcrumbs"] = [
            urls["home"],
            urls["signup"],
        ]
    
        return self.render()