Commit d77bc470 authored by Bruno Martin's avatar Bruno Martin
Browse files

fix general reports; set fiename for reports

parent ad8b068f
......@@ -212,7 +212,7 @@ class UsersByGroupViewSet(PandasViewSet):
if groups is not None:
self.queryset = self.queryset.filter(groups__name__in=groups.split(','))
self.queryset = self.queryset.prefetch_related('groups', 'course_students')
self.queryset = self.queryset.prefetch_related('groups', 'coursestudent_set')
return self.queryset
......@@ -222,7 +222,7 @@ class UsersByGroupViewSet(PandasViewSet):
serializer = UserInDetailSerializer(queryset, many=True)
# in order to get the data in the wanted column form, I'll need to make some transformations
return Response(self.transform_data(
return self.update_pandas_headers(Response(self.transform_data(
def transform_data(self, data):
response = []
......@@ -238,6 +238,10 @@ class UsersByGroupViewSet(PandasViewSet):
return pd.DataFrame.from_dict(response)
def get_pandas_filename(self, request, format):
return 'Relatório de atividades dos usuários'
class UsersByClassViewSet(PandasViewSet):
......@@ -270,8 +274,8 @@ class UsersByClassViewSet(PandasViewSet):
queryset = self.get_queryset()
serializer = UsersByClassSerializer(queryset, many=True)
return Response(pd.DataFrame
return self.update_pandas_headers(Response(pd.DataFrame
# .set_index('cpf'))
def transform_data(self, data):
......@@ -286,3 +290,7 @@ class UsersByClassViewSet(PandasViewSet):
coursestudent.pop('percent_progress_by_lesson', None)
return data
def get_pandas_filename(self, request, format):
return 'Relatório de progresso dos usuários'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment