def post_ready(self): from classification import localsettings from main.models import EntitySynonymType if self.is_table_exists(EntitySynonymType): builtins_types = [ "classification_entry_name", "classification_entry_code", "classification_entry_alternate_name" ] if EntitySynonymType.objects.filter( name__in=builtins_types).count() != len(builtins_types): configuration.wrong( "classification", "classification_entry_synonym_types", "Missing builtins classification entry synonym types. Be sure to have installed fixtures." ) else: configuration.validate( "classification", "classification_entry_synonym_types", "classification entry synonym types detected.") # keep models id in cache localsettings.synonym_type_classification_entry_name = EntitySynonymType.objects.get( name="classification_entry_name").pk localsettings.synonym_type_classification_entry_code = EntitySynonymType.objects.get( name="classification_entry_code").pk localsettings.synonym_type_classification_entry_alternate_name = EntitySynonymType.objects.get( name="classification_entry_alternate_name").pk
def post_ready(self): from accession import localsettings localsettings.max_file_size = self.get_setting('max_file_size') if not isinstance(localsettings.max_file_size, int): configuration.wrong("accession", "Accession action upload data max file size", "Max file size must be an integer.") if localsettings.max_file_size <= 1024: configuration.wrong( "accession", "Accession action upload data max file size", "Max file size must be greater than 1024 bytes.") else: configuration.validate( "accession", "Accession action upload data max file size", "Max file size is %i bytes." % localsettings.max_file_size) from main.models import EntitySynonymType if self.is_table_exists(EntitySynonymType): builtins_types = [ "accession_name", "accession_code", "accession_alternate_name", "accession_geves_code" ] if EntitySynonymType.objects.filter( name__in=builtins_types).count() != len(builtins_types): configuration.wrong( "accession", "accession_synonym_types", "Missing builtins accession synonym types. Be sure to have installed fixtures." ) else: configuration.validate("accession", "accession_synonym_types", "accession synonym types detected.") # keep models id in cache localsettings.synonym_type_accession_name = EntitySynonymType.objects.get( name="accession_name").pk localsettings.synonym_type_accession_code = EntitySynonymType.objects.get( name="accession_code").pk localsettings.synonym_type_accession_alternate_name = EntitySynonymType.objects.get( name="accession_alternate_name").pk localsettings.synonym_type_accession_geves_code = EntitySynonymType.objects.get( name="accession_geves_code").pk # setup the name builders from accession.namebuilder import NameBuilder, NameBuilderManager NameBuilderManager.init() NameBuilderManager.register( NameBuilderManager.GLOBAL_ACCESSION, NameBuilder("accession_naming_seq", self.get_setting("accession_naming"))) NameBuilderManager.register( NameBuilderManager.GLOBAL_BATCH, NameBuilder("batch_naming_seq", self.get_setting("batch_naming")))
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)
def ready(self): super().ready() instance.geolocation_app = self package_name, module_name, class_name = self.get_setting('geolocation_manager').split('.') try: module = import_module(self.name + '.' + package_name + '.' + module_name) configuration.validate('geolocation', 'geolocation_manager', "Geolocation external module importation validated") self.geolocation_manager = module.GeolocationManager() except ImportError: configuration.wrong('geolocation', 'geolocation_manager', "Geolocation external module importation error") # create a geolocation module geolocation_module = Module('geolocation', base_url='coll-gate') geolocation_module.include_urls(( 'base', 'geolocation' ) ) # registers media types of formats from . import descriptorformattype self.format_types += [ # descriptorformattype.DescriptorFormatTypeGeolocation(), descriptorformattype.DescriptorFormatTypeCountry(), descriptorformattype.DescriptorFormatTypeCity(), ] from descriptor.descriptorformattype import DescriptorFormatTypeManager DescriptorFormatTypeManager.register(self.format_types) module_manager.register_menu(geolocation_module)
def post_ready(self): from organisation.models import GRC if self.is_table_exists(GRC): # check if there is a unique GRC model instance num_grcs = len(GRC.objects.all()) if num_grcs == 0: self.logger.info( "Missing GRC configuration. Create a unique GRC model instance. Need configuration." ) grc = GRC() grc.save() configuration.partial( "organisation", "GRC instance", "GRC instance created. Need configuration.") elif num_grcs > 1: configuration.wrong( "organisation", "GRC instance", "Invalid GRC configuration. Only a unique GRC could be configured." ) else: configuration.validate("organisation", "GRC instance", "GRC instance detected.") from descriptor.models import Layout if self.is_table_exists(Layout): # keep descriptor layout for organisation and establishment. if not Layout.objects.filter(name="organisation").exists(): configuration.wrong( "organisation", "Organisation descriptor layout", "Missing organisation descriptor layout. Be sure to have installed fixtures." ) else: configuration.validate( "organisation", "Organisation descriptor layout", "Organisation descriptor layout detected.") if not Layout.objects.filter(name="establishment").exists(): configuration.wrong( "organisation", "Establishment descriptor layout", "Missing establishment descriptor layout. Be sure to have installed fixtures." ) else: configuration.validate( "organisation", "Establishment descriptor layout", "Establishment descriptor layout detected.")
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)