diff options
-rw-r--r-- | archaeological_finds/models_finds.py | 11 | ||||
-rw-r--r-- | ishtar_common/migrations/0072_auto_20181008_1117.py | 24 | ||||
-rw-r--r-- | ishtar_common/models.py | 2 |
3 files changed, 34 insertions, 3 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index bea9b8048..26993aa32 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1382,6 +1382,12 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, profile = get_current_profile() + index = "" + if profile.find_use_index: + index = """|| '-' || + to_char(find_cached_bulk_update.index, 'fm{zeros}') + """.format(zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") + sql = """ UPDATE "archaeological_finds_find" AS f SET cached_label = @@ -1404,8 +1410,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, '{main_ope_prefix}' || find_cached_bulk_update.main_ope_code END - || '-' || - to_char(find_cached_bulk_update.index, 'fm{zeros}') + {index} || '{join}' || find_cached_bulk_update.label @@ -1419,7 +1424,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, """.format(main_ope_prefix=profile.operation_prefix, ope_prefix=profile.default_operation_prefix, join=settings.JOINT, filters=filters, - zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") + index=index) with connection.cursor() as c: c.execute(sql, args) diff --git a/ishtar_common/migrations/0072_auto_20181008_1117.py b/ishtar_common/migrations/0072_auto_20181008_1117.py new file mode 100644 index 000000000..203d56abb --- /dev/null +++ b/ishtar_common/migrations/0072_auto_20181008_1117.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-10-08 11:17 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0071_auto_20180926_1023'), + ] + + operations = [ + migrations.AlterModelOptions( + name='area', + options={'ordering': ('label',), 'verbose_name': 'Area', 'verbose_name_plural': 'Areas'}, + ), + migrations.AddField( + model_name='ishtarsiteprofile', + name='find_use_index', + field=models.BooleanField(default=True, verbose_name='Use auto index for finds'), + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 0a00fc108..3e7cecf2a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1987,6 +1987,8 @@ class IshtarSiteProfile(models.Model, Cached): u"Change this with care. With incorrect formula, the " u"application might be unusable and import of external " u"data can be destructive.")) + find_use_index = models.BooleanField(_(u"Use auto index for finds"), + default=True) currency = models.CharField(_(u"Currency"), default=u"€", choices=CURRENCY, max_length=5) |