summaryrefslogtreecommitdiff
path: root/archaeological_operations
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 /archaeological_operations
parent58178a04b3e716a063b1c457018aafe28e5107dd (diff)
downloadIshtar-3dae10a792d49d685debfe52eb7d61b9a6dc93f9.tar.bz2
Ishtar-3dae10a792d49d685debfe52eb7d61b9a6dc93f9.zip
QA: lock/unlock (sites, operations, context records, finds, containers, warehouses)
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/forms.py2
-rw-r--r--archaeological_operations/models.py22
-rw-r--r--archaeological_operations/urls.py8
-rw-r--r--archaeological_operations/views.py12
4 files changed, 38 insertions, 6 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 1e12c3614..b79447d9f 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -1375,7 +1375,7 @@ class SiteSelect(HistorySelect):
self.fields.pop('drassm_number')
-class SiteFormSelection(IshtarForm):
+class SiteFormSelection(CustomFormSearch):
SEARCH_AND_SELECT = True
associated_models = {'pk': models.ArchaeologicalSite}
currents = {'pk': models.ArchaeologicalSite}
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index c2e4e618b..6a25490d7 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -111,7 +111,7 @@ post_delete.connect(post_save_cache, sender=RecordQualityType)
class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
- GeoItem, OwnPerms, ValueGetter, ShortMenuItem):
+ GeoItem, OwnPerms, ValueGetter, MainItem):
SLUG = 'site'
APP = "archaeological-operations"
MODEL = "archaeological-site"
@@ -256,6 +256,15 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
'cached_remains']
DOWN_MODEL_UPDATE = ["context_records"]
+ QA_LOCK = QuickAction(
+ url="contextrecord-qa-lock", icon_class="fa fa-lock",
+ text=_(u"Lock/Unlock"), target="many",
+ rights=['change_contextrecord', 'change_own_contextrecord']
+ )
+ QUICK_ACTIONS = [
+ QA_LOCK
+ ]
+
objects = SiteManager()
reference = models.CharField(_("Reference"), max_length=200, unique=True)
@@ -870,9 +879,14 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
QA_EDIT = QuickAction(
url="operation-qa-bulk-update", icon_class="fa fa-pencil",
text=_(u"Bulk update"), target="many",
- rights=['change_operation', 'change_own_operation'])
+ )
+ QA_LOCK = QuickAction(
+ url="operation-qa-lock", icon_class="fa fa-lock",
+ text=_(u"Lock/Unlock"), target="many",
+ rights=['change_operation', 'change_own_operation']
+ )
QUICK_ACTIONS = [
- QA_EDIT
+ QA_EDIT, QA_LOCK
]
UP_MODEL_QUERY = {
@@ -1284,7 +1298,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
actions = super(Operation, self).get_extra_actions(request)
can_add_cr = self.can_do(request, 'add_contextrecord')
- if can_add_cr:
+ if can_add_cr and not self.locked:
actions += [
(reverse('operation-qa-contextrecord', args=[self.pk]),
_("Add context record"), "fa fa-plus",
diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py
index 1cb66de6f..38dbe2cbf 100644
--- a/archaeological_operations/urls.py
+++ b/archaeological_operations/urls.py
@@ -176,4 +176,12 @@ urlpatterns = [
check_rights(['change_operation', 'change_own_operation'])(
views.QAOperationForm.as_view()),
name='operation-qa-bulk-update-confirm', kwargs={"confirm": True}),
+
+ url(r'^operation-qa-lock/(?P<pks>[0-9-]+)?/$',
+ views.QAOperationLockView.as_view(), name='operation-qa-lock',
+ kwargs={"model": models.Operation}),
+
+ url(r'^site-qa-lock/(?P<pks>[0-9-]+)?/$',
+ views.QASiteLockView.as_view(), name='site-qa-lock',
+ kwargs={"model": models.ArchaeologicalSite}),
]
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index d8d9f30d5..0d69d72f3 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -52,7 +52,7 @@ from ishtar_common.forms import ClosingDateFormSelection, FinalForm, \
from ishtar_common.models import get_current_profile, IshtarSiteProfile, \
DocumentTemplate
from ishtar_common.utils import put_session_message, check_rights_condition
-from ishtar_common.views import gen_generate_doc, QAItemEditForm
+from ishtar_common.views import gen_generate_doc, QAItemEditForm, QABaseLockView
from ishtar_common.views_item import get_item, show_item, revert_item, new_item
from ishtar_common.wizards import SearchWizard
@@ -581,3 +581,13 @@ def reset_wizards(request):
class QAOperationForm(QAItemEditForm):
model = models.Operation
form_class = QAOperationFormMulti
+
+
+class QAOperationLockView(QABaseLockView):
+ model = models.Operation
+ base_url = "operation-qa-lock"
+
+
+class QASiteLockView(QABaseLockView):
+ model = models.ArchaeologicalSite
+ base_url = "site-qa-lock"