def view(request): available_projects = request.registry.settings['projects'] selected_project = get_selected_project(request) error_id = request.matchdict['id'] try: error = Error.objects(project=selected_project['id']).with_id(error_id) except: return HTTPNotFound() if request.user not in error.seenby: error.seenby.append(request.user) error.save() params = { 'error': error, 'selected_project': selected_project, 'available_projects': available_projects } try: template = 'error-view/' + str(error['language']).lower() + '.html' return render_to_response(template, params) except: template = 'error-view/generic.html' return render_to_response(template, params)
def view(request): project = get_selected_project(request) error_id = request.matchdict['id'] try: error = Error.objects(project=project.token, id=error_id).get() except: return HTTPNotFound() error.mark_seen(request.user) error.save() instances = ErrorInstance.objects(hash=error.hash)[:10] params = { 'error': error, 'selected_project': project, 'available_projects': Project.objects(), 'instances': instances, 'github': GithubLinker(project.github) } try: template = 'error-view/' + str(error['language']).lower() + '.html' return render_to_response(template, params) except: template = 'error-view/generic.html' return render_to_response(template, params)
def view(request): available_projects = request.registry.settings['projects'] selected_project = get_selected_project(request) error_id = request.matchdict['id'] try: error = Error.objects().with_id(error_id) except: return HTTPNotFound() if request.user not in error.seenby: error.seenby.append(request.user) error.save() instances = ErrorInstance.objects(hash=error.hash)[:10] params = { 'error': error, 'selected_project': selected_project, 'available_projects': available_projects, 'instances': instances } try: template = 'error-view/' + str(error['language']).lower() + '.html' return render_to_response(template, params) except: template = 'error-view/generic.html' return render_to_response(template, params)
def mass(request): error_ids = request.matchdict['ids'].split(',') action = request.matchdict['action'] project = get_selected_project(request) try: for error_id in error_ids: error = Error.objects(project=project.token, id=error_id).get() if action == 'claim': error.claim(request.user) elif action == 'unclaim': error.remove_claim() elif action == 'resolve': error.resolve(request.user) elif action == 'unresolve': error.unresolve() elif action == 'markseen': error.mark_seen(request.user) elif action == 'markunseen': error.mark_unseen(request.user) else: raise Exception('Unknown action: ' + action) error.save() return {'type': 'success'} except Exception, e: return { 'type': 'failure', 'reason': e }
def view(request): available_projects = request.registry.settings['projects'] selected_project = get_selected_project(request) error_id = request.matchdict['id'] try: error = Error.objects(project=selected_project['id']).with_id(error_id) except: return HTTPNotFound() comment_schema = CommentsSchema() comment_form = Form(comment_schema, buttons=('submit',), formid="comment_form") tag_schema = TagSchema() tag_form = Form(tag_schema, buttons=('submit',), formid="tag_form") if 'submit' in request.POST: form_id = request.POST['__formid__'] controls = request.POST.items() if form_id == 'comment_form': try: values = comment_form.validate(controls) error.comments.append(Comment( author=request.user, content=values['comment'], created=int(time()) )) error.save() url = request.route_url('error_view', project=selected_project['id'], id=error_id) return HTTPFound(location=url) except ValidationFailure, e: comment_form_render = e.render() elif form_id == 'tag_form': try: values = tag_form.validate(controls) # build a list of comma seperated, non empty tags tags = [t.strip() for t in values['tag'].split(',') if t.strip() != ''] changed = False for tag in tags: if tag not in error.tags: error.tags.append(tag) changed = True Tag.create(tag).save() if changed: error.save() url = request.route_url('error_view', project=selected_project['id'], id=error_id) return HTTPFound(location=url) except ValidationFailure, e: tag_form_render = e.render()
def log(request): get_params = dict(request.GET) try: msg = json.loads(base64.b64decode(get_params['data'])) msg = _format_backtrace(msg) error = Error.create_from_msg(msg) error.save() except: return {'success': False} return {'success': True}
def toggle_hide(request): error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) error.hiddenby = None if error.hiddenby else request.user error.save() url = request.route_url('error_view', project=selected_project['id'], id=error_id) return HTTPFound(location=url) except: return HTTPNotFound()
def log(request): available_projects = request.registry.settings['projects'] get_params = dict(request.GET) try: msg = json.loads(base64.b64decode(get_params['data'])) msg = _format_backtrace(msg) error = Error.create_from_msg(msg) error.save() except: return {'success': False} return {'success': True}
def comment_add(request): error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) error.comments.append( Comment(author=request.user, content=request.POST.get('comment').strip(), created=int(time()))) error.save() return {'type': 'success'} except: return {'type': 'failure'}
def comment_add(request): error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) error.comments.append(Comment( author=request.user, content=request.POST.get('comment').strip(), created=int(time()) )) error.save() return {'type': 'success'} except: return {'type': 'failure'}
def toggle_resolve(request): error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) if error.hiddenby and error.hiddenby != request.user: return {'type': 'failure'} error.hiddenby = None if error.hiddenby else request.user error.save() return {'type': 'success'} except: return {'type': 'failure'}
def tag_remove(request): tag = request.matchdict['tag'] error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) if tag not in error.tags: return {'type': 'failure'} error.tags.remove(tag) error.save() Tag.removeOne(tag) return {'type': 'success'} except: return {'type': 'failure'}
def tag_add(request): tag = request.matchdict['tag'] error_id = request.matchdict['id'] selected_project = get_selected_project(request) try: error = Error.objects(project=selected_project['id']).with_id(error_id) if tag in error.tags: return {'type': 'failure'} error.tags.append(tag) error.save() Tag.create(tag).save() return {'type': 'success'} except: return {'type': 'failure'}
def toggle_resolve(request): error_id = request.matchdict['id'] project = get_selected_project(request) try: error = Error.objects(project=project.token, id=error_id).get() if error.is_resolved(): error.unresolve() else: error.resolve(request.user) error.save() return {'type': 'success'} except: return {'type': 'failure'}