def get(self):
     if not self.is_logged_in():
         self.redirect(LOGIN_PAGE_URL)
     else:
         
         customer = Customer.get_by_key_name(self.get_current_username())
         if customer.has_active_activation_credentials():            
             from activation import generate_deactivation_entry_code
             from pytz.gae import pytz
             deactivation_entry_code = generate_deactivation_entry_code(timezone=customer.timezone)
             self.render('deinstall_maths_english.html', 
                 default_timezone=customer.timezone,
                 deactivation_entry_code=deactivation_entry_code,
                 timezones=pytz.all_timezones)
         else:
             self.render('deinstall_no_active_subscriptions.html')
    def post(self):
        from activation import generate_deactivation_entry_code

        timezone = self.get_argument('timezone')
        
        customer = Customer.get_by_key_name(self.get_current_username())
        customer.timezone = timezone
        customer.put()
        
        deactivation_entry_code = generate_deactivation_entry_code(timezone=timezone)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({
            'deactivationEntryCode': deactivation_entry_code,
            'timezone': timezone,
        }))