Example #1
0
    def ready(self):
        super().ready()

        instance.geonames_app = self

        self.geonames_username = self.get_setting('geonames_username')

        if self.geonames_username == 'demo' or not self.geonames_username:
            configuration.wrong(
                'geonames', 'geonames_username',
                "Geonames username invalid : %s" % self.geonames_username)

        else:
            configuration.validate(
                'geonames', 'geonames_username',
                "Geonames username found : %s" % self.geonames_username)

        self.geonames_include_city_types = self.get_setting(
            'geonames_include_city_types')

        geonames_features_code = [
            'PPL', 'PPLA', 'PPLA2', 'PPLA3', 'PPLA4', 'PPLC', 'PPLCH', 'PPLF',
            'PPLG', 'PPLH', 'PPLL', 'PPLQ', 'PPLR', 'PPLS', 'PPLW', 'PPLX',
            'STLMT'
        ]

        if isinstance(self.geonames_include_city_types, list):
            codes_supported = True
            for code in self.geonames_include_city_types:
                if code not in geonames_features_code:
                    codes_supported = False
                    break

            if not codes_supported:
                configuration.wrong('geonames', 'geonames_include_city_types',
                                    "City types not supported")
            else:
                configuration.validate(
                    'geonames', 'geonames_include_city_types',
                    "City types supported : FeatureCode -> %s " %
                    self.geonames_include_city_types)
        else:
            configuration.wrong('geonames', 'geonames_include_city_types',
                                "Invalid format (not a list)")

        instance.geonames_include_city_types = self.geonames_include_city_types
        instance.geonames_username = self.geonames_username

        from main.models import main_register_models
        main_register_models(CollGateGeolocation.name)

        from audit.models import audit_register_models
        audit_register_models(CollGateGeolocation.name)

        # create a geonames module
        geonames_module = Module('geonames', base_url='coll-gate')
        geonames_module.include_urls(())

        # ignore geonames from content types
        geonames_module.ignored_content_types = ['geonames.']

        # ignore geonames from permission types
        geonames_module.ignored_permission_types = ['geonames.']

        # no client counterpart
        geonames_module.client_export = False

        module_manager.register_module(geonames_module)
Example #2
0
    def ready(self):
        super().ready()

        # register descriptor cache category
        from main.cache import cache_manager
        cache_manager.register('accession')

        from messenger.cache import client_cache_manager
        client_cache_manager.register('accession')

        from main.models import main_register_models
        main_register_models(CollGateAccession.name)

        from audit.models import audit_register_models
        audit_register_models(CollGateAccession.name)

        # create a module accession
        accession_module = Module('accession', base_url='coll-gate')
        accession_module.include_urls(
            ('base', 'accessionsynonym', 'actions.actiontype',
             'actions.action', 'accession', 'accessionbatch', 'batch',
             'accessionpanel', 'batchpanel', 'accessionclassificationentry',
             'storagelocation'))

        # add the describable entities models
        from .models import Accession, Batch, AccessionPanel, BatchPanel

        # descriptor_module
        from django.apps import apps
        descriptor_app = apps.get_app_config('descriptor')
        descriptor_app.describable_entities += [
            Accession, Batch, AccessionPanel, BatchPanel
        ]

        # add the classificationEntry entities models, classification_module
        classification_app = apps.get_app_config('classification')
        classification_app.children_entities += [Accession]

        # registers standard format type of descriptors layouts
        from accession import layouttype

        for element in dir(layouttype):
            attr = getattr(layouttype, element)
            if type(attr) is type and layouttype.LayoutType in attr.__bases__:
                self.layout_types.append(attr())

        # and register them
        LayoutTypeManager.register(self.layout_types)

        # and the action type formats
        from accession.actions import actionstepformat

        for element in dir(actionstepformat):
            attr = getattr(actionstepformat, element)
            if type(
                    attr
            ) is type and attr is not actionstepformat.ActionStepFormat and issubclass(
                    attr, actionstepformat.ActionStepFormat):
                self.action_step_formats.append(attr())

        from accession.actions.actionstepformat import ActionStepFormatManager
        ActionStepFormatManager.register(self.action_step_formats)

        # accession menu
        menu_accession = ModuleMenu('accession',
                                    _('Accession'),
                                    auth=AUTH_USER)

        menu_accession.add_entry(
            MenuEntry('create-accession',
                      _('Create accession'),
                      "~accession/accession/create",
                      icon=FaGlyph('plus'),
                      order=1))

        menu_accession.add_entry(MenuSeparator(100))
        menu_accession.add_entry(
            MenuEntry('list-accession',
                      _('List accessions'),
                      "#accession/accession/",
                      icon=FaGlyph('list'),
                      order=101))
        menu_accession.add_entry(
            MenuEntry('panel-accession',
                      _('Panel accessions'),
                      "#accession/accessionpanel/",
                      icon=FaGlyph('list-alt'),
                      order=102))

        menu_accession.add_entry(MenuSeparator(200))
        menu_accession.add_entry(
            MenuEntry('search-accession',
                      _('Search accessions'),
                      "~accession/accession/search",
                      icon=FaGlyph('search'),
                      order=201))

        accession_module.add_menu(menu_accession)

        # batch menu
        menu_batch = ModuleMenu('batch', _('Batch'), auth=AUTH_USER)

        menu_batch.add_entry(
            MenuEntry('create-batch',
                      _('Introduce a batch'),
                      "~accession/batch/create",
                      icon=FaGlyph('plus'),
                      order=1))

        menu_batch.add_entry(MenuSeparator(100))
        menu_batch.add_entry(
            MenuEntry('list-batches',
                      _('List batches'),
                      "#accession/batch/",
                      icon=FaGlyph('list'),
                      order=101))
        menu_batch.add_entry(
            MenuEntry('panel-batches',
                      _('Panel batches'),
                      "#accession/batchpanel/",
                      icon=FaGlyph('list-alt'),
                      order=102))

        menu_batch.add_entry(MenuSeparator(200))
        menu_batch.add_entry(
            MenuEntry('search-batch',
                      _('Search batches'),
                      "~accession/batch/search",
                      icon=FaGlyph('search'),
                      order=201))

        accession_module.add_menu(menu_batch)

        # action menu
        menu_action = ModuleMenu('action', _('Action'), auth=AUTH_USER)

        menu_action.add_entry(
            MenuEntry('create-action',
                      _('Create action'),
                      "~accession/action/create",
                      icon=FaGlyph('plus'),
                      order=1))

        menu_action.add_entry(MenuSeparator(100))
        menu_action.add_entry(
            MenuEntry('list-actions',
                      _('List actions'),
                      "#accession/action/",
                      icon=FaGlyph('list-alt'),
                      order=101))

        accession_module.add_menu(menu_action)

        # accession administration menu
        menu_administration = ModuleMenu('administration',
                                         _('Administration'),
                                         order=999,
                                         auth=AUTH_STAFF)

        # storage location menu
        menu_administration.add_entry(
            MenuEntry('list-location',
                      _('Storage locations'),
                      "#accession/storagelocation/",
                      icon=FaGlyph('archive'),
                      order=-196,
                      auth=AUTH_STAFF))

        # descriptor related menus
        menu_administration.add_entry(MenuSeparator(500))
        menu_administration.add_entry(
            MenuEntry('list-action-type',
                      _('Action types'),
                      "#accession/actiontype/",
                      icon=FaGlyph('cubes'),
                      order=501,
                      auth=AUTH_STAFF))
        accession_module.add_menu(menu_administration)

        module_manager.register_module(accession_module)

        if self.is_run_mode():
            self.post_ready()
Example #3
0
    def ready(self):
        super().ready()

        from main.models import main_register_models
        main_register_models(CollGateClassification.name)

        from audit.models import audit_register_models
        audit_register_models(CollGateClassification.name)

        # create a module classification
        classification_module = Module('classification', base_url='coll-gate')
        classification_module.include_urls(
            ('base', 'classification', 'classificationentry',
             'classificationentrysynonym', 'classificationentryrelated'))

        # add the describable entities models
        from .models import ClassificationEntry

        # descriptor_module
        from django.apps import apps
        descriptor_app = apps.get_app_config('descriptor')
        descriptor_app.describable_entities += [ClassificationEntry]

        # registers standard format type of layouts
        from classification import layouttype

        for element in dir(layouttype):
            attr = getattr(layouttype, element)
            if type(attr) is type and layouttype.LayoutType in attr.__bases__:
                self.layout_types.append(attr())

        # and register them
        LayoutTypeManager.register(self.layout_types)

        # administration menu
        menu_administration = ModuleMenu('administration',
                                         _('Administration'),
                                         order=999,
                                         auth=AUTH_STAFF)

        menu_administration.add_entry(MenuSeparator(400))

        # administration related menus
        menu_administration.add_entry(
            MenuEntry('classification-list',
                      _('List of classifications'),
                      "#classification/classification/",
                      icon=FaGlyph('sitemap'),
                      order=401,
                      auth=AUTH_SUPER_USER))

        classification_module.add_menu(menu_administration)

        # classification menu
        menu_classification = ModuleMenu('classification',
                                         _('Classification'),
                                         auth=AUTH_USER)
        menu_classification.add_entry(
            MenuEntry('create-classification-entry',
                      _('Create classification entry'),
                      "~classification/classificationEntry/create",
                      icon=FaGlyph('plus'),
                      order=1))

        classification_module.add_menu(menu_classification)

        module_manager.register_module(classification_module)

        if self.is_run_mode():
            self.post_ready()
Example #4
0
    def ready(self):
        super().ready()

        # register main cache category
        from main.cache import cache_manager
        cache_manager.register('main')

        from messenger.cache import client_cache_manager
        client_cache_manager.register('main')

        from main.models import main_register_models
        main_register_models(CollGateMain.name)

        main_module = Module('main', base_url='coll-gate')
        main_module.include_urls(
            ('base', 'home', 'contenttype', 'entity', 'profile', 'language',
             'help', 'eventmessage'))

        # administration menu
        menu_administration = ModuleMenu('administration',
                                         _('Administration'),
                                         order=999,
                                         auth=AUTH_STAFF)

        # administration related menus
        menu_administration.add_entry(
            MenuEntry('server-config',
                      _('Server configuration'),
                      "#main/config/",
                      icon=FaGlyph('cog'),
                      order=-199,
                      auth=AUTH_SUPER_USER))

        menu_administration.add_entry(
            MenuEntry('language-list',
                      _('Configured languages'),
                      "#main/language/",
                      icon=FaGlyph('language'),
                      order=-198,
                      auth=AUTH_SUPER_USER))

        menu_administration.add_entry(
            MenuEntry('entity-synonym-type-list',
                      _('Configured types of synonyms'),
                      "#main/entity-synonym-type/",
                      icon=FaGlyph('tags'),
                      order=-197,
                      auth=AUTH_SUPER_USER))
        menu_administration.add_entry(MenuSeparator(-100,
                                                    auth=AUTH_SUPER_USER))
        main_module.add_menu(menu_administration)

        # help menu
        menu_help = ModuleMenu('help', _('Help'), order=1001)
        menu_help.add_entry(
            MenuEntry('manual', _('Manual index'), "#main/help/",
                      FaGlyph('book'), 50))
        menu_help.add_entry(MenuSeparator(100))
        menu_help.add_entry(
            MenuEntry('about', _('About Coll-Gate IS...'), "#main/about/",
                      FaGlyph('question-circle'), 101))
        main_module.add_menu(menu_help)

        module_manager.register_module(main_module)

        if self.is_run_mode():
            self.post_ready()
Example #5
0
    def ready(self):
        super().ready()

        # register descriptor cache category
        from main.cache import cache_manager
        cache_manager.register('descriptor')
        cache_manager.register('entity_columns')

        from messenger.cache import client_cache_manager
        client_cache_manager.register('descriptors')
        client_cache_manager.register('entity_columns')

        from main.models import main_register_models
        main_register_models(CollGateDescriptor.name)

        from audit.models import audit_register_models
        audit_register_models(CollGateDescriptor.name)

        # create a module accession
        descriptor_module = Module('descriptor', base_url='coll-gate')
        descriptor_module.include_urls(
            ('descriptorformat', 'condition', 'describable', 'descriptor',
             'layout', 'descriptorcolumns'))

        # registers standard types of formats
        from . import descriptorformattype

        self.format_types += [
            descriptorformattype.DescriptorFormatTypeBoolean(),
            descriptorformattype.DescriptorFormatTypeNumeric(),
            descriptorformattype.DescriptorFormatTypeNumericRange(),
            descriptorformattype.DescriptorFormatTypeOrdinal(),
            descriptorformattype.DescriptorFormatTypeString(),
            descriptorformattype.DescriptorFormatTypeDate(),
            descriptorformattype.DescriptorFormatTypeImpreciseDate(),
            descriptorformattype.DescriptorFormatTypeTime(),
            descriptorformattype.DescriptorFormatTypeDateTime(),
            descriptorformattype.DescriptorFormatTypeEntity(),
            descriptorformattype.DescriptorFormatTypeEnumSingle(),
            descriptorformattype.DescriptorFormatTypeEnumPair(),
            descriptorformattype.DescriptorFormatTypeEnumOrdinal()
        ]

        # and register them
        descriptorformattype.DescriptorFormatTypeManager.register(
            self.format_types)

        # registers standard units
        from . import descriptorformatunit

        for element in dir(descriptorformatunit):
            attr = getattr(descriptorformatunit, element)
            if type(
                    attr
            ) is type and descriptorformatunit.DescriptorFormatUnit in attr.__bases__:
                self.format_units.append(attr())

        # and register them
        descriptorformatunit.DescriptorFormatUnitManager.register(
            self.format_units)

        # registers standard types of descriptors layouts
        from . import layouttype

        for element in dir(layouttype):
            attr = getattr(layouttype, element)
            if type(attr) is type and layouttype.LayoutType in attr.__bases__:
                self.layout_types.append(attr())

        # and register them
        layouttype.LayoutTypeManager.register(self.layout_types)

        # descriptor administration menu
        menu_descriptor = ModuleMenu('administration',
                                     _('Administration'),
                                     order=999,
                                     auth=AUTH_STAFF)

        # index menu
        menu_descriptor.add_entry(
            MenuEntry('list-index',
                      _('Index management'),
                      "#descriptor/index/",
                      icon=FaGlyph('list-ol'),
                      order=-195,
                      auth=AUTH_STAFF))

        # descriptor related menus
        menu_descriptor.add_entry(MenuSeparator(300))
        menu_descriptor.add_entry(
            MenuEntry('list-descriptor',
                      _('Descriptor management'),
                      "#descriptor/descriptor/",
                      icon=FaGlyph('th-list'),
                      order=301,
                      auth=AUTH_STAFF))
        menu_descriptor.add_entry(
            MenuEntry('list-layout',
                      _('Layout management'),
                      "#descriptor/layout/",
                      icon=FaGlyph('th-large'),
                      order=303,
                      auth=AUTH_STAFF))
        descriptor_module.add_menu(menu_descriptor)

        module_manager.register_module(descriptor_module)