WIP: rework/properties #31
|
@ -180,7 +180,7 @@ class AddUserPropertyView(DashboardView, CreateView):
|
||||||
def form_valid(self, form):
|
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.user = self.request.user
|
||||||
form.instance.uuid = self.annotation.uuid
|
form.instance.uuid = self.property.uuid
|
||||||
form.instance.type = Property.Type.USER
|
form.instance.type = Property.Type.USER
|
||||||
response = super().form_valid(form)
|
response = super().form_valid(form)
|
||||||
return response
|
return response
|
||||||
|
@ -188,13 +188,13 @@ class AddUserPropertyView(DashboardView, CreateView):
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
pk = self.kwargs.get('pk')
|
pk = self.kwargs.get('pk')
|
||||||
institution = self.request.user.institution
|
institution = self.request.user.institution
|
||||||
self.annotation = SystemProperty.objects.filter(
|
self.property = UserProperty.objects.filter(
|
||||||
owner=institution,
|
owner=institution,
|
||||||
value=pk,
|
value=pk,
|
||||||
type=Property.Type.SYSTEM
|
type=Property.Type.SYSTEM
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if not self.annotation:
|
if not self.property:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
self.success_url = reverse_lazy('device:details', args=[pk])
|
self.success_url = reverse_lazy('device:details', args=[pk])
|
||||||
|
@ -211,13 +211,8 @@ class UpdateUserPropertyView(DashboardView, UpdateView):
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
pk = self.kwargs.get('pk')
|
pk = self.kwargs.get('pk')
|
||||||
user_property = get_object_or_404(UserProperty, pk=pk, owner=self.request.user.institution)
|
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
|
raise Http404
|
||||||
|
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
@ -225,7 +220,7 @@ class UpdateUserPropertyView(DashboardView, UpdateView):
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def form_valid(self, form):
|
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.user = self.request.user
|
||||||
form.instance.type = Property.Type.USER
|
form.instance.type = Property.Type.USER
|
||||||
response = super().form_valid(form)
|
response = super().form_valid(form)
|
||||||
|
@ -263,7 +258,7 @@ class DeleteUserPropertyView(DashboardView, DeleteView):
|
||||||
|
|
||||||
|
|
||||||
class AddDocumentView(DashboardView, CreateView):
|
class AddDocumentView(DashboardView, CreateView):
|
||||||
template_name = "new_annotation.html"
|
template_name = "new_user_property.html"
|
||||||
title = _("New Document")
|
title = _("New Document")
|
||||||
breadcrumb = "Device / New document"
|
breadcrumb = "Device / New document"
|
||||||
success_url = reverse_lazy('dashboard:unassigned_devices')
|
success_url = reverse_lazy('dashboard:unassigned_devices')
|
||||||
|
@ -273,7 +268,7 @@ class AddDocumentView(DashboardView, CreateView):
|
||||||
def form_valid(self, form):
|
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.user = self.request.user
|
||||||
form.instance.uuid = self.annotation.uuid
|
form.instance.uuid = self.property.uuid
|
||||||
form.instance.type = Property.Type.DOCUMENT
|
form.instance.type = Property.Type.DOCUMENT
|
||||||
response = super().form_valid(form)
|
response = super().form_valid(form)
|
||||||
return response
|
return response
|
||||||
|
@ -281,13 +276,13 @@ class AddDocumentView(DashboardView, CreateView):
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
pk = self.kwargs.get('pk')
|
pk = self.kwargs.get('pk')
|
||||||
institution = self.request.user.institution
|
institution = self.request.user.institution
|
||||||
self.annotation = SystemProperty.objects.filter(
|
self.property = SystemProperty.objects.filter(
|
||||||
owner=institution,
|
owner=institution,
|
||||||
value=pk,
|
value=pk,
|
||||||
type=Property.Type.SYSTEM
|
type=Property.Type.SYSTEM
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if not self.annotation:
|
if not self.property:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
self.success_url = reverse_lazy('device:details', args=[pk])
|
self.success_url = reverse_lazy('device:details', args=[pk])
|
||||||
|
|
|
@ -164,8 +164,8 @@ class ImportForm(forms.Form):
|
||||||
table = []
|
table = []
|
||||||
for row in self.rows:
|
for row in self.rows:
|
||||||
doc = create_doc(row)
|
doc = create_doc(row)
|
||||||
annotation = create_property(doc, self.user)
|
property = create_property(doc, self.user)
|
||||||
table.append((doc, annotation))
|
table.append((doc, property))
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
for doc, cred in table:
|
for doc, cred in table:
|
||||||
|
|
Loading…
Reference in New Issue