diff --git a/device/templates/details.html b/device/templates/details.html
index c889d45..82c52ee 100644
--- a/device/templates/details.html
+++ b/device/templates/details.html
@@ -132,9 +132,9 @@
{{ a.created }} |
-
-
-
+
@@ -172,6 +172,33 @@
{% endfor %}
+
+{% for a in object.get_user_properties %}
+
+{% endfor %}
diff --git a/device/views.py b/device/views.py
index b97c062..b00e6fa 100644
--- a/device/views.py
+++ b/device/views.py
@@ -208,8 +208,24 @@ class UpdateUserPropertyView(DashboardView, UpdateView):
model = UserProperty
fields = ("key", "value")
+ 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:
+ raise Http404
+
+ kwargs = super().get_form_kwargs()
+ kwargs['instance'] = user_property
+ 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)
@@ -223,22 +239,7 @@ class UpdateUserPropertyView(DashboardView, UpdateView):
return referer
else:
return reverse_lazy('device:details', args=[self.object.device.pk])
-
- 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.annotation = SystemProperty.objects.filter(
- owner=self.request.user.institution,
- uuid=user_property.uuid,
- type=Property.Type.SYSTEM
- ).first()
- if not self.annotation:
- raise Http404
-
- kwargs = super().get_form_kwargs()
- kwargs['instance'] = user_property
- return kwargs
class DeleteUserPropertyView(DashboardView, DeleteView):
model = UserProperty
|