summaryrefslogtreecommitdiff
path: root/archaeological_context_records/wizards.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-19 11:09:10 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-19 11:09:10 +0100
commiteb4565bbab91e2942b19fb107b3d7c51d2c7afa9 (patch)
treebfa6fbf20d7c7b7b3eedebb79bae8ecd4e0759f1 /archaeological_context_records/wizards.py
parente2d6c50f231f636fed362be37e7bf3319fc5d6b8 (diff)
downloadIshtar-eb4565bbab91e2942b19fb107b3d7c51d2c7afa9.tar.bz2
Ishtar-eb4565bbab91e2942b19fb107b3d7c51d2c7afa9.zip
Format - black: context_records
Diffstat (limited to 'archaeological_context_records/wizards.py')
-rw-r--r--archaeological_context_records/wizards.py90
1 files changed, 50 insertions, 40 deletions
diff --git a/archaeological_context_records/wizards.py b/archaeological_context_records/wizards.py
index 53f13c481..da1364b28 100644
--- a/archaeological_context_records/wizards.py
+++ b/archaeological_context_records/wizards.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2012-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
@@ -32,15 +32,15 @@ class RecordSearch(SearchWizard):
class RecordWizard(Wizard):
model = models.ContextRecord
edit = False
- wizard_done_window = reverse_lazy('show-contextrecord')
- relations_step_key = 'relations'
- redirect_url = 'record_modification'
+ wizard_done_window = reverse_lazy("show-contextrecord")
+ relations_step_key = "relations"
+ redirect_url = "record_modification"
def get_template_names(self):
templates = super(RecordWizard, self).get_template_names()
current_step = self.steps.current
if current_step.startswith(self.relations_step_key):
- templates = ['ishtar/wizard/relations_wizard.html'] + templates
+ templates = ["ishtar/wizard/relations_wizard.html"] + templates
return templates
def get_current_operation(self):
@@ -48,23 +48,21 @@ class RecordWizard(Wizard):
if not step:
return
# manage manualy on creation
- if step.endswith('_creation'): # an operation has been selected
- main_form_key = 'selec-' + self.url_name
+ if step.endswith("_creation"): # an operation has been selected
+ main_form_key = "selec-" + self.url_name
try:
- idx = int(self.session_get_value(
- main_form_key, 'operation_id'))
+ idx = int(self.session_get_value(main_form_key, "operation_id"))
current_ope = models.Operation.objects.get(pk=idx)
return current_ope
- except(TypeError, ValueError, ObjectDoesNotExist):
+ except (TypeError, ValueError, ObjectDoesNotExist):
pass
else:
- ope_form_key = 'operation-' + self.url_name
+ ope_form_key = "operation-" + self.url_name
try:
- idx = int(self.session_get_value(
- ope_form_key, 'operation'))
+ idx = int(self.session_get_value(ope_form_key, "operation"))
current_ope = models.Operation.objects.get(pk=idx)
return current_ope
- except(TypeError, ValueError, ObjectDoesNotExist):
+ except (TypeError, ValueError, ObjectDoesNotExist):
pass
current_cr = self.get_current_object()
if current_cr:
@@ -77,9 +75,9 @@ class RecordWizard(Wizard):
context = super(RecordWizard, self).get_context_data(form)
operation = self.get_current_operation()
- if not operation or self.steps.current.startswith('selec-'):
+ if not operation or self.steps.current.startswith("selec-"):
return context
- context['reminders'] = ((_("Operation"), str(operation)),)
+ context["reminders"] = ((_("Operation"), str(operation)),)
return context
def get_form(self, step=None, data=None, files=None):
@@ -96,30 +94,28 @@ class RecordWizard(Wizard):
form = self.get_form_list()[step]
# general_form_key = 'general-' + self.url_name
- if step.startswith('general-'):
- if step.endswith('_creation'): # an operation has been selected
- main_form_key = 'selec-' + self.url_name
+ if step.startswith("general-"):
+ if step.endswith("_creation"): # an operation has been selected
+ main_form_key = "selec-" + self.url_name
try:
- idx = int(self.session_get_value(main_form_key,
- 'operation_id'))
+ idx = int(self.session_get_value(main_form_key, "operation_id"))
current_obj = models.Operation.objects.get(pk=idx)
- data['operation'] = current_obj
- except(TypeError, ValueError, ObjectDoesNotExist):
+ data["operation"] = current_obj
+ except (TypeError, ValueError, ObjectDoesNotExist):
pass
- elif step.endswith('_modification'):
- ope_form_key = 'operation-' + self.url_name
+ elif step.endswith("_modification"):
+ ope_form_key = "operation-" + self.url_name
try:
- idx = int(self.session_get_value(ope_form_key,
- 'operation'))
+ idx = int(self.session_get_value(ope_form_key, "operation"))
current_obj = models.Operation.objects.get(pk=idx)
- data['operation'] = current_obj
- except(TypeError, ValueError, ObjectDoesNotExist):
+ data["operation"] = current_obj
+ except (TypeError, ValueError, ObjectDoesNotExist):
pass
else:
current_object = self.get_current_object()
- data['context_record'] = current_object
- elif step.startswith('relations') and hasattr(form, 'management_form'):
- data['CONTEXT_RECORDS'] = self.get_other_context_records()
+ data["context_record"] = current_object
+ elif step.startswith("relations") and hasattr(form, "management_form"):
+ data["CONTEXT_RECORDS"] = self.get_other_context_records()
form = super(RecordWizard, self).get_form(step, data, files)
return form
@@ -137,11 +133,10 @@ class RecordWizard(Wizard):
class RecordModifWizard(RecordWizard):
modification = True
model = models.ContextRecord
- filter_owns = {'selec-record_modification': ['pk']}
+ filter_owns = {"selec-record_modification": ["pk"]}
def get_form_kwargs(self, step, **kwargs):
- kwargs = super(RecordModifWizard, self).get_form_kwargs(
- step, **kwargs)
+ kwargs = super(RecordModifWizard, self).get_form_kwargs(step, **kwargs)
if step != "relations-record_modification":
return kwargs
kwargs["left_record"] = self.get_current_object()
@@ -150,9 +145,24 @@ class RecordModifWizard(RecordWizard):
class RecordDeletionWizard(MultipleDeletionWizard):
model = models.ContextRecord
- fields = ['label', 'parcel', 'description', 'length', 'width', 'thickness',
- 'depth', 'location', 'datings', 'units', 'documentations',
- 'filling', 'interpretation', 'taq', 'taq_estimated', 'tpq',
- 'tpq_estimated']
- filter_owns = {'selec-record_deletion': ['pks']}
+ fields = [
+ "label",
+ "parcel",
+ "description",
+ "length",
+ "width",
+ "thickness",
+ "depth",
+ "location",
+ "datings",
+ "units",
+ "documentations",
+ "filling",
+ "interpretation",
+ "taq",
+ "taq_estimated",
+ "tpq",
+ "tpq_estimated",
+ ]
+ filter_owns = {"selec-record_deletion": ["pks"]}
redirect_url = "record_deletion"