Skip to content

Commit

Permalink
fix esb get_msg_type (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-smile authored Oct 23, 2023
1 parent 637f85d commit a702672
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ repos:
files: src/dashboard/
- repo: local
hooks:
- id: isort
name: isort
language: python
types: [python]
entry: isort --settings-path=src/esb/pyproject.toml
files: src/esb/
- id: black
name: black
language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@


class ESBChannelSLZ(OfficialWriteFields, serializers.ModelSerializer):

board = serializers.HiddenField(default="")
system_id = serializers.IntegerField(min_value=1)
system_name = serializers.CharField(source="system.name", read_only=True)
Expand Down Expand Up @@ -164,6 +163,11 @@ def _exclude_current_instance(self, queryset):
def update(self, instance, validated_data):
if not ESBChannelExtend.objects.get_config_fields(instance.id):
validated_data.pop("config", None)
elif validated_data.get("config"):
# 指定 config-fields 的组件,保留未修改的原配置
config = instance.config.copy()
config.update(validated_data["config"])
validated_data["config"] = config

return super().update(instance, validated_data)

Expand Down
14 changes: 13 additions & 1 deletion src/esb/esb/esb/management/utils/channel_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_info(self):
"path": self.path,
"method": self.channel_config.get("method", ""),
"comp_codename": self.channel_config["comp_codename"],
"comp_conf_to_db": self.channel_config.get("comp_conf_to_db") or self.channel_config.get("comp_conf"),
"comp_conf_to_db": self._get_comp_conf_to_db(),
"config_fields": self.channel_config.get("config_fields"),
"permission_level": self.channel_config.get("permission_level", PermissionLevelEnum.UNLIMITED.value),
"verified_user_required": self.channel_config.get("verified_user_required", True),
Expand All @@ -57,3 +57,15 @@ def get_info(self):
}
)
return info

def _get_comp_conf_to_db(self):
if self.channel_config.get("comp_conf_to_db"):
return self.channel_config.get("comp_conf_to_db")

if self.channel_config.get("comp_conf"):
return self.channel_config.get("comp_conf")

if self.channel_config.get("config_fields"):
return {field["variable"]: field["default"] for field in self.channel_config["config_fields"]}

return None

0 comments on commit a702672

Please sign in to comment.