def test_editor_can_make_object_with_slots(self): wizard_data = [ { 'dynamic_aristotle_wizard-current_step': 'initial', 'initial-name': 'My new object' }, { 'dynamic_aristotle_wizard-current_step': 'results', 'results-name': 'My new object', 'results-definition': 'Brand new' } ] slots_data = [ {'name': 'Extra', 'type': 'String', 'value': 'SomeExtraData', 'order': 0, 'permission': 0} ] formsets = utils.get_management_forms(self.model, item_is_model=True) formsets.update(self.get_formset_postdata(slots_data, 'slots')) wizard_data[1].update(formsets) self.login_editor() response = self.post_direct_to_wizard( wizard_data, self.wizard_url, self.step_names ) self.assertEqual(response.status_code, 302) item = models._concept.objects.get(name='My new object') self.assertEqual(item.definition, 'Brand new') slot = Slot.objects.get( concept=item, name='Extra' ) self.assertEqual(slot.value, 'SomeExtraData')
def test_editor_can_make_object_with_custom_values(self): cf = CustomField.objects.create( order=0, name='ExtraInfo', type='str', ) cf_field_name = 'results-{}'.format(cf.form_field_name) wizard_data = [{ 'dynamic_aristotle_wizard-current_step': 'initial', 'initial-name': 'My new object' }, { 'dynamic_aristotle_wizard-current_step': 'results', 'results-name': 'My new object', 'results-definition': 'Brand new', cf_field_name: 'SomeExtraInformation' }] formsets = utils.get_management_forms(self.model, item_is_model=True, slots=True) wizard_data[1].update(formsets) self.login_editor() response = self.post_direct_to_wizard(wizard_data, self.wizard_url, self.step_names) self.assertEqual(response.status_code, 302) concept = models._concept.objects.get(name='My new object') cv = CustomValue.objects.get(concept=concept, field=cf) self.assertEqual(cv.content, 'SomeExtraInformation')
def test_editor_can_make_object(self): self.login_editor() step_1_data = { self.wizard_form_name+'-current_step': 'initial', } response = self.client.post(self.wizard_url, step_1_data) wizard = response.context['wizard'] self.assertEqual(wizard['steps'].current, 'initial') self.assertTrue('name' in wizard['form'].errors.keys()) # must submit a name step_1_data.update({'initial-name':"Test Item"}) # success! response = self.client.post(self.wizard_url, step_1_data) wizard = response.context['wizard'] self.assertEqual(response.status_code, 200) self.assertEqual(wizard['steps'].current, 'results') self.do_test_for_issue333(response) step_2_data = { self.wizard_form_name+'-current_step': 'results', 'results-name':"Test Item", } management_forms = utils.get_management_forms(self.model, item_is_model=True, slots=True) step_2_data.update(management_forms) step_2_data.update(self.extra_step2_data) response = self.client.post(self.wizard_url, step_2_data) wizard = response.context['wizard'] self.assertTrue('definition' in wizard['form'].errors.keys()) # NOWG self.assertTrue('workgroup' in wizard['form'].errors.keys()) # no "test item" yet. self.assertFalse(models._concept.objects.filter(name="Test Item").exists()) # must submit a definition at this step. But we are using a non-permitted workgroup. step_2_data.update({ 'results-definition':"Test Definition", 'results-workgroup':self.wg2.id }) response = self.client.post(self.wizard_url, step_2_data) self.assertEqual(response.status_code, 200) wizard = response.context['wizard'] self.assertTrue('workgroup' in wizard['form'].errors.keys()) # must submit a definition at this step. With the right workgroup step_2_data.update({ 'results-definition':"Test Definition", 'results-workgroup':self.wg1.id }) response = self.client.post(self.wizard_url, step_2_data) self.assertEqual(response.status_code, 302) self.assertTrue(models._concept.objects.filter(name="Test Item").exists()) self.assertEqual(models._concept.objects.filter(name="Test Item").count(),1) item = models._concept.objects.filter(name="Test Item").first() self.assertRedirects(response,url_slugify_concept(item))
def test_editor_can_make_object_with_custom_values(self): cf = CustomField.objects.create( order=0, name='ExtraInfo', type='str', ) wizard_data = [ { 'dynamic_aristotle_wizard-current_step': 'initial', 'initial-name': 'My new object' }, { 'dynamic_aristotle_wizard-current_step': 'results', 'results-name': 'My new object', 'results-definition': 'Brand new', 'results-custom_ExtraInfo': 'SomeExtraInformation' } ] formsets = utils.get_management_forms(self.model, item_is_model=True, slots=True) wizard_data[1].update(formsets) self.login_editor() response = self.post_direct_to_wizard( wizard_data, self.wizard_url, self.step_names ) self.assertEqual(response.status_code, 302) concept = models._concept.objects.get(name='My new object') cv = CustomValue.objects.get( concept=concept, field=cf ) self.assertEqual(cv.content, 'SomeExtraInformation')