Example #1
0
 def has_permission(self, request, view):
     perms = ('catalogo.list_autor', )  # cambie aqui el permiso
     if request.user.has_perms(perms):
         return True
     else:
         log.info(
             _('Permission denied. You don\'t have permission to %s.') %
             (perms),
             extra=log_params(request))
         return False
Example #2
0
 def get(self, request, format=None):
     """
     Return a list of all users.
     """
     user = self.request.user
     serializer = UserInfoSerializer(user)
     if not self.request.user:
         return Response(
             {'detail': 'AUTHENTICATION IS REQUIRED'},
             status=status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED)
     if not self.request.user.is_anonymous():
         log.info(force_text('User is authenticated'),
                  extra=log_params(self.request))
         return Response(serializer.data)
     else:
         log.warning(force_text('User is anonymous'),
                     extra=log_params(self.request))
     return Response({'detail': 'AUTHENTICATION IS REQUIRED'},
                     status=status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED)
     '''
Example #3
0
 def get(self, request, format=None):
     """
     Return a list of all users.
     """
     user = self.request.user
     serializer = UserInfoSerializer(user)
     if not self.request.user:
         return Response(
             {'detail': 'AUTHENTICATION IS REQUIRED'},
             status=status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED
         )
     if not self.request.user.is_anonymous():
         log.info(force_text('User is authenticated'),
                  extra=log_params(self.request))
         return Response(serializer.data)
     else:
         log.warning(force_text('User is anonymous'),
                     extra=log_params(self.request))
     return Response({'detail': 'AUTHENTICATION IS REQUIRED'},
                     status=status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED)
     '''
Example #4
0
    def get_queryset(self):
        '''


        print("Hola %s (id=%s)" %
              (self.request.user.username, self.request.user.id))
        if self.request.user.person:
            print("dni=%s)" % self.request.user.person.identity_num)
        print("==========\n")
        '''
        log.info('!!Writing in log file!!', extra=log_params(self.request))
        all = self.request.query_params.get('all', None)
        print('MenuViewSet all=', all)
        self.queryset = self.queryset.filter(parent=None)  # si vas a modificar
        return ModelPagination.get_queryset(self)