def get (self): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return if not UserManager.is_admin(): self.redirect('/') return template = JINJA_ENVIRONMENT.get_template('templates/users/users.html') def is_user_admin(user): values = sorted(values, key=lambda r: r.value, reverse=True) remapped_values = itertools.groupby(values, key=lambda v: v.type) return remapped_values JINJA_ENVIRONMENT.filters['is_user_admin'] = is_user_admin self.response.write(template.render({ 'users': User.query(), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Users" }] }))
def get (self, url): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return if (url == '' or os.path.isdir('help/%s' % url)): url += 'index.md' template = JINJA_ENVIRONMENT.get_template('templates/help/help.html') help_file_path = 'help/%s' % re.sub('html$', 'md', url) if not os.path.exists(help_file_path): print help_file_path return with codecs.open(help_file_path, 'r', 'utf-8') as md_file: help_file = md_file.read() self.response.write(template.render({ 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Help" }], 'help': markdown.markdown(help_file, extensions=['markdown.extensions.fenced_code']) }))
def get(self, key): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return project = Project.get_by_id(int(key)) if project == None: self.redirect('/') return if not UserManager.get_user_has_privilege_for_operation(project): self.redirect('/') return project_key = ndb.Key(Project, int(key)) template_path = 'templates/project/action.html' data = { 'project_key': key, 'project_secret': project.secret, 'logs': Log.query(ancestor=project_key).order(-Log.date).fetch(5), 'actions': Action.query(ancestor=project_key).order(Action.name), 'action_upload_url': blobstore.create_upload_url('/action/import'), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Projects", "url": "/project/list" }, { "name": project.name }] } template = JINJA_ENVIRONMENT.get_template(template_path) self.response.write(template.render(data))
def get(self): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return template = JINJA_ENVIRONMENT.get_template('templates/project/project.html') self.response.write(template.render({ 'projects': Project.query(), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Projects" }] }))
def get(self): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return template = JINJA_ENVIRONMENT.get_template( 'templates/project/project.html') self.response.write( template.render({ 'projects': Project.query(), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Projects" }] }))
def get(self, key): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return project = Project.get_by_id(int(key)) if project == None: self.redirect('/') return if not UserManager.get_user_has_privilege_for_operation(project): self.redirect('/') return project_key = ndb.Key(Project, int(key)) template_path = 'templates/project/action.html' data = { 'project_key': key, 'project_secret': project.secret, 'logs': Log.query(ancestor=project_key).order(-Log.date).fetch(5), 'actions': Action.query(ancestor=project_key).order(Action.name), 'action_upload_url': blobstore.create_upload_url('/action/import'), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Projects", "url": "/project/list" },{ "name": project.name }] } template = JINJA_ENVIRONMENT.get_template(template_path) self.response.write(template.render(data))
def get(self, url): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return if (url == '' or os.path.isdir('help/%s' % url)): url += 'index.md' template = JINJA_ENVIRONMENT.get_template('templates/help/help.html') help_file_path = 'help/%s' % re.sub('html$', 'md', url) if not os.path.exists(help_file_path): print help_file_path return with codecs.open(help_file_path, 'r', 'utf-8') as md_file: help_file = md_file.read() self.response.write( template.render({ 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'sections': [{ "name": "Help" }], 'help': markdown.markdown( help_file, extensions=['markdown.extensions.fenced_code']) }))
def get(self, url): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return search = re.search('^([0-9A-Za-z\-]+)/([0-9A-Za-z\-]+)/(json)?', url) project_key_string = search.group(1) action_key_string = search.group(2) is_json = (search.group(3) == 'json') action_key = ndb.Key( Project, int(project_key_string), ) action_detail_key = ndb.Key(Project, int(project_key_string), Action, int(action_key_string)) project = Project.get_by_id(int(project_key_string)) if not UserManager.get_user_has_privilege_for_operation(project): self.redirect('/') return action = Action.get_by_id(int(action_key_string), parent=action_key) if (action == None): self.redirect('/project/%s/' % project_key_string) return template_path = 'templates/project/action-detail.html' if (is_json): template_path = 'templates/_endpoints/chart-data.json' actions = ActionDetail.query( ancestor=action_detail_key).order(-ActionDetail.date) data = { 'action_name': action.name, 'action_type': action.type, 'action_label': action.label, 'action_x_axis': action.x_axis, 'action_y_axis': action.y_axis, 'action_y_axis_max': action.y_axis_max, 'action_upload_url': blobstore.create_upload_url('/action/import'), 'action_key': action_key_string, 'project_key': project_key_string, 'project_secret': project.secret, 'actions': actions, 'can_use_speed_index': all(a.speed_index > -1 for a in actions), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'data_url': '/project/' + url + 'json', 'sections': [{ "name": "Projects", "url": "/project/list" }, { "name": project.name, "url": "/project/%s/" % project_key_string }, { "name": action.name }] } def remap_extended_info(values): remapped_values = {} for v in values: if v.type not in remapped_values: remapped_values[v.type] = [] try: value = { 'name': v.name, 'type': v.type, 'value': float(v.value) } except Exception, e: if value == None: value = 0.0 # print v remapped_values[v.type].append(value) if 'JavaScript' in remapped_values: remapped_values['JavaScript'] = (sorted( remapped_values['JavaScript'], key=lambda r: float(r['value']), reverse=True)) return remapped_values
def get (self, url): if UserManager.get_current_user() == None: self.redirect('/user-not-found') return search = re.search('^([0-9A-Za-z\-]+)/([0-9A-Za-z\-]+)/(json)?', url) project_key_string = search.group(1) action_key_string = search.group(2) is_json = (search.group(3) == 'json') action_key = ndb.Key( Project, int(project_key_string), ) action_detail_key = ndb.Key( Project, int(project_key_string), Action, int(action_key_string) ) project = Project.get_by_id(int(project_key_string)) if not UserManager.get_user_has_privilege_for_operation(project): self.redirect('/') return action = Action.get_by_id(int(action_key_string), parent=action_key) if (action == None): self.redirect('/project/%s/' % project_key_string) return template_path = 'templates/project/action-detail.html' if (is_json): template_path = 'templates/_endpoints/chart-data.json' actions = ActionDetail.query(ancestor=action_detail_key).order( -ActionDetail.date) data = { 'action_name': action.name, 'action_type': action.type, 'action_label': action.label, 'action_x_axis': action.x_axis, 'action_y_axis': action.y_axis, 'action_y_axis_max': action.y_axis_max, 'action_upload_url': blobstore.create_upload_url('/action/import'), 'action_key': action_key_string, 'project_key': project_key_string, 'project_secret': project.secret, 'actions': actions, 'can_use_speed_index': all(a.speed_index > -1 for a in actions), 'sign_out_url': UserManager.get_signout_url(), 'gravatar_url': UserManager.get_gravatar_url(), 'user_email': UserManager.get_email(), 'user_is_admin': UserManager.is_admin(), 'data_url': '/project/' + url + 'json', 'sections': [{ "name": "Projects", "url": "/project/list" },{ "name": project.name, "url": "/project/%s/" % project_key_string }, { "name": action.name }] } def remap_extended_info(values): remapped_values = {} for v in values: if v.type not in remapped_values: remapped_values[v.type] = [] try: value = { 'name': v.name, 'type': v.type, 'value': float(v.value) } except Exception, e: if value == None: value = 0.0 # print v remapped_values[v.type].append(value) if 'JavaScript' in remapped_values: remapped_values['JavaScript'] = ( sorted(remapped_values['JavaScript'], key=lambda r: float(r['value']), reverse=True) ) return remapped_values