def test_upload_interactive_cabinet_selection_view_with_access(self): WizardStep.deregister_all() WizardStep.reregister(name=WizardStepCabinets.name) self._create_test_cabinet() self.grant_access(permission=permission_document_create, obj=self.test_document_type) response = self._request_wizard_view() self.assertEqual(response.status_code, 200)
def get_form_kwargs(self, wizard): return { 'help_text': _('Tags to be attached.'), 'model': Tag, 'permission': permission_tag_attach, 'user': wizard.request.user } @classmethod def done(cls, wizard): result = {} cleaned_data = wizard.get_cleaned_data_for_step(cls.name) if cleaned_data: result['tags'] = [ force_text(tag.pk) for tag in cleaned_data['tags'] ] return result @classmethod def step_post_upload_process(cls, document, querystring=None): Tag = apps.get_model(app_label='tags', model_name='Tag') tag_id_list = URL(query_string=querystring).args.getlist('tags') for tag in Tag.objects.filter(pk__in=tag_id_list): tag.documents.add(document) WizardStep.register(step=WizardStepTags)
document_type_metadata_type.metadata_type, }) return initial @classmethod def done(cls, wizard): result = {} cleaned_data = wizard.get_cleaned_data_for_step(cls.name) if cleaned_data: for identifier, metadata in enumerate( wizard.get_cleaned_data_for_step(cls.name)): if metadata.get('update'): result['metadata%s_metadata_type_id' % identifier] = metadata['metadata_type_id'] result['metadata%s_value' % identifier] = metadata['value'] return result @classmethod def step_post_upload_process(cls, document, querystring=None): metadata_dict_list = decode_metadata_from_querystring( querystring=querystring) if metadata_dict_list: save_metadata_list(metadata_list=metadata_dict_list, document=document, create=True) WizardStep.register(step=WizardStepMetadata)
def tearDown(self): super(CabinetDocumentUploadTestCase, self).tearDown() WizardStep.reregister_all()
@classmethod def get_form_kwargs(self, wizard): return { 'help_text': _('Cabinets to which the document will be added.'), 'permission': permission_cabinet_add_document, 'queryset': Cabinet.objects.all(), 'user': wizard.request.user } @classmethod def done(cls, wizard): result = {} cleaned_data = wizard.get_cleaned_data_for_step(cls.name) if cleaned_data: result['cabinets'] = [ force_text(s=cabinet.pk) for cabinet in cleaned_data['cabinets'] ] return result @classmethod def step_post_upload_process(cls, document, querystring=None): Cabinet = apps.get_model(app_label='cabinets', model_name='Cabinet') cabinet_id_list = URL(query_string=querystring).args.getlist('cabinets') for cabinet in Cabinet.objects.filter(pk__in=cabinet_id_list): cabinet.documents.add(document) WizardStep.register(WizardStepCabinets)