[PR #19963] [MERGED] Closes #19945: Create DecimalVar class for custom script input #15773

Closed
opened 2025-12-30 00:23:58 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19963
Author: @kyerlasswell
Created: 7/28/2025
Status: Merged
Merged: 7/29/2025
Merged by: @jeremystretch

Base: featureHead: 19945-decimalvar


📝 Commits (4)

📊 Changes

3 files changed (+79 additions, -0 deletions)

View changed files

📝 docs/customization/custom-scripts.md (+9 -0)
📝 netbox/extras/scripts.py (+21 -0)
📝 netbox/extras/tests/test_scripts.py (+49 -0)

📄 Description

Fixes: #19945

  • Adds a new class called DecimalVar to netbox/extras/scripts.py to take in decimal input from a form. DecimalVar takes the same arguments as django.forms.DecimalField: min_value, max_value, max_digits and decimal_places.

  • Adds 5 new tests to netbox/extras/tests/test_scripts.py. One to isolate each of the four parameters and one to validate valid data. Two objects are created with different parameters because max_value will always be hit before max_digits can come into play so they have to be tested separately (e.g. if max_value = 999 but max_digits = 4, you can't test max_digits because a value of 1000 is already invalid).

  • Adds DecimalVar to custom script documentation.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19963 **Author:** [@kyerlasswell](https://github.com/kyerlasswell) **Created:** 7/28/2025 **Status:** ✅ Merged **Merged:** 7/29/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `19945-decimalvar` --- ### 📝 Commits (4) - [`12750da`](https://github.com/netbox-community/netbox/commit/12750da341e7508f48b5834014fd578dbceb5553) add DecimalVar class - [`7396c68`](https://github.com/netbox-community/netbox/commit/7396c68a9b5340b5cc87d9df44f7e1d3c68dc8cc) add DecimalVar tests - [`583cd13`](https://github.com/netbox-community/netbox/commit/583cd13a012e317c650bd71de3dfd1eec94afa45) add DecimalVar documentation - [`adb7423`](https://github.com/netbox-community/netbox/commit/adb742313c91cde5dd905e60e8bb244ffb4e8a95) Misc cleanup ### 📊 Changes **3 files changed** (+79 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/customization/custom-scripts.md` (+9 -0) 📝 `netbox/extras/scripts.py` (+21 -0) 📝 `netbox/extras/tests/test_scripts.py` (+49 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #19945 <!-- Please include a summary of the proposed changes below. --> - Adds a new class called `DecimalVar` to `netbox/extras/scripts.py` to take in decimal input from a form. DecimalVar takes the same arguments as `django.forms.DecimalField`: `min_value`, `max_value`, `max_digits` and `decimal_places`. - Adds 5 new tests to `netbox/extras/tests/test_scripts.py`. One to isolate each of the four parameters and one to validate valid data. Two objects are created with different parameters because `max_value` will always be hit before `max_digits` can come into play so they have to be tested separately (e.g. if `max_value = 999` but `max_digits = 4`, you can't test `max_digits` because a value of `1000` is already invalid). - Adds DecimalVar to custom script documentation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:23:58 +01:00
adam closed this issue 2025-12-30 00:23:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15773