def ajax_handler(): op = request.form.get('op') if op == 'poll': filters = [] for filter_ in get_filters(): filters.append(filter_(request)) query = request.args.get('content') is_search = query if is_search: message_list = self.get_search_query_set(query) else: message_list = GroupedMessage.objects.extra( select={ 'score': GroupedMessage.get_score_clause(), } ) if query: # You really shouldnt be doing this message_list = message_list.filter( Q(view__icontains=query) \ | Q(message__icontains=query) \ | Q(traceback__icontains=query) ) sort = request.args.get('sort') if sort == 'date': message_list = message_list.order_by('-last_seen') elif sort == 'new': message_list = message_list.order_by('-first_seen') else: sort = 'priority' if not is_search: message_list = message_list.order_by('-score', '-last_seen') for filter_ in filters: if not filter_.is_set(): continue message_list = filter_.get_query_set(message_list) data = [ (m.pk, { 'html': self.render_to_string('sentry/partial/_group.html', { 'group': m, 'priority': p, 'request': request, }, request), 'count': m.times_seen, 'priority': p, }) for m, p in with_priority(message_list[0:15])] elif op == 'resolve': gid = request.REQUEST.get('gid') if not gid: abort(403) try: group = GroupedMessage.objects.get(pk=gid) except GroupedMessage.DoesNotExist: abort(403) GroupedMessage.objects.filter(pk=group.pk).update(status=1) group.status = 1 if not request.is_ajax(): return redirect(request.environ['HTTP_REFERER']) data = [ (m.pk, { 'html': self.render_to_string('sentry/partial/_group.html', { 'group': m, 'request': request, }, request), 'count': m.times_seen, }) for m in [group]] else: abort(400) return Response(simplejson.dumps(data), mimetype='application/json')
def ajax_handler(): op = request.form.get('op') if op == 'poll': filters = [] for filter_ in filters.all(): filters.append(filter_(request)) event_list = Group.objects sort = request.args.get('sort') if sort == 'date': event_list = event_list.order_by('-last_seen') elif sort == 'new': event_list = event_list.order_by('-first_seen') elif sort == 'count': event_list = event_list.order_by('-count') else: sort = 'priority' event_list = event_list.order_by('-score') # for filter_ in filters: # if not filter_.is_set(): # continue # event_list = filter_.get_query_set(event_list) data = [ (m.pk, { 'html': render_template('sentry/partial/group.html', **{ 'group': m, 'priority': p, 'request': request, }), 'count': m.times_seen, 'priority': p, }) for m, p in with_priority(event_list[0:15])] elif op == 'resolve': gid = request.REQUEST.get('gid') if not gid: abort(403) try: group = Group.objects.get(pk=gid) except Group.DoesNotExist: abort(403) group.update(status=1) if not request.is_ajax(): return redirect(request.environ['HTTP_REFERER']) data = [ (m.pk, { 'html': render_template('sentry/partial/group.html', **{ 'group': m, 'request': request, }), 'count': m.times_seen, }) for m in [group]] else: abort(400) return Response(simplejson.dumps(data), mimetype='application/json')
def delete(self, request, *args, **kwargs): key = self.get_key() key.delete() if request.is_ajax(): return "Key {} deleted".format(key.urlsafe()), 204 return redirect(self.get_next())
def ajax_handler(): op = request.form.get("op") if op == "poll": filters = [] for filter_ in get_filters(): filters.append(filter_(request)) event_list = Group.objects sort = request.args.get("sort") if sort == "date": event_list = event_list.order_by("-last_seen") elif sort == "new": event_list = event_list.order_by("-first_seen") elif sort == "count": event_list = event_list.order_by("-count") else: sort = "priority" event_list = event_list.order_by("-score") # for filter_ in filters: # if not filter_.is_set(): # continue # event_list = filter_.get_query_set(event_list) data = [ ( m.pk, { "html": render_template( "sentry/partial/group.html", **{"group": m, "priority": p, "request": request} ), "count": m.times_seen, "priority": p, }, ) for m, p in with_priority(event_list[0:15]) ] elif op == "resolve": gid = request.REQUEST.get("gid") if not gid: abort(403) try: group = Group.objects.get(pk=gid) except Group.DoesNotExist: abort(403) group.update(status=1) if not request.is_ajax(): return redirect(request.environ["HTTP_REFERER"]) data = [ ( m.pk, { "html": render_template("sentry/partial/group.html", **{"group": m, "request": request}), "count": m.times_seen, }, ) for m in [group] ] else: abort(400) return Response(simplejson.dumps(data), mimetype="application/json")