-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 [#14] improved code and fixed the natural keys
- Loading branch information
1 parent
f7e7254
commit 38e60dd
Showing
6 changed files
with
73 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...lications/metadata/management/commands/update_information_categories_from_waardenlijst.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand, CommandError | ||
|
||
from woo_publications.metadata.update_informatie_category import ( | ||
InformatieCategoryWaardenlijstError, | ||
update_informatie_category, | ||
) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Retrieve the information categories from the value list published on overheid.nl and dump them as a fixture." | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"--file-path", | ||
action="store", | ||
help="The file path to where the fixture file will be created.", | ||
default=Path( | ||
settings.BASE_DIR | ||
/ "src" | ||
/ "woo_publications" | ||
/ "fixtures" | ||
/ "informatie_category.json" | ||
), | ||
) | ||
|
||
def handle(self, *args, **options): | ||
file_path = options["file_path"] | ||
if not isinstance(file_path, Path): | ||
file_path = Path(file_path) | ||
|
||
try: | ||
update_informatie_category(file_path) | ||
except InformatieCategoryWaardenlijstError as err: | ||
raise CommandError(err.message) from err |
24 changes: 0 additions & 24 deletions
24
src/woo_publications/metadata/management/commands/update_information_category.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from ordered_model.models import OrderedModelManager | ||
|
||
|
||
class InformationCategoryManager(OrderedModelManager): | ||
def get_by_natural_key(self, identifier): | ||
return self.get(identifier=identifier) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters