Before Release 27 March
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.analysis.typeCheckingMode": "basic"
|
||||
}
|
||||
@@ -26,10 +26,8 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
'allauth.socialaccount',
|
||||
|
||||
@@ -38,11 +38,9 @@ class DeviceSerializer(serializers.ModelSerializer):
|
||||
mac_address = self.context['request'].data.get('macAddress')
|
||||
sistema = validated_data['sistema']
|
||||
client = validated_data['client']
|
||||
|
||||
existing_devices = Device.objects.filter(
|
||||
Q(sistema=sistema)& Q(client=client)& Q(macAddress=mac_address)
|
||||
Q(sistema=sistema)& Q(client=client)& Q(macAddress__icontains=mac_address)
|
||||
)
|
||||
|
||||
if existing_devices.exists():
|
||||
# A device with the same macAddress already exists for the given sistema and client
|
||||
# Get the number of existing devices and add 1 to create a new suffix
|
||||
@@ -59,6 +57,6 @@ class DeviceSerializer(serializers.ModelSerializer):
|
||||
sistemaxCli = sistemas_por_cliente.objects.get(id_sistema=sistema,cliente=client)
|
||||
except sistemas_por_cliente.DoesNotExist:
|
||||
raise serializers.ValidationError('No existe licencia para este sistema y/o cliente')
|
||||
if sistemaxCli.num_licencias <= Device.objects.filter(sistema=sistemaxCli.id_sistema).count():
|
||||
if sistemaxCli.num_licencias <= Device.objects.filter(sistema=sistemaxCli.id_sistema, client=client).count():
|
||||
raise serializers.ValidationError(f"No hay licencias disponibles para este sistema:{sistema} y cliente:{client}")
|
||||
return data
|
||||
@@ -217,6 +217,7 @@ class Sistema_CreateView(CreateView):
|
||||
'''
|
||||
|
||||
class GetDeviceToken(APIView):
|
||||
"""Recobra el Token DRF del Device"""
|
||||
authentication_classes= [TokenAuthentication]
|
||||
permissions_classes=[IsAuthenticated, HasAuthorizationHeader]
|
||||
def post(self,request):
|
||||
@@ -242,11 +243,10 @@ class GetDeviceToken(APIView):
|
||||
traceback=traceback.format_exc(),
|
||||
view='Sistemas.GetDeviceToken'
|
||||
)
|
||||
return Response(
|
||||
{'Error':f'{ex}','isError':True}
|
||||
, status=status.HTTP_200_OK)
|
||||
return Response({'Error':f'{ex}','isError':True}, status=status.HTTP_200_OK)
|
||||
|
||||
class RegisterDeviceView(APIView):
|
||||
"""Registra al Device"""
|
||||
permissions_classes = (permissions.AllowAny,)
|
||||
|
||||
def post(self,request):
|
||||
@@ -260,11 +260,12 @@ class RegisterDeviceView(APIView):
|
||||
except Exception as ex:
|
||||
BitacoraErrores.objects.create(level=2, message=str(ex), traceback=traceback.format_exc(),
|
||||
view='Sistemas.RegisterDeviceView')
|
||||
return Response(
|
||||
{'Error':f'{ex}','isError':True}
|
||||
, status=status.HTTP_200_OK)
|
||||
return Response({'Error':f'{ex}','isError':True}
|
||||
, status=status.HTTP_200_OK
|
||||
)
|
||||
|
||||
class AuthenticateDeviceView(APIView):
|
||||
"""Autentica al device"""
|
||||
authentication_classes= [TokenAuthentication]
|
||||
permissions_classes=[IsAuthenticated, HasAuthorizationHeader]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user