From 9598665c383d0b1bd30584b60b0f3a2e196b6935 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Jul 2017 14:29:38 +0200 Subject: Fix find deletion when warehouse module is activated (refs #3649) --- archaeological_finds/wizards.py | 1 + ishtar_common/wizards.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py index 43fe6262f..b4471a80b 100644 --- a/archaeological_finds/wizards.py +++ b/archaeological_finds/wizards.py @@ -83,6 +83,7 @@ class FindModificationWizard(FindWizard): class FindDeletionWizard(DeletionWizard): model = models.Find + main_item_select_keys = ('selec-', 'selecw-') fields = ['label', 'material_types', 'datings', 'find_number', 'object_types', 'description', 'conservatory_state', 'mark', 'preservation_to_considers', 'integrities', 'remarkabilities', diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 8d787d733..3f90f8c48 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1232,10 +1232,11 @@ class DeletionWizard(Wizard): def done(self, form_list, **kwargs): obj = self.get_current_object() - try: - obj.delete() - except ObjectDoesNotExist: - pass + if obj: + try: + obj.delete() + except ObjectDoesNotExist: + pass return render_to_response( 'ishtar/wizard/wizard_delete_done.html', {}, context_instance=RequestContext(self.request)) -- cgit v1.2.3 From 25bc49ad788b6ffe640d7306c20a6341cd1d6a90 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Jul 2017 14:49:07 +0200 Subject: v0.99.23 --- CHANGES.md | 11 +++++++++++ version.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 20a3113db..d936b7cb2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,17 @@ Ishtar changelog ================ +v0.99.23 (2017-07-11) +--------------------- +### Features ### +- Tests: add show-* tests +- Tests: improve wizard test management + +### Bug fixes ### +- Fix find deletion when warehouse module is activated +- Archaeologivcal files: safely manage is_preventive test if preventive type is not created - show-file test +- Account : fix form initialization when raw name is empty + v0.99.22 (2017-06-30) --------------------- ### Features ### diff --git a/version.py b/version.py index 9c03d80c5..e7ae337c7 100644 --- a/version.py +++ b/version.py @@ -1,4 +1,4 @@ -VERSION = (0, 99, 22) +VERSION = (0, 99, 23) def get_version(): -- cgit v1.2.3 From f2e2d4f7c7172cc84c14613ea4049ae54e75d818 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 12 Jul 2017 00:03:40 +0200 Subject: Find deletion tests --- archaeological_finds/tests.py | 34 ++++++++++++++++++++++++++++++++-- archaeological_finds/views.py | 7 +++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index b6382b720..41e113245 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -26,7 +26,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse from django.test.client import Client from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\ - FormaterType, ImportTarget + FormaterType, ImportTarget, IshtarSiteProfile from ishtar_common.models import Person, get_current_profile from archaeological_context_records.models import Period, Dating @@ -92,7 +92,6 @@ class FindInit(ContextRecordInit): class FindWizardCreationTest(WizardTest, FindInit, TestCase): - # TODO: first to be run because of strange init things... fixtures = [settings.ROOT_PATH + '../fixtures/initial_data.json', settings.ROOT_PATH + @@ -149,6 +148,37 @@ class FindWizardCreationTest(WizardTest, FindInit, TestCase): self.find_number + 1) +class FindWizardDeletionWithWarehouseModTest(WizardTest, FindInit, TestCase): + fixtures = FindWizardCreationTest.fixtures + url_name = 'find_deletion' + wizard_name = 'find_deletion_wizard' + steps = views.find_deletion_steps + form_datas = [ + FormData( + 'Find deletion', + form_datas={ + 'selecw': {}, + }, + ignored=['selec-find_deletion'] + ) + ] + + def pre_wizard(self): + profile, created = IshtarSiteProfile.objects.get_or_create( + slug='default', active=True) + profile.warehouse = True + profile.save() + + find, bf = self.get_default_find(force=True) + self.form_datas[0].set('selecw', 'pk', find.pk) + self.find_number = models.Find.objects.count() + super(FindWizardDeletionWithWarehouseModTest, self).pre_wizard() + + def post_wizard(self): + self.assertEqual(models.Find.objects.count(), + self.find_number - 1) + + class TreatmentWizardCreationTest(WizardTest, FindInit, TestCase): fixtures = [settings.ROOT_PATH + '../fixtures/initial_data.json', diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 680faf421..2e84757c9 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -181,10 +181,13 @@ find_deletion_condition_dict = { 'selecw-find_deletion': check_warehouse_module, } -find_deletion_wizard = FindDeletionWizard.as_view([ +find_deletion_steps = [ ('selec-find_deletion', FindFormSelection), ('selecw-find_deletion', FindFormSelectionWarehouseModule), - ('final-find_deletion', FindDeletionForm)], + ('final-find_deletion', FindDeletionForm)] + +find_deletion_wizard = FindDeletionWizard.as_view( + find_deletion_steps, condition_dict=find_deletion_condition_dict, label=_(u"Find deletion"), url_name='find_deletion',) -- cgit v1.2.3