diff options
| -rw-r--r-- | Makefile.example | 1 | ||||
| -rw-r--r-- | archaeological_finds/admin.py | 9 | ||||
| -rw-r--r-- | archaeological_finds/forms.py | 31 | ||||
| -rw-r--r-- | archaeological_finds/migrations/0033_auto_20180813_1310.py | 5 | ||||
| -rw-r--r-- | archaeological_finds/migrations/0034_auto_20180814_1133.py | 23 | ||||
| -rw-r--r-- | archaeological_finds/models.py | 10 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 52 | ||||
| -rw-r--r-- | archaeological_warehouse/models.py | 4 | 
8 files changed, 85 insertions, 50 deletions
| diff --git a/Makefile.example b/Makefile.example index 3967a6565..1609d1091 100644 --- a/Makefile.example +++ b/Makefile.example @@ -206,6 +206,7 @@ fixtures_finds:  							archaeological_finds.objecttypequalitytype \  							archaeological_finds.integritytype \  							archaeological_finds.batchtype \ +							archaeological_finds.checkedtype \  							archaeological_finds.treatmentfiletype \  	   > '../archaeological_finds/fixtures/initial_data-'$(default_data)'.json' diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py index c85ac2425..7ab92475f 100644 --- a/archaeological_finds/admin.py +++ b/archaeological_finds/admin.py @@ -140,6 +140,7 @@ admin_site.register(models.TreatmentFile, TreatmentFileAdmin)  class HierarchicalTypeAdmin(GeneralTypeAdmin):      list_display = ['label', 'txt_idx', 'parent', 'available', 'comment'] +  admin_site.register(models.ObjectType, HierarchicalTypeAdmin) @@ -162,6 +163,14 @@ class TreatmentTypeAdmin(GeneralTypeAdmin):  admin_site.register(models.TreatmentType, TreatmentTypeAdmin) + +class CheckedTypeAdmin(GeneralTypeAdmin): +    list_display = GeneralTypeAdmin.list_display + ['order'] +    model = models.CheckedType + + +admin_site.register(models.CheckedType, CheckedTypeAdmin) +  general_models = [      models.ConservatoryState, models.RemarkabilityType,      models.IntegrityType, diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index b291f4417..358b12477 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -132,7 +132,8 @@ class FindForm(CustomForm, ManageOldType):          'get_first_base_find__batch': models.BatchType,          'get_first_base_find__spatial_reference_system': SpatialReferenceSystem,          'material_type_quality': models.MaterialTypeQualityType, -        'object_type_quality': models.ObjectTypeQualityType +        'object_type_quality': models.ObjectTypeQualityType, +        'checked_type': models.CheckedType,      }      HEADERS = {}      HEADERS['label'] = FormHeader(_(u"Identification")) @@ -225,8 +226,8 @@ class FindForm(CustomForm, ManageOldType):      get_first_base_find__estimated_error_z = \          forms.FloatField(label=_(u"Estimated error for Z"), required=False) -    HEADERS['checked'] = FormHeader(_(u"Sheet")) -    checked = forms.ChoiceField(label=_(u"Check")) +    HEADERS['checked_type'] = FormHeader(_(u"Sheet")) +    checked_type = forms.ChoiceField(label=_(u"Check"), required=False)      check_date = forms.DateField(          initial=get_now, label=_(u"Check date"), widget=DatePicker) @@ -240,6 +241,7 @@ class FindForm(CustomForm, ManageOldType):          FieldType('get_first_base_find__batch', models.BatchType),          FieldType('get_first_base_find__spatial_reference_system',                    SpatialReferenceSystem), +        FieldType('checked_type', models.CheckedType, is_multiple=True),      ]      PROFILE_FILTER = {          'mapping': [ @@ -257,7 +259,6 @@ class FindForm(CustomForm, ManageOldType):          if not context_record or \                  not context_record.operation.operation_type.judiciary:              self.fields.pop('seal_number') -        self.fields['checked'].choices = models.CHECK_CHOICES      def clean(self):          taq = self.cleaned_data.get('get_first_base_find__discovery_date_taq', @@ -452,12 +453,10 @@ class FindSelect(CustomForm, TableSelect):              reverse_lazy('autocomplete-contextrecord'),              associated_model=ContextRecord),          validators=[valid_id(ContextRecord)]) -    ope_relation_types = forms.MultipleChoiceField( -        label=_(u"Search within related operations"), choices=[], -        widget=widgets.CheckboxSelectMultiple) -    cr_relation_types = forms.MultipleChoiceField( -        label=_(u"Search within related context records"), choices=[], -        widget=widgets.CheckboxSelectMultiple) +    ope_relation_types = forms.ChoiceField( +        label=_(u"Search within related operations"), choices=[]) +    cr_relation_types = forms.ChoiceField( +        label=_(u"Search within related context records"), choices=[])      datings__period = forms.ChoiceField(label=_(u"Period"), choices=[])      material_types = forms.ChoiceField(label=_(u"Material type"), choices=[])      object_types = forms.ChoiceField(label=_(u"Object type"), choices=[]) @@ -472,7 +471,7 @@ class FindSelect(CustomForm, TableSelect):      base_finds__find__description = forms.CharField(label=_(u"Description"))      base_finds__batch = forms.ChoiceField(          label=_(u"Batch/object"), choices=[]) -    checked = forms.ChoiceField(label=_("Check")) +    checked_type = forms.ChoiceField(label=_("Check"))      documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?"))      TYPES = [ @@ -487,19 +486,17 @@ class FindSelect(CustomForm, TableSelect):          FieldType('base_finds__context_record__town__areas', Area),          FieldType('base_finds__context_record__operation__operation_type',                    OperationType), +        FieldType('checked_type', models.CheckedType),      ]      def __init__(self, *args, **kwargs):          super(FindSelect, self).__init__(*args, **kwargs) -        if 'checked' in self.fields: -            self.fields['checked'].choices = \ -                [('', '--')] + list(models.CHECK_CHOICES)          if 'ope_relation_types' in self.fields:              self.fields['ope_relation_types'].choices = \ -                OpeRelationType.get_types(empty_first=False) +                OpeRelationType.get_types()          if 'cr_relation_types' in self.fields:              self.fields['cr_relation_types'].choices = CRRelationType.get_types( -                empty_first=False) +                )      def get_input_ids(self):          ids = super(FindSelect, self).get_input_ids() @@ -528,7 +525,7 @@ class FindSelectWarehouseModule(FindSelect):              associated_model=Warehouse),          validators=[valid_id(Warehouse)])      container__index = forms.IntegerField(label=_(u"Container ID")) -    container__reference = forms.IntegerField(label=_(u"Container ref.")) +    container__reference = forms.CharField(label=_(u"Container ref."))  class FindFormSelection(CustomFormSearch): diff --git a/archaeological_finds/migrations/0033_auto_20180813_1310.py b/archaeological_finds/migrations/0033_auto_20180813_1310.py index aea94a8e9..caa840c06 100644 --- a/archaeological_finds/migrations/0033_auto_20180813_1310.py +++ b/archaeological_finds/migrations/0033_auto_20180813_1310.py @@ -12,7 +12,7 @@ import re  def migrate_finds(apps, schema_editor):      Find = apps.get_model('archaeological_finds', 'Find')      CheckedType = apps.get_model('archaeological_finds', -                                       'RecordQualityType') +                                 'CheckedType')      not_checked, c = CheckedType.objects.get_or_create(          txt_idx=u"not-checked", @@ -64,9 +64,10 @@ class Migration(migrations.Migration):                  ('txt_idx', models.TextField(help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', unique=True, validators=[django.core.validators.RegexValidator(re.compile('^[-a-zA-Z0-9_]+\\Z'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid')], verbose_name='Textual ID')),                  ('comment', models.TextField(blank=True, null=True, verbose_name='Comment')),                  ('available', models.BooleanField(default=True, verbose_name='Available')), +                ('order', models.IntegerField(default=10, verbose_name='Order')),              ],              options={ -                'ordering': ('label',), +                'ordering': ('order',),                  'verbose_name': 'Checked type',                  'verbose_name_plural': 'Checked types',              }, diff --git a/archaeological_finds/migrations/0034_auto_20180814_1133.py b/archaeological_finds/migrations/0034_auto_20180814_1133.py new file mode 100644 index 000000000..b6e8f2ee4 --- /dev/null +++ b/archaeological_finds/migrations/0034_auto_20180814_1133.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-08-14 11:33 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('archaeological_finds', '0033_auto_20180813_1310'), +    ] + +    operations = [ +        migrations.RemoveField( +            model_name='find', +            name='checked', +        ), +        migrations.RemoveField( +            model_name='historicalfind', +            name='checked', +        ), +    ] diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 98d495d7c..23177faee 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -1,9 +1,9 @@  from archaeological_finds.models_finds import MaterialType, ConservatoryState, \      CheckedType, IntegrityType, RemarkabilityType, ObjectType, BaseFind, \ -    FindBasket, Find, Property, CHECK_CHOICES, BatchType, \ -    BFBulkView, FBulkView, FirstBaseFindView, AlterationType, \ -    AlterationCauseType, TreatmentEmergencyType, TreatmentType, \ -    CommunicabilityType, MaterialTypeQualityType, ObjectTypeQualityType +    FindBasket, Find, Property, BatchType, BFBulkView, FBulkView, \ +    FirstBaseFindView, AlterationType, AlterationCauseType, \ +    TreatmentEmergencyType, TreatmentType, CommunicabilityType, \ +    MaterialTypeQualityType, ObjectTypeQualityType  from archaeological_finds.models_treatments import Treatment, \      AbsFindTreatments, FindUpstreamTreatments, FindDownstreamTreatments, \      FindTreatments, TreatmentFile, TreatmentFileType, \ @@ -13,7 +13,7 @@ __all__ = ['MaterialType', 'ConservatoryState', 'IntegrityType', 'CheckedType',             'RemarkabilityType', 'ObjectType', 'BaseFind', 'FindBasket', 'Find',             'Property', 'BFBulkView', 'FBulkView', 'FirstBaseFindView',             'AlterationType', 'AlterationCauseType', 'TreatmentEmergencyType', -           'CHECK_CHOICES', 'BatchType', 'TreatmentType', 'TreatmentState', +           'BatchType', 'TreatmentType', 'TreatmentState',             'Treatment', 'AbsFindTreatments', 'FindUpstreamTreatments',             'FindDownstreamTreatments', 'FindTreatments', 'TreatmentFile',             'TreatmentFileType', 'CommunicabilityType', diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 322cf90e4..465d57f3a 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -213,10 +213,12 @@ post_delete.connect(post_save_cache, sender=CommunicabilityType)  class CheckedType(GeneralType): +    order = models.IntegerField(_(u"Order"), default=10) +      class Meta:          verbose_name = _(u"Checked type")          verbose_name_plural = _(u"Checked types") -        ordering = ('label',) +        ordering = ('order',)  post_save.connect(post_save_cache, sender=CheckedType) @@ -548,11 +550,6 @@ post_save.connect(post_save_point, sender=BaseFind)  WEIGHT_UNIT = (('g', _(u"g")),                 ('kg', _(u"kg")),) -CHECK_CHOICES = (('NC', _(u"Not checked")), -                 ('CI', _(u"Checked but incorrect")), -                 ('CC', _(u"Checked and correct")), -                 ) -  class FindBasket(Basket):      items = models.ManyToManyField('Find', blank=True, related_name='basket') @@ -597,7 +594,6 @@ class FBulkView(object):  class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,             ShortMenuItem):      EXTERNAL_ID_KEY = 'find_external_id' -    CHECK_DICT = dict(CHECK_CHOICES)      SHOW_URL = 'show-find'      SLUG = 'find'      TABLE_COLS = ['external_id', 'label', @@ -616,7 +612,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,          'previous_id', 'label', 'material_types__label',          'datings__period__label', 'find_number', 'object_types__label',          'container__cached_label', -        'container__cahed_location', +        'container__cached_location',          'description',          'base_finds__context_record__town__name',          'base_finds__context_record__parcel', ] @@ -674,20 +670,12 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,      ]      BASE_REQUEST = {'downstream_treatment__isnull': True}      EXTRA_REQUEST_KEYS = { -        'base_finds__cache_short_id': -            'base_finds__cache_short_id__icontains', -        'base_finds__cache_complete_id': -            'base_finds__cache_complete_id__icontains', -        'label': -            'label__icontains',          'base_finds__context_record':              'base_finds__context_record__pk',          'base_finds__context_record__archaeological_site':              'base_finds__context_record__archaeological_site__pk',          'archaeological_sites_context_record':              'base_finds__context_record__archaeological_site__pk', -        'base_finds__context_record__town': -            'base_finds__context_record__town__pk',          'base_finds__context_record__operation__year':              'base_finds__context_record__operation__year__contains',          'base_finds__context_record__operation': @@ -729,15 +717,15 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,      ALT_NAMES = {          'base_finds__cache_short_id': (              pgettext_lazy(TXT_SEARCH_COMMENT, u"short-id"), -            'base_finds__cache_short_id__iexact' +            'base_finds__cache_short_id__contains'          ),          'base_finds__cache_complete_id': (              pgettext_lazy(TXT_SEARCH_COMMENT, u"complete-id"), -            'base_finds__cache_complete_id__iexact' +            'base_finds__cache_complete_id__icontains'          ),          'label': (              pgettext_lazy(TXT_SEARCH_COMMENT, u"free-id"), -            'label__iexact' +            'label__icontains'          ),          'denomination': (              pgettext_lazy(TXT_SEARCH_COMMENT, u"denomination"), @@ -826,12 +814,30 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,              pgettext_lazy(TXT_SEARCH_COMMENT, u"batch"),              'base_finds__batch__label__iexact',          ), -        'checked': ( +        'checked_type': (              pgettext_lazy(TXT_SEARCH_COMMENT, u"checked"),              'checked_type__label__iexact',          ), - - +        'documents__image__isnull': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"has-image"), +            'documents__image__isnull', +        ), +        'container__location': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"location"), +            'container__location__name__iexact', +        ), +        'container__responsible': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"warehouse"), +            'container__responsible__name__iexact', +        ), +        'container__index': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"container-index"), +            'container__index', +        ), +        'container__reference': ( +            pgettext_lazy(TXT_SEARCH_COMMENT, u"container-ref"), +            'container__reference__iexact', +        ),      }      for v in ALT_NAMES.values():          EXTRA_REQUEST_KEYS[v[0]] = v[1] @@ -925,8 +931,6 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,      index = models.IntegerField(u"Index", default=0)      checked_type = models.ForeignKey(CheckedType, verbose_name=_(u"Check"),                                       blank=True, null=True) -    checked = models.CharField(_(u"Check"), max_length=2, default=u'NC', -                               choices=CHECK_CHOICES)      check_date = models.DateField(_(u"Check date"),                                    default=datetime.date.today)      estimated_value = models.FloatField(_(u"Estimated value"), blank=True, diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 48cc042f8..9b0ff2e86 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -81,7 +81,7 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):          )      def __unicode__(self): -        return u"%s (%s)" % (self.name, unicode(self.warehouse_type)) +        return self.name      def _get_base_image_path(self):          return u"{}/{}".format(self.SLUG, slugify(self.name)) @@ -89,7 +89,7 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):      @property      def associated_filename(self):          return datetime.date.today().strftime('%Y-%m-%d') + '-' + \ -               slugify(unicode(self)) +            slugify(unicode(self))      @classmethod      def get_query_owns(cls, ishtaruser): | 
