diff --git a/bims/serializers/location_site_serializer.py b/bims/serializers/location_site_serializer.py index f986932c6..f1901ebec 100644 --- a/bims/serializers/location_site_serializer.py +++ b/bims/serializers/location_site_serializer.py @@ -53,7 +53,6 @@ class Meta: 'ecosystem_type', 'wetland_name', 'user_wetland_name', - 'ecosystem_type' ] diff --git a/scripts/management/commands/import_all_frog.py b/scripts/management/commands/import_all_frog.py index a6c5d9174..2cba644a3 100644 --- a/scripts/management/commands/import_all_frog.py +++ b/scripts/management/commands/import_all_frog.py @@ -6,7 +6,7 @@ class Command(BaseCommand): """ - Import all odonata data + Import all frog data """ def add_arguments(self, parser): @@ -38,6 +38,13 @@ def add_arguments(self, parser): default='0', help='Start index' ) + parser.add_argument( + '-m', + '--module-name', + dest='module_name', + default='Anura', + help='Module name' + ) def handle(self, *args, **options): api_token = options.get('token', '') @@ -71,9 +78,18 @@ def handle(self, *args, **options): f"Fetching {start_index},{limit} of {total_records} - " f"{datetime.today()}\n" ) - print(log_text) + self.log_message(log_text) call_command('import_frog_vm_data', start_index=start_index, limit=limit, + module_name=options.get('module_name'), token=api_token) start_index += limit + + def log_message(self, message): + """ + Log a message to the console and a file. + """ + print(message) + with open('import_all_frog_log.txt', 'a') as the_file: + the_file.write(message + '\n') diff --git a/scripts/management/commands/import_all_odonata.py b/scripts/management/commands/import_all_odonata.py index e06053876..c757518f9 100644 --- a/scripts/management/commands/import_all_odonata.py +++ b/scripts/management/commands/import_all_odonata.py @@ -38,6 +38,13 @@ def add_arguments(self, parser): default='0', help='Start index' ) + parser.add_argument( + '-m', + '--module-name', + dest='module_name', + default='Odonate Adults', + help='Module name' + ) def handle(self, *args, **options): api_token = options.get('token', '') @@ -75,5 +82,6 @@ def handle(self, *args, **options): call_command('import_odonata_data', start_index=start_index, limit=limit, + module_name=options.get('module_name'), token=api_token) start_index += limit diff --git a/scripts/management/commands/import_frog_vm_data.py b/scripts/management/commands/import_frog_vm_data.py index d6a3b0ca0..e881bffba 100644 --- a/scripts/management/commands/import_frog_vm_data.py +++ b/scripts/management/commands/import_frog_vm_data.py @@ -49,6 +49,13 @@ def add_arguments(self, parser): default=self.source_name, help='Source name' ) + parser.add_argument( + '-md', + '--module-name', + dest='module_name', + default='Anurans', + help='Module Name' + ) def handle(self, *args, **options): self.api_token = options.get('token', '') @@ -68,7 +75,7 @@ def handle(self, *args, **options): module_name=self.module_name, base_api_url=self.base_api_url, source_name=self.source_name, - taxon_group_module='Anura') + taxon_group_module=options.get('module_name')) harvester.harvest( start_index=start_index, limit=limit, diff --git a/scripts/management/commands/import_odonata_data.py b/scripts/management/commands/import_odonata_data.py index 2d544a92f..ede996591 100644 --- a/scripts/management/commands/import_odonata_data.py +++ b/scripts/management/commands/import_odonata_data.py @@ -50,6 +50,13 @@ def add_arguments(self, parser): default=10, help='How many data should be retrieved' ) + parser.add_argument( + '-md', + '--module-name', + dest='module_name', + default='Odonate Adults', + help='Module Name' + ) def handle(self, *args, **options): self.api_token = options.get('token', '') @@ -69,7 +76,7 @@ def handle(self, *args, **options): module_name=self.module_name, base_api_url=self.base_api_url, source_name=self.source_name, - taxon_group_module='Odonate Adults') + taxon_group_module=options.get('module_name')) harvester.harvest( start_index=start_index, limit=limit,