From b26acbe50be39cd8f66d27358a600f29cbb59874 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 25 Feb 2021 15:32:01 +0100 Subject: [PATCH 1/3] api_views: factorize code for stat decorator (#49670) --- src/authentic2/api_views.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/authentic2/api_views.py b/src/authentic2/api_views.py index b2791325..8510bcaf 100644 --- a/src/authentic2/api_views.py +++ b/src/authentic2/api_views.py @@ -1133,6 +1133,7 @@ class StatisticsSerializer(serializers.Serializer): def stat(**kwargs): '''Extend action decorator to allow passing statistics related info.''' filters = kwargs.pop('filters', []) + kwargs['detail'] = False decorator = action(**kwargs) def wraps(func): @@ -1217,27 +1218,27 @@ class StatisticsAPI(ViewSet): 'err': 0, }) - @stat(detail=False, name=_('Login count by authentication type'), filters=('ou', 'service')) + @stat(name=_('Login count by authentication type'), filters=('ou', 'service')) def login(self, request): return self.get_statistics(request, UserLogin, 'get_method_statistics') - @stat(detail=False, name=_('Login count by service')) + @stat(name=_('Login count by service')) def service_login(self, request): return self.get_statistics(request, UserLogin, 'get_service_statistics') - @stat(detail=False, name=_('Login count by organizational unit')) + @stat(name=_('Login count by organizational unit')) def service_ou_login(self, request): return self.get_statistics(request, UserLogin, 'get_service_ou_statistics') - @stat(detail=False, name=_('Registration count by type'), filters=('ou', 'service')) + @stat(name=_('Registration count by type'), filters=('ou', 'service')) def registration(self, request): return self.get_statistics(request, UserRegistration, 'get_method_statistics') - @stat(detail=False, name=_('Registration count by service')) + @stat(name=_('Registration count by service')) def service_registration(self, request): return self.get_statistics(request, UserRegistration, 'get_service_statistics') - @stat(detail=False, name=_('Registration count by organizational unit')) + @stat(name=_('Registration count by organizational unit')) def service_ou_registration(self, request): return self.get_statistics(request, UserRegistration, 'get_service_ou_statistics') -- 2.20.1