def get(self): if self.logged_in: user = self.current_user; attacks = user.get_attacks_as_dict() if len(attacks) > 0: self.response.out.write(simplejson.dumps(generate_statistics_from_events(attacks))) else: self.response.out.write(simplejson.dumps({})) else: self.response.out.write(simplejson.dumps({}))
def get(self): if self.logged_in: user = self.current_user attacks = user.get_attacks_as_dict() if len(attacks) > 0: self.response.out.write( simplejson.dumps(generate_statistics_from_events(attacks))) else: self.response.out.write(simplejson.dumps({})) else: self.response.out.write(simplejson.dumps({}))
def show_main(self, user): response = {} attacks = user.get_attacks_as_dict() response['data'] = simplejson.dumps(generate_statistics_from_events(attacks)) response['web_debug'] = Configuration.get_instance().web_debug response['share_report'] = user.share_report_key response['share_report_and_list'] = user.share_report_and_list_key response['logout_url'] = self.get_logout() response['show_logout'] = True response['show_add'] = True response['show_options'] = True response['show_list'] = True response['user'] = user path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/main.html') self.response.out.write(template.render(path, response))
def get(self): events = self.get_example_attacks() response = generate_statistics_from_events(events) response['web_debug'] = Configuration.get_instance().web_debug response['show_logout'] = False response['share_report'] = "example_report" response['share_report_and_list'] = "example_report_and_list" response['show_add'] = True response['show_options'] = True response['show_list'] = True response['example'] = True response['user'] = {'name': 'Example User', 'provider_name': 'Google+'} response['data'] = simplejson.dumps(response) path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/main.html') self.response.out.write(template.render(path, response))
def show_main(self, user): response = {} attacks = user.get_attacks_as_dict() response['data'] = simplejson.dumps( generate_statistics_from_events(attacks)) response['web_debug'] = Configuration.get_instance().web_debug response['share_report'] = user.share_report_key response['share_report_and_list'] = user.share_report_and_list_key response['logout_url'] = self.get_logout() response['show_logout'] = True response['show_add'] = True response['show_options'] = True response['show_list'] = True response['user'] = user path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/main.html') self.response.out.write(template.render(path, response))
def get(self): matches = re.match(r"/shared/(?P<key>[0-9a-z_]+)/.*", self.request.path) if matches: shared_link = matches.group("key") response = {} attacks = None if len(shared_link) == 7: # Report with List acc = User.get_account_from_share_link_report_and_list( shared_link) response['show_list'] = True attacks = acc.get_attacks_as_dict() if len(shared_link) == 8: # Report only acc = User.get_account_from_share_link_report_only(shared_link) response['show_list'] = False attacks = acc.get_attacks_as_dict() if shared_link == "example_report": response['show_list'] = False attacks = Example.get_example_attacks() if shared_link == "example_report_and_list": response['show_list'] = True attacks = Example.get_example_attacks() if attacks is not None: if len(attacks) > 0: response['data'] = simplejson.dumps( generate_statistics_from_events(attacks)) else: response['data'] = {} response['show_logout'] = False response['show_add'] = False response['show_options'] = False response['shared'] = True response['web_debug'] = Configuration.get_instance().web_debug path = os.path.join( os.path.join(os.path.dirname(__file__), 'html'), '../../templates/main.html') self.response.out.write(template.render(path, response)) else: template_values = { 'status': '404 - Not found', 'title': 'What a headache!', 'message': "Sorry, we couldn't find what you're looking for." } self.response.status = 404 path = os.path.join( os.path.join(os.path.dirname(__file__), 'html'), '../../templates/error.html') self.response.out.write(template.render(path, template_values)) else: template_values = { 'status': '404 - Not found', 'title': 'What a headache!', 'message': "Sorry, we couldn't find what you're looking for." } self.response.status = 404 path = os.path.join( os.path.join(os.path.dirname(__file__), 'html'), '../../templates/error.html') self.response.out.write(template.render(path, template_values))
def get(self): matches = re.match( r"/shared/(?P<key>[0-9a-z_]+)/.*", self.request.path) if matches: shared_link = matches.group("key") response = {} attacks = None if len(shared_link) == 7: # Report with List acc = User.get_account_from_share_link_report_and_list(shared_link) response['show_list'] = True attacks = acc.get_attacks_as_dict() if len(shared_link) == 8: # Report only acc = User.get_account_from_share_link_report_only(shared_link) response['show_list'] = False attacks = acc.get_attacks_as_dict() if shared_link == "example_report": response['show_list'] = False attacks = Example.get_example_attacks() if shared_link == "example_report_and_list": response['show_list'] = True attacks = Example.get_example_attacks() if attacks is not None: if len(attacks) > 0: response['data'] = simplejson.dumps(generate_statistics_from_events(attacks)) else: response['data'] = {} response['show_logout'] = False response['show_add'] = False response['show_options'] = False response['shared'] = True response['web_debug'] = Configuration.get_instance().web_debug path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/main.html') self.response.out.write(template.render(path, response)) else: template_values = {'status': '404 - Not found', 'title': 'What a headache!', 'message': "Sorry, we couldn't find what you're looking for."} self.response.status = 404 path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/error.html') self.response.out.write(template.render(path, template_values)) else: template_values = {'status': '404 - Not found', 'title': 'What a headache!', 'message': "Sorry, we couldn't find what you're looking for."} self.response.status = 404 path = os.path.join(os.path.join(os.path.dirname(__file__), 'html'), '../../templates/error.html') self.response.out.write(template.render(path, template_values))