Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix get_msg_type #306

Merged
Merged
Show file tree
Hide file tree
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
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 @@ -40,7 +40,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 @@ -165,6 +164,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