summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-10 20:49:13 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-10 20:49:13 +0200
commit3dae10a792d49d685debfe52eb7d61b9a6dc93f9 (patch)
tree45f1d910b67a30e44015735581ec9cdc6db51cdf /ishtar_common
parent58178a04b3e716a063b1c457018aafe28e5107dd (diff)
downloadIshtar-3dae10a792d49d685debfe52eb7d61b9a6dc93f9.tar.bz2
Ishtar-3dae10a792d49d685debfe52eb7d61b9a6dc93f9.zip
QA: lock/unlock (sites, operations, context records, finds, containers, warehouses)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms.py6
-rw-r--r--ishtar_common/forms_common.py21
-rw-r--r--ishtar_common/views.py11
3 files changed, 35 insertions, 3 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index a69c65f0e..8acd5ffcc 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -698,7 +698,7 @@ def get_form_selection(
class_name, label, key, model, base_form, get_url,
not_selected_error=_(u"You should select an item."), new=False,
new_message=_(u"Add a new item"), get_full_url=None,
- gallery=False, map=False):
+ gallery=False, map=False, base_form_select=None):
"""
Generate a class selection form
class_name -- name of the class
@@ -746,7 +746,9 @@ def get_form_selection(
return cleaned_data
attrs['clean'] = clean
attrs['SEARCH_AND_SELECT'] = True
- return type(class_name, (forms.Form,), attrs)
+ if not base_form_select:
+ base_form_select = forms.Form
+ return type(class_name, (base_form_select,), attrs)
def get_data_from_formset(data):
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 93e1839f0..dd55f95b4 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1378,6 +1378,27 @@ class QADocumentFormMulti(QAForm):
]
+class QALockForm(forms.Form):
+ action = forms.ChoiceField(
+ label=_("Action"), choices=(('lock', _("Lock")),
+ ('unlock', _("Unlock"))))
+
+ def __init__(self, *args, **kwargs):
+ self.items = kwargs.pop('items')
+ super(QALockForm, self).__init__(*args, **kwargs)
+
+ def save(self, items, user):
+ locked = self.cleaned_data["action"] == "lock"
+ for item in items:
+ item.locked = locked
+ if locked:
+ item.lock_user = user
+ else:
+ item.lock_user = None
+ item.skip_history_when_saving = True
+ item.save()
+
+
class SourceDeletionForm(FinalForm):
confirm_msg = " "
confirm_end_msg = _(u"Would you like to delete this documentation?")
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 4ab94aae9..c663eccbc 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -2126,7 +2126,7 @@ class QAItemForm(IshtarMixin, LoginRequiredMixin, FormView):
model = None
base_url = None
form_class = None
- page_name = u""
+ page_name = ""
success_url = "/success/"
modal_size = None # large, small or None (medium)
@@ -2218,6 +2218,15 @@ class QAItemEditForm(QAItemForm):
return HttpResponseRedirect(reverse("success"))
+class QABaseLockView(QAItemForm):
+ form_class = forms.QALockForm
+ page_name = _("lock/unlock")
+
+ def form_valid(self, form):
+ form.save(self.items, self.request.user)
+ return HttpResponseRedirect(reverse("success"))
+
+
class QAPersonForm(QAItemEditForm):
model = models.Person
form_class = forms.QAPersonFormMulti