diff options
| -rw-r--r-- | archaeological_finds/models_finds.py | 2 | ||||
| -rw-r--r-- | archaeological_operations/forms.py | 16 | ||||
| -rw-r--r-- | archaeological_operations/views.py | 2 | ||||
| -rw-r--r-- | ishtar_common/fixtures/initial_importtypes-fr.json | 4 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 4 | ||||
| -rw-r--r-- | ishtar_common/views.py | 12 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 18 | ||||
| -rw-r--r-- | version.py | 4 | 
8 files changed, 45 insertions, 17 deletions
| diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 8d4945a0b..632df91f5 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -562,6 +562,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,      }      EXTRA_FULL_FIELDS = [ +        'datings',          'base_finds__cache_short_id', 'base_finds__cache_complete_id',          'base_finds__comment', 'base_finds__description',          'base_finds__topographic_localisation', @@ -603,7 +604,6 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel,          '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', diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index b280e982e..32b37e4c3 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)"), @@ -994,6 +990,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['full-width'] = True + +  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 d3f239bbd..545f42b89 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/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"          }      },       { 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/views.py b/ishtar_common/views.py index fe0693d7b..a70bb0c30 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -458,7 +458,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(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      q = request.GET.get('term')      limit = request.GET.get('limit', 20)      try: @@ -494,7 +494,7 @@ def autocomplete_person(request, person_types=None, attached_to=None,  def autocomplete_department(request):      if not request.GET.get('term'): -        return HttpResponse(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      q = request.GET.get('term')      q = unicodedata.normalize("NFKD", q).encode('ascii', 'ignore')      query = Q() @@ -1338,9 +1338,9 @@ def autocomplete_organization(request, orga_type=None):                                    models.Organization)         and not request.user.ishtaruser.has_right(              'person_search', session=request.session)): -        return HttpResponse(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      if not request.GET.get('term'): -        return HttpResponse(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      q = request.GET.get('term')      query = Q()      for q in q.split(' '): @@ -1364,9 +1364,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(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      if not request.GET.get('term'): -        return HttpResponse(content_type='text/plain') +        return HttpResponse('[]', content_type='text/plain')      q = request.GET.get('term')      query = Q()      for q in q.split(' '): diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index b00cad3d8..0a80bb895 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) @@ -82,12 +82,20 @@ 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: +            if attrs.get('full-width', None): +                attrs['style'] = "width: 100%" +            else: +                attrs['style'] = "width: 370px" +          options = ""          if self.remote:              options = """{ @@ -120,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 += """<script type="text/javascript"> diff --git a/version.py b/version.py index cf55cff12..efadf2154 100644 --- a/version.py +++ b/version.py @@ -1,5 +1,5 @@ -# 1.99.0 -VERSION = (1, 99, 0) +# 1.99.1 +VERSION = (1, 99, 1)  def get_version(): | 
