diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-18 15:36:26 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-18 15:36:26 +0200 | 
| commit | 4f23c4050eb57b2f2ee2af79f66f0191aab96efd (patch) | |
| tree | 68971bdc42ab6208ba8a47e48f6bd6aa296d0241 /ishtar_common | |
| parent | 580818aedffebce068728de1d36ffdb8447fee14 (diff) | |
| download | Ishtar-4f23c4050eb57b2f2ee2af79f66f0191aab96efd.tar.bz2 Ishtar-4f23c4050eb57b2f2ee2af79f66f0191aab96efd.zip  | |
Manage alternative profiles for labels, external ids, etc.
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/alternative_configs.py | 27 | ||||
| -rw-r--r-- | ishtar_common/migrations/0068_ishtarsiteprofile_config.py | 20 | ||||
| -rw-r--r-- | ishtar_common/models.py | 14 | 
3 files changed, 61 insertions, 0 deletions
diff --git a/ishtar_common/alternative_configs.py b/ishtar_common/alternative_configs.py new file mode 100644 index 000000000..269b44948 --- /dev/null +++ b/ishtar_common/alternative_configs.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +class ConfigDrassm(object): +    LABEL = u"DRASSM" + +    @classmethod +    def find_administrative_index(cls, find): +        return find.external_id + +    @classmethod +    def basefind_complete_id(cls, basefind): +        return basefind.external_id + +    @classmethod +    def basefind_short_id(cls, basefind): +        return basefind.external_id + + +ALTERNATE_CONFIGS = { +    'DRASSM': ConfigDrassm +} + +ALTERNATE_CONFIGS_CHOICES = [ +    (k, choice.LABEL) for k, choice in ALTERNATE_CONFIGS.items() +] diff --git a/ishtar_common/migrations/0068_ishtarsiteprofile_config.py b/ishtar_common/migrations/0068_ishtarsiteprofile_config.py new file mode 100644 index 000000000..05acb47be --- /dev/null +++ b/ishtar_common/migrations/0068_ishtarsiteprofile_config.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-08-18 14:54 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0067_auto_20180816_1832'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='ishtarsiteprofile', +            name='config', +            field=models.CharField(blank=True, choices=[(b'DRASSM', 'DRASSM')], help_text='Choose an alternate configuration for label, index management', max_length=200, null=True, verbose_name='Alternate configuration'), +        ), +    ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index ac639168c..dfcf503af 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -58,6 +58,9 @@ from secretary import Renderer as SecretaryRenderer  from simple_history.models import HistoricalRecords as BaseHistoricalRecords  from unidecode import unidecode +from ishtar_common.alternative_configs import ALTERNATE_CONFIGS, \ +    ALTERNATE_CONFIGS_CHOICES +  from ishtar_common.model_merging import merge_model_objects  from ishtar_common.models_imports import ImporterModel, ImporterType, \      ImporterDefault, ImporterDefaultValues, ImporterColumn, \ @@ -1703,6 +1706,13 @@ class IshtarSiteProfile(models.Model, Cached):      experimental_feature = models.BooleanField(          _(u"Activate experimental feature"), default=False)      description = models.TextField(_(u"Description"), null=True, blank=True) +    config = models.CharField( +        _(u"Alternate configuration"), max_length=200, +        choices=ALTERNATE_CONFIGS_CHOICES, +        help_text=_(u"Choose an alternate configuration for label, " +                    u"index management"), +        null=True, blank=True +    )      files = models.BooleanField(_(u"Files module"), default=False)      archaeological_site = models.BooleanField(          _(u"Archaeological site module"), default=False) @@ -1814,6 +1824,10 @@ class IshtarSiteProfile(models.Model, Cached):      def __unicode__(self):          return unicode(self.label) +    def has_overload(self, key): +        return self.config and self.config in ALTERNATE_CONFIGS and \ +               hasattr(ALTERNATE_CONFIGS[self.config], key) +      @classmethod      def get_current_profile(cls, force=False):          cache_key, value = get_cache(cls, ['is-current-profile'])  | 
