From 7b3d65bf870767994e9400b4b029adb4c6541f23 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 16 May 2017 19:10:16 +0200 Subject: Finds: fix full CSV export columns --- archaeological_finds/models_finds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 668546602..9a993ad37 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -559,6 +559,7 @@ class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms, } EXTRA_FULL_FIELDS = [ + 'datings', 'base_finds__cache_short_id', 'base_finds__cache_complete_id', 'base_finds__comment', 'base_finds__description', 'base_finds__topographic_localisation', @@ -600,7 +601,6 @@ class Find(ValueGetter, BaseHistorizedItem, ImageModel, OwnPerms, 'base_finds__context_record__operation__code_patriarche': 'base_finds__context_record__operation__code_patriarche', 'datings__period': 'datings__period__pk', - 'material_types': 'material_types__pk', 'base_finds__find__description': 'base_finds__find__description__icontains', 'base_finds__batch': 'base_finds__batch', -- cgit v1.2.3 From 5960b5165179fa68cab83657cce6b936fcda1fc5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 16 May 2017 19:40:55 +0200 Subject: Import fixture: fix find export --- ishtar_common/fixtures/initial_importtypes-fr.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ishtar_common/fixtures/initial_importtypes-fr.json b/ishtar_common/fixtures/initial_importtypes-fr.json index bd3330f7d..511a1fc7d 100644 --- a/ishtar_common/fixtures/initial_importtypes-fr.json +++ b/ishtar_common/fixtures/initial_importtypes-fr.json @@ -393,7 +393,7 @@ "required": true, "label": "Label mobilier", "importer_type": 20, - "export_field_name": null + "export_field_name": "label" } }, { @@ -718,7 +718,7 @@ "required": false, "label": "P\u00e9riodes", "importer_type": 20, - "export_field_name": null + "export_field_name": "datings__period__label" } }, { -- cgit v1.2.3 From e25ebecf8304b927ad8e75aefa1e1886dab2efeb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 May 2017 11:15:07 +0200 Subject: Operation wizard: collaborators in a specific panel (refs #3595) --- archaeological_operations/forms.py | 16 ++++++++++++---- archaeological_operations/views.py | 2 ++ ishtar_common/widgets.py | 6 +++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 86bea4ed5..b9e68980f 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -759,11 +759,9 @@ class DashboardForm(forms.Form): class OperationFormGeneral(ManageOldType, forms.Form): form_label = _(u"General") - base_models = ['collaborator'] file_upload = True associated_models = {'scientist': Person, 'in_charge': Person, - 'collaborator': Person, 'cira_rapporteur': Person, 'operator': Organization, 'operation_type': models.OperationType, @@ -819,8 +817,6 @@ class OperationFormGeneral(ManageOldType, forms.Form): limit={'person_types': [person_type_pk_lazy('sra_agent')]}, new=True), validators=[valid_id(Person)], required=False) - collaborator = widgets.Select2MultipleField( - model=Person, label=_("Collaborators"), required=False, remote=True) surface = forms.IntegerField( required=False, widget=widgets.AreaWidget, label=_(u"Total surface (m2)"), @@ -989,6 +985,18 @@ OperationFormModifGeneral.associated_models = \ OperationFormModifGeneral.associated_models['associated_file'] = File +class CollaboratorForm(forms.Form): + form_label = _(u"Collaborators") + base_models = ['collaborator'] + associated_models = {'collaborator': Person, } + collaborator = widgets.Select2MultipleField( + model=Person, label=_("Collaborators"), required=False, remote=True) + + def __init__(self, *args, **kwargs): + super(CollaboratorForm, self).__init__(*args, **kwargs) + self.fields['collaborator'].widget.attrs['style'] = 'width: 100%' + + class OperationFormPreventive(forms.Form): form_label = _(u"Preventive informations - excavation") cost = forms.IntegerField(label=_(u"Cost (euros)"), required=False) diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 9b420f594..24271bb8f 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -171,6 +171,7 @@ operation_search_wizard = SearchWizard.as_view( wizard_steps = [ ('filechoice-operation_creation', OperationFormFileChoice), ('general-operation_creation', OperationFormGeneral), + ('collaborators-operation_creation', CollaboratorForm), ('archaeologicalsite-operation_creation', ArchaeologicalSiteFormSet), ('preventive-operation_creation', OperationFormPreventive), ('preventivediag-operation_creation', OperationFormPreventiveDiag), @@ -227,6 +228,7 @@ operation_creation_wizard = OperationWizard.as_view( operation_modif_wizard_steps = [ ('selec-operation_modification', OperationFormSelection), ('general-operation_modification', OperationFormModifGeneral), + ('collaborators-operation_modification', CollaboratorForm), ('archaeologicalsite-operation_modification', ArchaeologicalSiteFormSet), ('preventive-operation_modification', OperationFormPreventive), ('preventivediag-operation_modification', OperationFormPreventiveDiag), diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index b0f28a6cf..12db821c5 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -82,12 +82,16 @@ class Select2Multiple(forms.SelectMultiple): self.remote = None if not choices and not self.remote and self.model: choices = self.get_choices() + new_attrs = self.attrs.copy() + new_attrs.update(attrs) + attrs = new_attrs klass = attrs and attrs.get('class') or '' klass += ' ' if klass else '' + 'js-select2' if not attrs: attrs = {} attrs['class'] = klass - attrs['style'] = "width: 370px" + if 'style' not in attrs: + attrs['style'] = "width: 370px" options = "" if self.remote: options = """{ -- cgit v1.2.3 From 8451333f4e1a3cdaab05650141b154d2e5ee54fd Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 May 2017 11:27:19 +0200 Subject: Autocomplete: on no result return an empty list instead of an empty string --- ishtar_common/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index f185576ea..d1ba4478f 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -454,7 +454,7 @@ def autocomplete_person(request, person_types=None, attached_to=None, own_items = request.user.has_perm('ishtar_common.view_own_person', models.Person) if not all_items and not own_items or not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') q = request.GET.get('term') limit = request.GET.get('limit', 20) try: @@ -490,7 +490,7 @@ def autocomplete_person(request, person_types=None, attached_to=None, def autocomplete_department(request): if not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') q = request.GET.get('term') q = unicodedata.normalize("NFKD", q).encode('ascii', 'ignore') query = Q() @@ -1325,9 +1325,9 @@ def autocomplete_organization(request, orga_type=None): models.Organization) and not request.user.ishtaruser.has_right( 'person_search', session=request.session)): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') if not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') q = request.GET.get('term') query = Q() for q in q.split(' '): @@ -1351,9 +1351,9 @@ def autocomplete_author(request): if not request.user.has_perm('ishtar_common.view_author', models.Author)\ and not request.user.has_perm('ishtar_common.view_own_author', models.Author): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') if not request.GET.get('term'): - return HttpResponse(mimetype='text/plain') + return HttpResponse('[]', mimetype='text/plain') q = request.GET.get('term') query = Q() for q in q.split(' '): -- cgit v1.2.3 From e5dc6268a843e216ccf14469447d9b6f1ad43b49 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 May 2017 11:50:39 +0200 Subject: Operation wizard: collaborator panel more explicit style (refs #3595) --- archaeological_operations/forms.py | 2 +- ishtar_common/static/media/style.css | 4 ++++ ishtar_common/widgets.py | 14 ++++++++++++-- version.py | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index b9e68980f..8fd9233d2 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -994,7 +994,7 @@ class CollaboratorForm(forms.Form): def __init__(self, *args, **kwargs): super(CollaboratorForm, self).__init__(*args, **kwargs) - self.fields['collaborator'].widget.attrs['style'] = 'width: 100%' + self.fields['collaborator'].widget.attrs['full-width'] = True class OperationFormPreventive(forms.Form): diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 4e59b0f64..0016ca0e5 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -1483,6 +1483,10 @@ input.widget-oa{ /* select2 overload */ +.select2-container--default .full-width.select2-selection--multiple .select2-selection__choice{ + float: none; +} + .select2-container-multi .select2-choices .select2-search-field { min-width:233px; } diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 12db821c5..42a93ddaa 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -58,7 +58,7 @@ class Select2Multiple(forms.SelectMultiple): css = { 'all': ('select2/css/select2.css',) } - js = ['select2/js/select2.min.js'] + js = ['select2/js/select2.full.min.js'] for lang_code, lang in settings.LANGUAGES: js.append('select2/js/i18n/{}.js'.format(lang_code)) media.add_css(css) @@ -91,7 +91,11 @@ class Select2Multiple(forms.SelectMultiple): attrs = {} attrs['class'] = klass if 'style' not in attrs: - attrs['style'] = "width: 370px" + if attrs.get('full-width', None): + attrs['style'] = "width: 100%" + else: + attrs['style'] = "width: 370px" + options = "" if self.remote: options = """{ @@ -124,6 +128,12 @@ class Select2Multiple(forms.SelectMultiple): except (self.model.DoesNotExist, ValueError): # an old reference? it should not happen pass + if attrs.get('full-width', None): + if options: + options = options[:-1] + ", " + else: + options = "{" + options += " containerCssClass: 'full-width'}" html = super(Select2Multiple, self).render(name, value, attrs, choices) html += """