Run links keep only the last value of repeated query parameters

未关闭 适合新手
#83 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从 Run 视图的初始值准备开始。issue 指出 request.GET.dict() 会丢弃重复参数,请将其与使用 normalize_querydict() 的 NetBox 内置 Script 视图进行比较。检查 Run 表单如何处理 MultiObjectVar 和 MultiChoiceVar 的值。完成标准是重复查询参数的两个值都被选中;请确认两种字段类型都满足这一点。

由索引模型根据 Issue 内容生成。

描述

app: scripts severity: medium status: backlog type: bug
Plugin Version

v0.0.1

NetBox Version

v4.7.4

Python Version

3.12

Steps to Reproduce
  1. Upload and activate the following Script:
    from dcim.models import Interface
    from netbox_scripts import MultiObjectVar, Script
    
    
    class PickInterfaces(Script):
        interfaces = MultiObjectVar(model=Interface)
    
        def run(self, data, commit):
            for interface in data['interfaces']:
                self.log_info(str(interface), obj=interface)
    
  2. Use two existing interfaces, or create two on a device, and note their IDs.
  3. As a user who can run the Script and view both interfaces, open its Run URL with the interfaces parameter repeated. Replace the sample IDs with the actual interface IDs:
    /plugins/netbox-scripts/scripts/<id>/run/?interfaces=1&interfaces=2
    
Expected Behavior

Both interfaces are selected in the form, matching NetBox's built-in Script form.

Observed Behavior

Only interface 2 is selected.

The Run view prepares initial values with request.GET.dict(), which discards earlier values for the same parameter. This also affects MultiChoiceVar fields. NetBox's built-in Script view preserves repeated values with normalize_querydict().

主要语言
Python
星标
8
派生
0
平均合并
11 小时 23 分钟
30 天内合并 PR
24

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

netbox-community/netbox-scripts 的其他 Issue

查看 netbox-community/netbox-scripts 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。