diff options
Diffstat (limited to 'ishtar_common/views.py')
-rw-r--r-- | ishtar_common/views.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 19fc9f848..6f5953841 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -2100,14 +2100,14 @@ class DocumentCreateView(DocumentFormMixin, CreateView): def get_form_kwargs(self): kwargs = super(DocumentCreateView, self).get_form_kwargs() initial = kwargs.get("initial", {}) - document_parent = None - value = None + source = None - if self.kwargs.get("pk"): + if self.request.GET.get("source_pk", None): try: - document_parent = models.Document.objects.get(pk=self.kwargs.get("pk")) - assert check_permission(self.request, "document/create", document_parent.pk) - except (AssertionError, models.Document.DoesNotExist): + source = models.Document.objects.get( + pk=self.request.GET.get("source_pk") + ) + except models.Document.DoesNotExist: raise Http404() for related_key in models.Document.RELATED_MODELS_ALT: @@ -2119,15 +2119,15 @@ class DocumentCreateView(DocumentFormMixin, CreateView): continue initial[related_key] = str(item.pk) - if document_parent: + if source: for k in models.Document.RELATED_MODELS: - value = getattr(document_parent, k) + value = getattr(source, k) if hasattr(value, "all"): value = ",".join([str(v.pk) for v in value.all()]) if hasattr(value, "pk"): value = value.pk initial[k] = value - initial["source"] = document_parent.pk + initial["source"] = source.pk if initial: kwargs["initial"] = initial |