summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-04 18:24:19 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-04 18:24:19 +0200
commit19ce74c574ee3673caa7883d45e3db9b97382051 (patch)
treea36d85c0d2ebc37880f9c4e84dfbe952d37e46a1
parent87df7fd7357f3210953038bff58477319e12b6fc (diff)
downloadIshtar-19ce74c574ee3673caa7883d45e3db9b97382051.tar.bz2
Ishtar-19ce74c574ee3673caa7883d45e3db9b97382051.zip
QA document: bulk modification
-rw-r--r--ishtar_common/forms_common.py25
-rw-r--r--ishtar_common/models.py10
-rw-r--r--ishtar_common/urls.py9
-rw-r--r--ishtar_common/views.py5
4 files changed, 45 insertions, 4 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index df103e541..a92b53e29 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -508,7 +508,7 @@ class PersonFormSelection(CustomFormSearch):
class QAPersonFormMulti(QAForm):
form_admin_name = _(u"Person - Quick action - Modify")
form_slug = "person-quickaction-modify"
- base_models = ['qa_title_type']
+ base_models = ['qa_title']
associated_models = {
'qa_title': models.TitleType,
}
@@ -1316,7 +1316,7 @@ class DocumentSelect(HistorySelect):
}
-class DocumentFormSelection(forms.Form):
+class DocumentFormSelection(CustomFormSearch):
SEARCH_AND_SELECT = True
form_label = _(u"Document search")
associated_models = {'pk': models.Document}
@@ -1338,6 +1338,27 @@ class DocumentFormSelection(forms.Form):
return cleaned_data
+class QADocumentFormMulti(QAForm):
+ form_admin_name = _(u"Document - Quick action - Modify")
+ form_slug = "document-quickaction-modify"
+ base_models = ['qa_source_type']
+ associated_models = {
+ 'qa_source_type': models.SourceType,
+ }
+
+ MULTI = True
+ REPLACE_FIELDS = [
+ 'qa_source_type',
+ ]
+ qa_source_type = forms.ChoiceField(
+ label=_(u"Source type"), required=False
+ )
+
+ TYPES = [
+ FieldType('qa_source_type', models.SourceType),
+ ]
+
+
class SourceDeletionForm(FinalForm):
confirm_msg = " "
confirm_end_msg = _(u"Would you like to delete this documentation?")
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 2e618749b..c9a66f861 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -3694,7 +3694,6 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem):
QA_EDIT
]
-
objects = PersonManager()
# fields
@@ -4399,7 +4398,7 @@ post_save.connect(post_save_cache, sender=LicenseType)
post_delete.connect(post_save_cache, sender=LicenseType)
-class Document(BaseHistorizedItem, OwnPerms, ImageModel, ValueGetter):
+class Document(BaseHistorizedItem, OwnPerms, ImageModel, ValueGetter, MainItem):
EXTERNAL_ID_KEY = 'document_external_id'
# order is important: put the image in the first match found
# other will be symbolic links
@@ -4560,6 +4559,13 @@ class Document(BaseHistorizedItem, OwnPerms, ImageModel, ValueGetter):
"treatmentfile": (pgettext_lazy("key for text search",
u"treatment-file"), 'cached_label'),
}
+ QA_EDIT = QuickAction(
+ url="document-qa-bulk-update", icon_class="fa fa-pencil",
+ text=_(u"Bulk update"), target="many",
+ rights=['change_document', 'change_own_document'])
+ QUICK_ACTIONS = [
+ QA_EDIT
+ ]
title = models.TextField(_(u"Title"), blank=True, default='')
associated_file = models.FileField(
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index 26dfcdc07..1a4c43a3a 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -275,6 +275,15 @@ urlpatterns += [
check_rights(['change_document', 'change_own_document'])(
views.document_deletion_wizard),
name='document_deletion'),
+
+ url(r'^document-qa-bulk-update/(?P<pks>[0-9-]+)?/$',
+ check_rights(['change_document', 'change_own_document'])(
+ views.QADocumentForm.as_view()),
+ name='document-qa-bulk-update'),
+ url(r'^document-qa-bulk-update/(?P<pks>[0-9-]+)?/confirm/$',
+ check_rights(['change_document', 'change_own_document'])(
+ views.QADocumentForm.as_view()),
+ name='document-qa-bulk-update-confirm', kwargs={"confirm": True}),
]
urlpatterns += get_urls_for_model(models.Document, views)
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 0ebdc411f..8f7964576 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -2088,3 +2088,8 @@ class QAPersonForm(QAItemEditForm):
form_class = forms.QAPersonFormMulti
+class QADocumentForm(QAItemEditForm):
+ model = models.Document
+ form_class = forms.QADocumentFormMulti
+
+