def get(self): self.get_current_user() kwargs = dict(self.application.static_kwargs) kwargs['page_name'] = 'mobile_admin' kwargs['config'] = config kwargs['access_level'] = None ## check for logout logout_value = self.get_argument('logout', None) if logout_value == '1': self.clear_cookie('admin_code') self.redirect('/mobile/admin') ## check admin code admin_code = self.get_argument('admin_code', None) if admin_code is None: admin_code = self.get_secure_cookie('admin_code') if admin_code is None: kwargs['admin_status'] = False self.write( self.application.loader.load('mobile/admin.html').generate( **kwargs)) return resource = Resource(self.db, config) results = resource.verify_admin(admin_code) if results['meta']['status'] == 'OK': kwargs['admin_status'] = True kwargs['access_level'] = results['access_level'] kwargs['resource_object'] = results['response'] self.set_secure_cookie('admin_code', admin_code) else: kwargs['admin_status'] = False kwargs['access_level'] = False ## bedcount if kwargs['admin_status'] is True: addbed = self.get_argument('addbed', None) delbed = self.get_argument('delbed', None) if addbed == '1': resource = Resource(self.db, config) results2 = resource.add_bed(admin_code) if delbed == '1': resource = Resource(self.db, config) results2 = resource.del_bed(admin_code) resource = Resource(self.db, config) results = resource.verify_admin(admin_code) kwargs['resource_object'] = results['response'] self.write( self.application.loader.load('mobile/admin.html').generate( **kwargs))
def post(self): self.get_current_user() kwargs = dict(self.application.static_kwargs) kwargs['page_name'] = 'mobile/admin_update' kwargs['config'] = config kwargs['access_level'] = None ## check admin code admin_code = self.get_argument('admin_code', None) if admin_code is None: admin_code = self.get_secure_cookie('admin_code') if admin_code is None: kwargs['admin_status'] = False self.write( self.application.loader.load('mobile/admin.html').generate( **kwargs)) return resource = Resource(self.db, config) results = resource.verify_admin(admin_code) if results['meta']['status'] == 'OK': kwargs['admin_status'] = True kwargs['access_level'] = results['access_level'] kwargs['resource_object'] = results['response'] self.set_secure_cookie('admin_code', admin_code) else: kwargs['admin_status'] = False kwargs['access_level'] = results['access_level'] ## resource update if kwargs['admin_status'] is True: input_data = {} input_data['name_1'] = self.get_argument('name_1', None) input_data['name_2'] = self.get_argument('name_2', None) input_data['street_1'] = self.get_argument('street_1', None) input_data['street_2'] = self.get_argument('street_2', None) input_data['city'] = self.get_argument('city', None) input_data['state'] = self.get_argument('state', None) input_data['zipcode'] = self.get_argument('zipcode', None) input_data['phone'] = self.get_argument('phone', None) input_data['url'] = self.get_argument('url', None) input_data['hours'] = self.get_argument('hours', None) input_data['notes'] = self.get_argument('notes', None) input_data['va_status'] = self.get_argument('va_status', None) input_data['contact_name'] = self.get_argument( 'contact_name', None) input_data['email_address'] = self.get_argument( 'email_address', None) resource = Resource(self.db, config) results = resource.update_resource(admin_code, input_data) self.redirect('/mobile/admin/update')
def get(self): self.get_current_user() kwargs = dict(self.application.static_kwargs) kwargs['page_name'] = 'ios/admin_update' kwargs['config'] = config kwargs['access_level'] = None ## check for logout logout_value = self.get_argument('logout', None) if logout_value == '1': self.clear_cookie('admin_code') self.redirect('/ios/admin') ## check admin code admin_code = self.get_argument('admin_code', None) if admin_code is None: admin_code = self.get_secure_cookie('admin_code') if admin_code is None: kwargs['admin_status'] = False self.write(self.application.loader.load('ios/admin.html').generate(**kwargs)) return resource = Resource(self.db, config) results = resource.verify_admin(admin_code) if results['meta']['status'] == 'OK': kwargs['admin_status'] = True kwargs['access_level'] = results['access_level'] if results['response']['name_2'] is None: results['response']['name_2'] = '' if results['response']['street_2'] is None: results['response']['street_2'] = '' if results['response']['phone'] is None: results['response']['phone'] = '' if results['response']['url'] is None: results['response']['url'] = '' if results['response']['hours'] is None: results['response']['hours'] = '' if results['response']['notes'] is None: results['response']['notes'] = '' kwargs['resource_object'] = results['response'] self.set_secure_cookie('admin_code', admin_code) else: kwargs['admin_status'] = False kwargs['access_level'] = results['access_level'] self.write(self.application.loader.load('ios_admin_update.html').generate(**kwargs))
def post(self): admin_code = self.get_argument('admin_code', None) resource = Resource(self.db, config) self.write(resource.verify_admin(admin_code))