updated views for new model structure
This commit is contained in:
parent
fe5abd0299
commit
443c37b1e2
|
@ -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, SystemProperty
|
||||
from evidence.models import SystemProperty
|
||||
from evidence.xapian import search
|
||||
from device.models import Device
|
||||
from lot.models import Lot
|
||||
|
@ -96,7 +96,6 @@ class SearchView(InventaryMixin):
|
|||
qry |= Q(value__startswith=i)
|
||||
|
||||
chids = SystemProperty.objects.filter(
|
||||
type=Property.Type.SYSTEM,
|
||||
owner=self.request.user.institution
|
||||
).filter(
|
||||
qry
|
||||
|
|
|
@ -15,7 +15,7 @@ from django.views.generic.edit import (
|
|||
)
|
||||
from django.views.generic.base import TemplateView
|
||||
from dashboard.mixins import DashboardView, Http403
|
||||
from evidence.models import UserProperty, SystemProperty, Property
|
||||
from evidence.models import UserProperty, SystemProperty
|
||||
from lot.models import LotTag
|
||||
from device.models import Device
|
||||
from device.forms import DeviceFormSet
|
||||
|
@ -184,7 +184,7 @@ class AddUserPropertyView(DashboardView, CreateView):
|
|||
form.instance.owner = self.request.user.institution
|
||||
form.instance.user = self.request.user
|
||||
form.instance.uuid = self.property.uuid
|
||||
form.instance.type = Property.Type.USER
|
||||
form.instance.type = UserProperty.Type.USER
|
||||
|
||||
messages.success(self.request, _("User property successfully added."))
|
||||
|
||||
|
@ -201,7 +201,6 @@ class AddUserPropertyView(DashboardView, CreateView):
|
|||
self.property = SystemProperty.objects.filter(
|
||||
owner=institution,
|
||||
value=pk,
|
||||
type=Property.Type.SYSTEM
|
||||
).first()
|
||||
|
||||
if not self.property:
|
||||
|
@ -237,7 +236,7 @@ class UpdateUserPropertyView(DashboardView, UpdateView):
|
|||
|
||||
form.instance.owner = self.request.user.institution
|
||||
form.instance.user = self.request.user
|
||||
form.instance.type = Property.Type.USER
|
||||
form.instance.type = UserProperty.Type.USER
|
||||
response = super().form_valid(form)
|
||||
|
||||
messages.success(self.request, _("User property updated successfully."))
|
||||
|
@ -278,14 +277,14 @@ class AddDocumentView(DashboardView, CreateView):
|
|||
title = _("New Document")
|
||||
breadcrumb = "Device / New document"
|
||||
success_url = reverse_lazy('dashboard:unassigned_devices')
|
||||
model = SystemProperty
|
||||
model = UserProperty
|
||||
fields = ("key", "value")
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.owner = self.request.user.institution
|
||||
form.instance.user = self.request.user
|
||||
form.instance.uuid = self.property.uuid
|
||||
form.instance.type = Property.Type.DOCUMENT
|
||||
form.instance.type = UserProperty.Type.DOCUMENT
|
||||
response = super().form_valid(form)
|
||||
return response
|
||||
|
||||
|
@ -295,7 +294,6 @@ class AddDocumentView(DashboardView, CreateView):
|
|||
self.property = SystemProperty.objects.filter(
|
||||
owner=institution,
|
||||
value=pk,
|
||||
type=Property.Type.SYSTEM
|
||||
).first()
|
||||
|
||||
if not self.property:
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.views.generic.edit import (
|
|||
)
|
||||
|
||||
from dashboard.mixins import DashboardView, Http403
|
||||
from evidence.models import Property, SystemProperty, UserProperty, Evidence
|
||||
from evidence.models import SystemProperty, UserProperty, Evidence
|
||||
from evidence.forms import (
|
||||
UploadForm,
|
||||
UserTagForm,
|
||||
|
|
|
@ -11,7 +11,6 @@ from django.views.generic.edit import (
|
|||
from dashboard.mixins import DashboardView
|
||||
from lot.models import Lot, LotTag, LotProperty
|
||||
from lot.forms import LotsForm
|
||||
from device.models import Property
|
||||
|
||||
class NewLotView(DashboardView, CreateView):
|
||||
template_name = "new_lot.html"
|
||||
|
@ -154,7 +153,7 @@ class LotAddDocumentView(DashboardView, CreateView):
|
|||
form.instance.owner = self.request.user.institution
|
||||
form.instance.user = self.request.user
|
||||
form.instance.lot = self.lot
|
||||
form.instance.type = Property.Type.DOCUMENT
|
||||
form.instance.type = LotProperty.Type.DOCUMENT
|
||||
response = super().form_valid(form)
|
||||
return response
|
||||
|
||||
|
@ -178,7 +177,7 @@ class LotDocumentsView(DashboardView, TemplateView):
|
|||
documents = LotProperty.objects.filter(
|
||||
lot=lot,
|
||||
owner=self.request.user.institution,
|
||||
type=Property.Type.DOCUMENT,
|
||||
type=LotProperty.Type.DOCUMENT,
|
||||
)
|
||||
context.update({
|
||||
'lot': lot,
|
||||
|
@ -201,7 +200,7 @@ class LotPropertiesView(DashboardView, TemplateView):
|
|||
properties = LotProperty.objects.filter(
|
||||
lot=lot,
|
||||
owner=self.request.user.institution,
|
||||
type=Property.Type.USER,
|
||||
type=LotProperty.Type.USER,
|
||||
)
|
||||
context.update({
|
||||
'lot': lot,
|
||||
|
@ -224,7 +223,7 @@ class LotAddPropertyView(DashboardView, CreateView):
|
|||
form.instance.owner = self.request.user.institution
|
||||
form.instance.user = self.request.user
|
||||
form.instance.lot = self.lot
|
||||
form.instance.type = Property.Type.USER
|
||||
form.instance.type = LotProperty.Type.USER
|
||||
response = super().form_valid(form)
|
||||
return response
|
||||
|
||||
|
|
Loading…
Reference in a new issue