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

Delete Images from Device Type (Add a delete button) #1353

Closed
jifox opened this issue Feb 9, 2022 · 1 comment · Fixed by #1358
Closed

Delete Images from Device Type (Add a delete button) #1353

jifox opened this issue Feb 9, 2022 · 1 comment · Fixed by #1358
Labels
good first issue Great issues for newcomers! type: feature Introduction of new or enhanced functionality to the application

Comments

@jifox
Copy link
Contributor

jifox commented Feb 9, 2022

Environment

  • Python version: 3.9
  • Nautobot version: a7a425060fec (v1.2.5)

Proposed Functionality

Add delete buttons or delete checkboxes to the upload fields

image

Maybe delete checkboxes are the better choice because this can be handled during saving the changes.

Use Case

As Nelly the Network engineer I want to have the ability to remove an image (front view, rear view) when editing the device type.

Currently if no image is selected, the existing one is preserved. Adding just one image when updating will also preserve the other image. So there is no way to get rid of one of the images

image

Database Changes

None

External Dependencies

@jifox jifox changed the title Delete Images from Device Type (Add button) Delete Images from Device Type (Add a delete button) Feb 9, 2022
@glennmatthews
Copy link
Contributor

Thanks for the report! Based on some brief investigation, this may be as simple as making the below change:

diff --git a/nautobot/dcim/forms.py b/nautobot/dcim/forms.py
index 00d059030..1349347f4 100644
--- a/nautobot/dcim/forms.py
+++ b/nautobot/dcim/forms.py
@@ -879,8 +879,8 @@ class DeviceTypeForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm
         widgets = {
             "subdevice_role": StaticSelect2(),
             # Exclude SVG images (unsupported by PIL)
-            "front_image": forms.FileInput(attrs={"accept": "image/bmp,image/gif,image/jpeg,image/png,image/tiff"}),
-            "rear_image": forms.FileInput(attrs={"accept": "image/bmp,image/gif,image/jpeg,image/png,image/tiff"}),
+            "front_image": forms.ClearableFileInput(attrs={"accept": "image/bmp,image/gif,image/jpeg,image/png,image/tiff"}),
+            "rear_image": forms.ClearableFileInput(attrs={"accept": "image/bmp,image/gif,image/jpeg,image/png,image/tiff"}),
         }

image

@glennmatthews glennmatthews added good first issue Great issues for newcomers! group: dcim type: feature Introduction of new or enhanced functionality to the application labels Feb 9, 2022
jifox added a commit to jifox/nautobot that referenced this issue Feb 9, 2022
glennmatthews pushed a commit that referenced this issue Feb 10, 2022
* Fix issue #1353 - Delete images from device_type

* Fix: black linting
glennmatthews added a commit that referenced this issue Feb 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Great issues for newcomers! type: feature Introduction of new or enhanced functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants