diff --git a/uvdat/core/models/networks.py b/uvdat/core/models/networks.py index 8f4ef129..6a83b1cc 100644 --- a/uvdat/core/models/networks.py +++ b/uvdat/core/models/networks.py @@ -21,6 +21,8 @@ def get_graph(self): def get_gcc(self, exclude_nodes): graph = self.get_graph() graph.remove_nodes_from(exclude_nodes) + if graph.number_of_nodes == 0 or nx.number_connected_components(graph) == 0: + return [] gcc = max(nx.connected_components(graph), key=len) return list(gcc) diff --git a/uvdat/core/rest/chart.py b/uvdat/core/rest/chart.py index 794b3373..a7ec8700 100644 --- a/uvdat/core/rest/chart.py +++ b/uvdat/core/rest/chart.py @@ -12,7 +12,8 @@ class ChartViewSet(GenericViewSet, mixins.ListModelMixin): serializer_class = ChartSerializer def get_queryset(self, **kwargs): - context_id = kwargs.get('context') + request = self.request + context_id = request.query_params.get('context') if context_id: return Chart.objects.filter(context__id=context_id) return Chart.objects.all()