Exemple #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     if get_rol(self.request) == 'c':
         context['cant_vete'] = Veterinaria.objects.all().count()
         context['cant_servi'] = Servicios.objects.filter(cliente=self.request.user.perfil_c.cc).count()
         context['entradas'] = Page.objects.all()[:3]
         context['rol'] = 'c'
     elif get_rol(self.request) == 'v':
         context['cant_cam'] = Camara.objects.filter(veterinaria=Veterinaria.objects.get(user=self.request.user)).count()
         context['cant_servi'] = Servicios.objects.filter(veterinaria=Veterinaria.objects.get(user=self.request.user)).count()
         context['entradas'] = Page.objects.all()[:3]
         context['rol'] = 'v'
     return context
Exemple #2
0
 def get(self, request, *args, **kwargs):
     r = get_rol(self.request)
     if r == 'n':
         return HttpResponseRedirect('/')
     elif r == 'v':
         return HttpResponseRedirect('/')
     return super(listVeterinarias, self).get(request, *args, **kwargs)
Exemple #3
0
 def get_queryset(self):
     r = get_rol(self.request)
     if r == 'v':
         vet = Veterinaria.objects.get(user=self.request.user)
         return Servicios.objects.filter(veterinaria=vet)
     elif r == 'c':
         return Servicios.objects.filter(cliente=self.request.user.perfil_c.cc)
     else:
         return Servicios.objects.filter(veterinaria=0)
Exemple #4
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     r = get_rol(self.request)
     if r == 'c':
         context['title'] = 'Mis mascotas'
     elif r == 'v':
         context['title'] = 'Mascotas'
     else:
         context['title'] = 'Error: no perfil, pongase en contacto con el servicio al cliente'
     return context
Exemple #5
0
def checkClient(request, cc):
    if get_rol(request) == 'v':
        try:
            cliente = Cliente.objects.get(cc=cc)
            mascotas = cliente.user.get_pets.all()
            mascotasList = []
            for mascota in mascotas:
                if mascota.activo:
                    data = [mascota.id, mascota.nombre]
                    mascotasList.append(data)
            if cliente.user.first_name or cliente.user.last_name:
                nombre_completo = cliente.user.first_name + ' ' + cliente.user.last_name
            else:
                nombre_completo = cliente.user.username
            return JsonResponse({'nombre':nombre_completo,'mascotas':mascotasList, 'e':0})
        except Cliente.DoesNotExist:
            return JsonResponse({'nombre':"No existe perfil", 'e':1})
    else:
        return JsonResponse({'error':'No eres una veterinaria'})
Exemple #6
0
 def get_queryset(self):
     r = get_rol(self.request)
     if r == 'c':
         return Mascota.objects.filter(dueno=self.request.user)
     else:
         return Mascota.objects.all()
Exemple #7
0
 def get_queryset(self):
     r = get_rol(self.request)
     if r == 'v':
         return Camara.objects.filter(veterinaria=self.request.user.perfil_v)
     else:
         return Camara.objects.filter(veterinaria=0)
Exemple #8
0
 def get(self, request, *args, **kwargs):
     r = get_rol(self.request)
     if r == 'n':
         return HttpResponseRedirect('/mascotas/')
     return super(listServices, self).get(request, *args, **kwargs)