Ejemplo n.º 1
0
    def ready(self):
        super().ready()

        # create a module permission
        permission_module = Module('permission', base_url='coll-gate')
        permission_module.include_urls(('base', ))

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

        menu_permission.add_entry(MenuSeparator(100))
        menu_permission.add_entry(
            MenuEntry('user-permission',
                      _('Manage users'),
                      "#permission/user/",
                      icon=FaGlyph('user'),
                      order=101))
        menu_permission.add_entry(
            MenuEntry('group-permission',
                      _('Manage groups'),
                      "#permission/group/",
                      icon=FaGlyph('folder'),
                      order=102))
        permission_module.add_menu(menu_permission)

        module_manager.register_module(permission_module)
Ejemplo n.º 2
0
    def ready(self):
        super().ready()

        # some local settings
        storage_path = self.get_setting('storage_path')
        if not os.path.isabs(storage_path):
            localsettings.storage_path = os.path.abspath(storage_path)
        else:
            localsettings.storage_path = storage_path

        if not os.path.isdir(localsettings.storage_path):
            configuration.wrong(
                "medialibrary", "Media-library destination path",
                "Media library destination folder does not exists.")
        else:
            configuration.validate(
                "medialibrary", "Media-library destination path",
                "Media library destination folder founds at %s." %
                localsettings.storage_path)

        localsettings.storage_location = self.get_setting('storage_location')
        localsettings.max_file_size = self.get_setting('max_file_size')

        if not isinstance(localsettings.max_file_size, int):
            configuration.wrong("medialibrary", "Media-library max file size",
                                "Max file size must be an integer.")

        if localsettings.max_file_size <= 1024:
            configuration.wrong(
                "medialibrary", "Media-library max file size",
                "Max file size must be greater than 1024 bytes.")
        else:
            configuration.validate(
                "medialibrary", "Media-library max file size",
                "Max file size is %i bytes." % localsettings.max_file_size)

        # create a module medialibrary
        media_library_module = Module('medialibrary', base_url='coll-gate')
        media_library_module.include_urls(('base', 'media'))

        # registers media types of formats
        from . import descriptorformattype

        self.format_types += [
            descriptorformattype.DescriptorFormatTypeMedia(),
            descriptorformattype.DescriptorFormatTypeMediaCollection()
        ]

        from descriptor.descriptorformattype import DescriptorFormatTypeManager
        DescriptorFormatTypeManager.register(self.format_types)

        module_manager.register_module(media_library_module)
Ejemplo n.º 3
0
    def ready(self):
        super().ready()

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

        messenger_module = Module('messenger', base_url='coll-gate')
        messenger_module.include_urls(('base', ))

        module_manager.register_module(messenger_module)

        if self.is_run_mode():
            self.post_ready()
Ejemplo n.º 4
0
    def ready(self):
        super().ready()

        # create a module organisation
        organisation_module = Module('organisation', base_url='coll-gate')
        organisation_module.include_urls(('base', 'organisationtype', 'grc',
                                          'organisation', 'establishment'))

        # add the describable entities models
        from .models import Organisation, Establishment

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

        # organisation menu
        menu_organisation = ModuleMenu('administration',
                                       _('Administration'),
                                       order=999,
                                       auth=AUTH_STAFF)
        menu_organisation.add_entry(
            MenuEntry('grc-details',
                      _('Manage GRC'),
                      "#organisation/grc/",
                      icon=FaGlyph('cloud'),
                      order=1))
        menu_organisation.add_entry(
            MenuEntry('organisation',
                      _('Manage organisations'),
                      "#organisation/organisation/",
                      icon=FaGlyph('map-marker'),
                      order=2))
        menu_organisation.add_entry(
            MenuEntry('create-organisation',
                      _('Create an organisation or a partner'),
                      "~organisation/organisation/create/",
                      icon=FaGlyph('plus'),
                      order=34))

        organisation_module.add_menu(menu_organisation)

        module_manager.register_module(organisation_module)

        if self.is_run_mode():
            self.post_ready()
Ejemplo n.º 5
0
    def ready(self):
        super().ready()

        from . import localsettings

        if "init_fixtures" in sys.argv or "data_migrate" in sys.argv or "migrate" in sys.argv:
            # migration mode is defined for init_fixture or data_migrate commands
            localsettings.migration_mode = True

        # checkout global settings
        self.get_global_settings()

        audit_module = Module('audit', base_url='coll-gate')
        audit_module.include_urls(('base', 'history'))

        # ignore audit from content types
        audit_module.ignored_content_types = ['audit.']

        # ignore audit from permission types
        audit_module.ignored_permission_types = ['audit.']

        # audit menu
        menu_audit = ModuleMenu('audit',
                                _('Tracability'),
                                auth=AUTH_STAFF,
                                order=900)
        menu_audit.add_entry(
            MenuEntry('audit-user',
                      _('Tracability for a user'),
                      "~audit/audit/searchByUserName",
                      icon=FaGlyph('user'),
                      order=1))
        menu_audit.add_entry(
            MenuEntry('audit-entity',
                      _('Tracability for an entity'),
                      "~audit/audit/searchByEntity",
                      icon=FaGlyph('book'),
                      order=2))
        audit_module.add_menu(menu_audit)

        module_manager.register_module(audit_module)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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()
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()
Ejemplo n.º 10
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)