Restructure Device Register
This commit is contained in:
@@ -155,9 +155,9 @@ class UsersConnectedList(UserPassesTestMixin,LoginRequiredMixin,ListView):
|
||||
|
||||
class SistemasXCliente_ListView(UserPassesTestMixin,LoginRequiredMixin, ListView):
|
||||
model = sistemas_por_cliente
|
||||
paginate_by = 20
|
||||
paginate_by = 100
|
||||
template_name = 'Sistemas/Xclientes/lista.html'
|
||||
|
||||
|
||||
def test_func(self):
|
||||
res = self.request.user.groups.filter(name= 'admin_soft')
|
||||
if not res:
|
||||
@@ -191,7 +191,7 @@ class SistemasXCliente_DetailView(UserPassesTestMixin,LoginRequiredMixin, Detail
|
||||
sistemas_por_cliente_ = self.object #type: ignore
|
||||
sistema = sistemas_por_cliente_.id_sistema
|
||||
cliente = sistemas_por_cliente_.cliente
|
||||
|
||||
|
||||
context['devices'] = Device.objects.filter(sistema=sistema, client=cliente.id)
|
||||
return context
|
||||
|
||||
@@ -228,16 +228,17 @@ class GetDeviceToken(APIView):
|
||||
def post(self,request):
|
||||
try:
|
||||
data = request.data
|
||||
sis = Sistema.objects.get(nombre_sistema=data.get('sistema'))
|
||||
#sis = Sistema.objects.get(nombre_sistema=data.get('sistema'))
|
||||
#ip_address = data.get('ip_address')
|
||||
cli = Clientes.objects.get(RFC=data.get('client'))
|
||||
device_name= data.get('device_name')
|
||||
ip_address = data.get('ip_address')
|
||||
macAddress = data.get('macAddress')
|
||||
database = data.get('database')
|
||||
|
||||
username_ = f"Device_{cli.RFC}_{device_name}_{ip_address}_{macAddress}"
|
||||
username_ = re.sub(r'\W+', '', username_)
|
||||
print(username_)
|
||||
#username_ = f"Device_{cli.RFC}_{device_name}_{ip_address}_{macAddress}"
|
||||
username_ = f"Device_{cli.RFC}_{device_name}_{macAddress}"
|
||||
username_ = re.sub(r'\W+', '', username_)
|
||||
|
||||
device = Device.objects.filter(
|
||||
username__username__icontains=username_,
|
||||
database=database
|
||||
@@ -317,9 +318,9 @@ class CheckVersionView(APIView):
|
||||
def post(self, request,*args, **kwargs):
|
||||
try:
|
||||
version = request.data.get('version')
|
||||
|
||||
|
||||
client_version = [int(x) for x in version.split(".")]
|
||||
|
||||
|
||||
try:
|
||||
ver = Sistema.objects.get(nombre_sistema="CFDI")
|
||||
server_version = [int(x) for x in ver.version.split(".")]
|
||||
@@ -327,8 +328,6 @@ class CheckVersionView(APIView):
|
||||
BitacoraErrores.objects.create(level=2, message=str(ex), traceback=traceback.format_exc(), view='Sistemas.CheckVersionView')
|
||||
return Response({'Error':f'{ex}','isError':True})
|
||||
|
||||
print('client_version: ',client_version)
|
||||
print('server_version', server_version)
|
||||
result=False
|
||||
for cont, ele in enumerate(client_version):
|
||||
if client_version[cont] != server_version[cont]:
|
||||
|
||||
Reference in New Issue
Block a user