Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion addon_service/management/commands/fill_external_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def handle(self, *args, **kwargs):
oauth1_config = oauth1_configs[oauth1_id]
oauth1_config = OAuth1ClientConfig.objects.create(**oauth1_config)
service["oauth1_client_config"] = oauth1_config

valid_fields = {field.name for field in model._meta.get_fields()}
service = {
key: value for key, value in service.items() if key in valid_fields
}

if (
"int_supported_features" in service
and service["int_supported_features"] is None
):
service["int_supported_features"] = 0

model.objects.create(**service)

def load_csv_data(self, path: Path) -> dict[str, dict[str, Any]]:
Expand All @@ -55,7 +67,11 @@ def load_csv_data(self, path: Path) -> dict[str, dict[str, Any]]:

def fix_values(self, item):
raw_values = {key: self.fix_value(value) for key, value in item.items()}
return {key: value for key, value in raw_values.items() if value is not None}
return {
key: value
for key, value in raw_values.items()
if value is not None or key == "int_supported_features"
}

def fix_value(self, data):
if data == "":
Expand Down