fixed search and moved delete user property class

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-14 14:16:45 -03:00
parent caa2be3a41
commit 10f2f6dc16
2 changed files with 2 additions and 27 deletions

View File

@ -6,7 +6,7 @@ from django.shortcuts import Http404
from django.db.models import Q
from dashboard.mixins import InventaryMixin, DetailsMixin
from evidence.models import Property
from evidence.models import Property, SystemProperty
from evidence.xapian import search
from device.models import Device
from lot.models import Lot
@ -74,7 +74,7 @@ class SearchView(InventaryMixin):
for x in matches:
# devices.append(self.get_annotations(x))
dev = self.get_property(x)
dev = self.get_properties(x)
if dev.id not in dev_id:
devices.append(dev)
dev_id.append(dev.id)

View File

@ -141,31 +141,6 @@ class DownloadEvidenceView(DashboardView, TemplateView):
return response
class UserPropertyDeleteView(DashboardView, DeleteView):
model = UserProperty
def get(self, request, *args, **kwargs):
self.pk = kwargs['pk']
try:
referer = self.request.META["HTTP_REFERER"]
path_referer = urlparse(referer).path
resolver_match = resolve(path_referer)
url_name = resolver_match.view_name
kwargs_view = resolver_match.kwargs
except:
# if is not possible resolve the reference path return 404
raise Http404
self.object = get_object_or_404(
self.model,
pk=self.pk,
owner=self.request.user.institution
)
self.object.delete()
return redirect(url_name, **kwargs_view)
class EraseServerView(DashboardView, FormView):