From aff13a04eb90058213843472817639a947d38494 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Fri, 15 Nov 2024 20:13:39 -0300 Subject: [PATCH] renaming of annotation to property --- device/views.py | 25 ++++++++++--------------- evidence/forms.py | 4 ++-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/device/views.py b/device/views.py index b00e6fa..c29228d 100644 --- a/device/views.py +++ b/device/views.py @@ -180,7 +180,7 @@ class AddUserPropertyView(DashboardView, CreateView): def form_valid(self, form): form.instance.owner = self.request.user.institution form.instance.user = self.request.user - form.instance.uuid = self.annotation.uuid + form.instance.uuid = self.property.uuid form.instance.type = Property.Type.USER response = super().form_valid(form) return response @@ -188,13 +188,13 @@ class AddUserPropertyView(DashboardView, CreateView): def get_form_kwargs(self): pk = self.kwargs.get('pk') institution = self.request.user.institution - self.annotation = SystemProperty.objects.filter( + self.property = UserProperty.objects.filter( owner=institution, value=pk, type=Property.Type.SYSTEM ).first() - if not self.annotation: + if not self.property: raise Http404 self.success_url = reverse_lazy('device:details', args=[pk]) @@ -211,13 +211,8 @@ class UpdateUserPropertyView(DashboardView, UpdateView): def get_form_kwargs(self): pk = self.kwargs.get('pk') user_property = get_object_or_404(UserProperty, pk=pk, owner=self.request.user.institution) - self.property = SystemProperty.objects.filter( - owner=self.request.user.institution, - uuid=user_property.uuid, - type=Property.Type.SYSTEM - ).first() - - if not self.property: + + if not user_property: raise Http404 kwargs = super().get_form_kwargs() @@ -225,7 +220,7 @@ class UpdateUserPropertyView(DashboardView, UpdateView): return kwargs def form_valid(self, form): - form.instance.owner = self.request .user.institution + form.instance.owner = self.request .user.institution form.instance.user = self.request.user form.instance.type = Property.Type.USER response = super().form_valid(form) @@ -263,7 +258,7 @@ class DeleteUserPropertyView(DashboardView, DeleteView): class AddDocumentView(DashboardView, CreateView): - template_name = "new_annotation.html" + template_name = "new_user_property.html" title = _("New Document") breadcrumb = "Device / New document" success_url = reverse_lazy('dashboard:unassigned_devices') @@ -273,7 +268,7 @@ class AddDocumentView(DashboardView, CreateView): def form_valid(self, form): form.instance.owner = self.request.user.institution form.instance.user = self.request.user - form.instance.uuid = self.annotation.uuid + form.instance.uuid = self.property.uuid form.instance.type = Property.Type.DOCUMENT response = super().form_valid(form) return response @@ -281,13 +276,13 @@ class AddDocumentView(DashboardView, CreateView): def get_form_kwargs(self): pk = self.kwargs.get('pk') institution = self.request.user.institution - self.annotation = SystemProperty.objects.filter( + self.property = SystemProperty.objects.filter( owner=institution, value=pk, type=Property.Type.SYSTEM ).first() - if not self.annotation: + if not self.property: raise Http404 self.success_url = reverse_lazy('device:details', args=[pk]) diff --git a/evidence/forms.py b/evidence/forms.py index 3de1b6f..c802b66 100644 --- a/evidence/forms.py +++ b/evidence/forms.py @@ -164,8 +164,8 @@ class ImportForm(forms.Form): table = [] for row in self.rows: doc = create_doc(row) - annotation = create_property(doc, self.user) - table.append((doc, annotation)) + property = create_property(doc, self.user) + table.append((doc, property)) if commit: for doc, cred in table: