Projet

Général

Profil

0001-api_views-factorize-code-for-stat-decorator-49670.patch

Valentin Deniaud, 25 février 2021 17:49

Télécharger (2,47 ko)

Voir les différences:

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(-)
src/authentic2/api_views.py
1133 1133
def stat(**kwargs):
1134 1134
    '''Extend action decorator to allow passing statistics related info.'''
1135 1135
    filters = kwargs.pop('filters', [])
1136
    kwargs['detail'] = False
1136 1137
    decorator = action(**kwargs)
1137 1138

  
1138 1139
    def wraps(func):
......
1217 1218
            'err': 0,
1218 1219
        })
1219 1220

  
1220
    @stat(detail=False, name=_('Login count by authentication type'), filters=('ou', 'service'))
1221
    @stat(name=_('Login count by authentication type'), filters=('ou', 'service'))
1221 1222
    def login(self, request):
1222 1223
        return self.get_statistics(request, UserLogin, 'get_method_statistics')
1223 1224

  
1224
    @stat(detail=False, name=_('Login count by service'))
1225
    @stat(name=_('Login count by service'))
1225 1226
    def service_login(self, request):
1226 1227
        return self.get_statistics(request, UserLogin, 'get_service_statistics')
1227 1228

  
1228
    @stat(detail=False, name=_('Login count by organizational unit'))
1229
    @stat(name=_('Login count by organizational unit'))
1229 1230
    def service_ou_login(self, request):
1230 1231
        return self.get_statistics(request, UserLogin, 'get_service_ou_statistics')
1231 1232

  
1232
    @stat(detail=False, name=_('Registration count by type'), filters=('ou', 'service'))
1233
    @stat(name=_('Registration count by type'), filters=('ou', 'service'))
1233 1234
    def registration(self, request):
1234 1235
        return self.get_statistics(request, UserRegistration, 'get_method_statistics')
1235 1236

  
1236
    @stat(detail=False, name=_('Registration count by service'))
1237
    @stat(name=_('Registration count by service'))
1237 1238
    def service_registration(self, request):
1238 1239
        return self.get_statistics(request, UserRegistration, 'get_service_statistics')
1239 1240

  
1240
    @stat(detail=False, name=_('Registration count by organizational unit'))
1241
    @stat(name=_('Registration count by organizational unit'))
1241 1242
    def service_ou_registration(self, request):
1242 1243
        return self.get_statistics(request, UserRegistration, 'get_service_ou_statistics')
1243 1244

  
1244
-