forked from allegro/ralph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect on graph click (allegro#2999)
- Loading branch information
xliiv
authored
Mar 31, 2017
1 parent
ded7f0e
commit 9c79164
Showing
7 changed files
with
151 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django.contrib import admin | ||
from django.shortcuts import get_object_or_404 | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from ralph.dashboards.models import Graph | ||
from ralph.dashboards.renderers import GRAPH_QUERY_SEP | ||
|
||
|
||
class ByGraphFilter(admin.SimpleListFilter): | ||
title = _('Graph ID') | ||
parameter_name = 'graph-query' | ||
sep = GRAPH_QUERY_SEP | ||
template = 'admin/filters/by-graph.html' | ||
|
||
def lookups(self, request, model_admin): | ||
return ( | ||
('', ''), | ||
) | ||
|
||
def tokenize(self, query_value): | ||
return query_value.split(self.sep) if self.sep in query_value else ( | ||
None, None | ||
) | ||
|
||
def queryset(self, request, queryset): | ||
graph_pk, graph_item = self.tokenize(self.value() or '') | ||
if graph_pk and graph_item: | ||
graph = get_object_or_404(Graph, pk=graph_pk) | ||
queryset = graph.apply_parital_filtering(queryset) | ||
queryset = queryset.filter( | ||
**{graph.params['labels']: graph_item} | ||
) | ||
|
||
return queryset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters