def post(self, request, **kwargs):
     c_user = get_user_index(request.user)
     c_user.user.first_name = request.POST['f_name']
     c_user.user.last_name = request.POST['l_name']
     if 'avatar' in request.FILES:
         c_user.avatar = request.FILES['avatar']
     c_user.save()
     return redirect('/')
 def get(self, request, **kwargs):
     c_user = get_user_index(request.user)
     self.context['c_user'] = c_user
     animals = AnimalType.objects.all()
     self.context['animals'] = animals
     if c_user is None:
         return render(request, 'index.html', context=self.context)
     return c_user.get_index(request, context=self.context)
示例#3
0
    def get(self, request, **kwargs):
        user = get_user_index(request.user)
        complaints = Complaint.objects.filter(
            municipality=user.municipality)

        self.context['complaints'] = complaints
        self.context['c_user'] = user
        self.context['stats'] = self.getComplaintStats(complaints)
        return render(request, self.template_name, context=self.context)
示例#4
0
    def get(self, request, pk, **kwargs):
        user = get_user_index(request.user)
        self.context['c_user'] = user
        complaint = get_object_or_404(Complaint, pk=pk)
        self.context['complaint'] = complaint

        images = ComplaintImage.objects.filter(complaint=complaint)
        self.context['images'] = images

        return render(request, self.template_name, context=self.context)
示例#5
0
    def get(self, request, pk, **kwargs):
        c_user = get_user_index(request.user)
        self.context['c_user'] = c_user

        animal = get_object_or_404(Animal, pk=pk)
        adopt_users_pk = Adopt.objects.filter(animal=animal).values('user')
        adopt_users = list(NaturalUser.objects.filter(pk__in=adopt_users_pk))
        self.context['selected_animal'] = animal
        self.context['adopters'] = adopt_users
        self.context['images'] = AnimalImage.objects.filter(animal=animal)
        return render(request, self.template_name, context=self.context)
示例#6
0
    def get(self, request, **kwargs):
        c_user = get_user_index(request.user)
        animal = get_object_or_404(Animal, pk=request.GET.get('id'))
        Adopt.objects.get_or_create(user=c_user, animal=animal)

        adopt_users_pk = Adopt.objects.filter(animal=animal).values('user')
        adopt_users = [
            "<p>" + user.user.first_name + " " + user.user.last_name + "</p>"
            for user in NaturalUser.objects.filter(pk__in=adopt_users_pk)
        ]

        return HttpResponse(adopt_users)
    def post(self, request, **kwargs):
        username = request.POST.get('email')
        password = request.POST.get('password')
        user = authenticate(username=username, password=password)

        if user is not None:
            current_user = get_user_index(user)
            if current_user is not None:
                login(request, user)
                return redirect('/')

        messages.error(request,
                       "La combinación de usuario y contraseña no coincide")
        return redirect('/login/')
 def get(self, request, **kwargs):
     c_user = get_user_index(request.user)
     self.context['c_user'] = c_user
     animals = AnimalType.objects.all()
     self.context['animals'] = animals
     return render(request, self.template_name, context=self.context)
示例#9
0
 def get(self, request, **kwargs):
     user = get_user_index(request.user)
     self.context['c_user'] = user
     return render(request, self.template_name, context=self.context)
示例#10
0
 def post(self, request, **kwargs):
     c_user = get_user_index(request.user)
     if 'avatar' in request.FILES:
         c_user.municipality.avatar = request.FILES['avatar']
         c_user.municipality.save()
     return redirect('/')