Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

not sure if this works

jonaswinklerfd4c9a1758b5
diff --git a/src/documents/forms.py b/src/documents/forms.py
index 63dd307b2..0c73c3810 100644
--- a/src/documents/forms.py
+++ b/src/documents/forms.py
@@ -1,4 +1,5 @@
import os
+import re
import tempfile
from datetime import datetime
from time import mktime
@@ -11,6 +12,17 @@ from pathvalidate import validate_filename, ValidationError
from documents.parsers import is_mime_type_supported
+class BuldEditForm(forms.Form):
+
+ def clean_ids(self):
+ ids = self.cleaned_data.get("ids")
+ if not re.match(r"[0-9,]+", ids):
+ raise forms.ValidationError("id list invalid")
+ id_list = [int(id) for id in ids.split(",")]
+
+
+
+
class UploadForm(forms.Form):
diff --git a/src/documents/views.py b/src/documents/views.py
index 84f4a3999..ee45af267 100755
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -93,6 +93,10 @@ class DocumentTypeViewSet(ModelViewSet):
ordering_fields = ("name", "matching_algorithm", "match", "document_count")
+class BulkEditForm(object):
+ pass
+
+
class DocumentViewSet(RetrieveModelMixin,
UpdateModelMixin,
DestroyModelMixin,
@@ -149,6 +153,13 @@ class DocumentViewSet(RetrieveModelMixin,
else:
return HttpResponseBadRequest(str(form.errors))
+ @action(methods=['post'], detail=False)
+ def bulk_edit(self, request, pk=None):
+ form = BulkEditForm(data=request.POST)
+ if not form.is_valid():
+ return HttpResponseBadRequest("")
+ return Response({'asd': request.POST['content']})
+
@action(methods=['get'], detail=True)
def metadata(self, request, pk=None):
try: