summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_context_records/tests.py2
-rw-r--r--archaeological_finds/wizards.py4
-rw-r--r--archaeological_operations/tests.py31
-rw-r--r--archaeological_operations/wizards.py2
-rw-r--r--ishtar_common/tests.py7
-rw-r--r--ishtar_common/wizards.py2
6 files changed, 42 insertions, 6 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index adfb56b01..cbb5e0775 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -725,7 +725,7 @@ class RecordRelationsTest(ContextRecordInit, TestCase):
self.create_context_record({"label": u"CR 1"})
self.create_context_record({"label": u"CR 2"})
- def testRelations(self):
+ def test_relations(self):
sym_rel_type = models.RelationType.objects.create(
symmetrical=True, txt_idx='sym')
rel_type_1 = models.RelationType.objects.create(
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index 42a1e603a..0e7828eca 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -403,8 +403,8 @@ class Treatment1NWizard(TreatmentBase):
class TreatmentDeletionWizard(DeletionWizard):
- wizard_confirm = 'ishtar/wizard/wizard_treatement_deletion.html'
model = models.Treatment
+ wizard_confirm = 'ishtar/wizard/wizard_treatement_deletion.html'
fields = ['label', 'other_reference', 'year', 'index',
'treatment_types', 'location', 'person', 'organization',
'external_id', 'comment', 'description',
@@ -504,5 +504,5 @@ class FindBasketEditWizard(FindBasketWizard):
class FindBasketDeletionWizard(DeletionWizard):
- wizard_confirm = 'ishtar/wizard/wizard_findbasket_deletion.html'
model = models.FindBasket
+ wizard_confirm = 'ishtar/wizard/wizard_findbasket_deletion.html'
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 3f35de73b..e1f29b293 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -37,6 +37,7 @@ from django.contrib.auth.models import User, Permission
from django.utils.translation import ugettext_lazy as _, pgettext, pgettext_lazy
from . import models
+from ishtar_common.views import document_deletion_steps
from archaeological_operations import views
from ishtar_common.models import OrganizationType, Organization, ItemKey, \
@@ -2805,3 +2806,33 @@ class DocumentTest(OperationInitTest, TestCase):
self.assertIn(posted["title"], response.content.decode())
+class DocumentWizardDeleteTest(WizardTest, OperationInitTest, TestCase):
+ fixtures = FILE_FIXTURES
+ url_name = 'document_deletion'
+ url_uri = "document/delete"
+ wizard_name = 'document_deletion_wizard'
+ steps = document_deletion_steps
+ form_datas = [
+ FormData(
+ "Delete document",
+ form_datas={
+ 'selec': {'pk': None},
+ },
+ ),
+ ]
+
+ def pre_wizard(self):
+ ope = self.get_default_operation()
+ document = Document.objects.create(title="testy")
+ document.operations.add(ope)
+ self.ope_id = ope.pk
+ self.form_datas[0].set('selec', 'pk', document.pk)
+ self.doc_nb = Document.objects.count()
+ super(DocumentWizardDeleteTest, self).pre_wizard()
+
+ def post_wizard(self):
+ self.assertEqual(Document.objects.count(),
+ self.doc_nb - 1)
+ # operation not deleted with the document
+ self.assertEqual(models.Operation.objects.filter(
+ pk=self.ope_id).count(), 1)
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 18a40f040..140a2a03a 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -449,12 +449,12 @@ class SiteDeletionWizard(SiteLabel, DeletionWizard):
class AdministrativeActDeletionWizard(ClosingWizard):
+ model = models.AdministrativeAct
wizard_templates = {
'final-operation_administrativeactop_deletion':
'ishtar/wizard/wizard_adminact_deletion.html',
'final-file_administrativeactfile_deletion':
'ishtar/wizard/wizard_adminact_deletion.html'}
- model = models.AdministrativeAct
fields = ['act_type', 'in_charge', 'operator', 'scientist', 'signatory',
'operation', 'associated_file', 'signature_date', 'act_object']
if settings.COUNTRY == 'fr':
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 03f8e3a69..9f97fd33b 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -330,6 +330,7 @@ class ManagedModelTestRunner(DiscoverRunner):
class WizardTest(object):
url_name = None
+ url_uri = None
wizard_name = ''
steps = None
condition_dict = None
@@ -416,7 +417,7 @@ class WizardTest(object):
next_form = self.steps[idx + 1][0]
self.assertRedirects(
response,
- '/{}/{}'.format(self.url_name, next_form),
+ '/{}/{}'.format(self.url_uri, next_form),
msg_prefix="Dataset n{} Redirection to {} has failed - "
"Error on previous form ({})?".format(
data_idx + 1, next_form, current_step)
@@ -425,13 +426,15 @@ class WizardTest(object):
# last form
self.assertRedirects(
response,
- '/{}/done'.format(self.url_name))
+ '/{}/done'.format(self.url_uri))
return response
def test_wizard(self):
if self.pass_test():
return
url = reverse(self.url_name)
+ if not self.url_uri:
+ self.url_uri = self.url_name
self.pre_wizard()
for data_idx, test_form_data in enumerate(self.form_datas):
test_form_data.inits(self)
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index b5fe507b0..375004e67 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -1495,6 +1495,7 @@ class DeletionWizard(Wizard):
if (not hasattr(self, 'fields') or not self.fields) and \
(hasattr(self, 'model') and hasattr(self.model, 'TABLE_COLS')):
self.fields = self.model.TABLE_COLS
+ assert self.model
return super(DeletionWizard, self).__init__(*args, **kwargs)
def get_formated_datas(self, forms):
@@ -1812,6 +1813,7 @@ class SourceWizard(Wizard):
class DocumentDeletionWizard(DeletionWizard):
+ model = models.Document
fields = [
f.name for f in models.Document._meta.get_fields()
if f.name != 'id' and f.name not in models.Document.RELATED_MODELS]