fixed search and moved delete user property class

This commit is contained in:
Thomas Nahuel Rusiecki 2024-11-14 14:16:45 -03:00 committed by Cayo Puigdefabregas
parent 03ddd9b8d9
commit 56c6bb69ac
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 django.db.models import Q
from dashboard.mixins import InventaryMixin, DetailsMixin from dashboard.mixins import InventaryMixin, DetailsMixin
from evidence.models import Property from evidence.models import Property, SystemProperty
from evidence.xapian import search from evidence.xapian import search
from device.models import Device from device.models import Device
from lot.models import Lot from lot.models import Lot
@ -74,7 +74,7 @@ class SearchView(InventaryMixin):
for x in matches: for x in matches:
# devices.append(self.get_annotations(x)) # devices.append(self.get_annotations(x))
dev = self.get_property(x) dev = self.get_properties(x)
if dev.id not in dev_id: if dev.id not in dev_id:
devices.append(dev) devices.append(dev)
dev_id.append(dev.id) dev_id.append(dev.id)

View file

@ -141,31 +141,6 @@ class DownloadEvidenceView(DashboardView, TemplateView):
return response 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): class EraseServerView(DashboardView, FormView):