Commit Graph

277 Commits

Author SHA1 Message Date
Omri Abu
e6d364b250 Initilize error_message to empty string
Update template branching for empty template render output
2025-05-16 14:46:43 -04:00
Jeremy Stretch
64b5867cb3 Merge branch 'main' into feature 2025-05-01 09:45:38 -04:00
Renato Almeida de Oliveira
584fff90c7
Closes #18215: Create ScriptJobTable from JobTable and add it to ScriptSourceView (#19337) 2025-04-28 09:57:48 -05:00
Jeremy Stretch
37cfc50202
Fixes #19322: Correct URL paths for bulk import views (#19323) 2025-04-25 12:20:25 -05:00
Jeremy Stretch
fc0acb020f Merge main into feature 2025-04-10 17:17:21 -04:00
Jeremy Stretch
bb5057c063
Closes #14591: Saved table configurations (#19101)
* Add SavedTableConfig

* Update table configuration logic to support TableConfigs

* Update table config link when updating table

* Correct docstring

* Misc cleanup

* Use multi-select widgets for column selection

* Return null config params for tables with no model

* Fix auto-selection of selected columns

* Update migration

* Clean up template

* Enforce enabled/shared flags

* Search/filter by table name

* Misc cleanup

* Fix population of selected columns

* Ordering field should not be required

* Enable cloning for TableConfig

* Misc cleanup

* Add model documentation for TableConfig

* Drop slug field from TableConfig

* Improve TableConfig validation

* Remove add button from TableConfig list view

* Fix ordering validation to account for leading hyphens
2025-04-10 15:48:02 -05:00
Jason Novinger
f07e2dd4e2
Fixes #18944: Clearing widget type field no longer causes 500 error (#18946)
* Fixes #18944: Clearing widget type field no longer causes 500 error

* Address PR feedback, cleanup implementation
2025-03-20 09:12:05 -04:00
Arthur Hanson
1b4e00aeda
18896 Replace STORAGE_BACKEND with STORAGES and support Script running from S3 (#18680) 2025-03-17 07:36:34 -07:00
atownson
48b825c64a
Closes #18024: Add URL pattern for scripts to reference them by module.name (#18723)
* Add URL pattern for scripts to reference them by module.name

* Change _get_script function name and syntax

* Fix formatting issue
2025-02-25 09:39:39 -05:00
Alexander Haase
3e1cc0d7f3
Fixes 18208: Consolidate rendering configuration templates (#18604) 2025-02-10 11:03:08 -05:00
Renato Almeida de Oliveira
efa939d0c2
Fixes: #18241 - Script results log_threshold should default to Default (#18501)
* Changed LogLevelChoices order; Changed ScriptResultView to select LogLevelChoices to LOG_DEFAULT and setup the html template to put (All) in the last one

* Change LogLevelChoices in ScriptResultView get_table method

* Remove default option, add Default string to INFO

* Fix scripts.py and reports.py to reflect removing DEFAULT level

* fix linting
2025-02-06 16:30:25 -05:00
Jeremy Stretch
39ca3ce571 Merge branch 'develop' into feature 2024-12-12 12:13:45 -05:00
Arthur Hanson
d122c334fd 18044 enable alert for plugins in script 2024-12-02 12:23:00 -05:00
Jeremy Stretch
ff7a59db2e Closes #17752: Rename URL paths for bulk import to *_bulk_import 2024-11-22 12:51:06 -05:00
Jeremy Stretch
f08e36e538 Merge branch 'develop' into feature 2024-11-21 14:00:57 -05:00
Alexander Haase
09a0e579fa
Fixes: #17923, #17921 - Fix non-null constraint for script execution (#17932)
* Fix non-null constraint for script execution

With c34a0e2, validation of job object fields is enabled, so ScriptJob
must not set required fields to empty strings. This commit reverts
b18f193 and (hopefully) fixes this issue not only for UI views, but for
all interactions with scripts.

Fixes: #17923

* Fix name of recurring jobs

For recurring jobs, the name must be passed to the next job object when
the job is rescheduled.
2024-11-21 08:43:59 -05:00
Jeremy Stretch
a0b4b0afe0
Closes #18023: Employ register_model_view() for list views (#18029)
* Extend register_model_view() to enable registering list views

* Register circuits list views with register_model_view()

* Register core list views with register_model_view()

* Fix bulk_edit & bulk_delete URL paths

* Register dcim list views with register_model_view() (WIP)

* Register dcim list views with register_model_view()

* Register extras list views with register_model_view()

* Register ipam list views with register_model_view()

* Register tenancy list views with register_model_view()

* Register users list views with register_model_view()

* Register virtualization list views with register_model_view()

* Register vpn list views with register_model_view()

* Register wireless list views with register_model_view()

* Add change note for register_model_view()
2024-11-20 15:54:37 -05:00
Arthur Hanson
5f94dff815 17885 fix script running by providing script name to job 2024-10-29 16:47:15 -04:00
Jeremy Stretch
e59f776e02
Closes #17725: Clean up import statements (#17728)
* #17725: Resolve all F401 errors

* Tweak noqa designation
2024-10-10 14:52:47 -04:00
Jeremy Stretch
6f7bf5baf4 Merge branch 'develop' into feature 2024-08-29 10:51:38 -04:00
Jeremy Stretch
50839fcb6b Fixes #16756: Fix table pagination for custom script results 2024-08-28 16:24:16 -04:00
Jeremy Stretch
dd3166a4ed
Fixes #17097: Record static object representation when calling NotificationGroup.notify() (#17161)
* Fixes #17097: Record static object representation when calling NotificationGroup.notify()

* Redirect to notifications list when marking as read notifications for deleted objects

* Link to object in notifications dropdown only for non-destructive events
2024-08-15 12:04:19 -04:00
Jeremy Stretch
a49a74236b #16886: Misc cleanup 2024-07-31 16:02:20 -04:00
Jeremy Stretch
d1e16013f0 #16886: Rename Event to EventType 2024-07-31 15:39:05 -04:00
Jeremy Stretch
a63bb6dba6 #8984: Tweak ordering of log levels; fix invalid level handling 2024-07-30 14:49:42 -04:00
Alexander Haase
d3a3a6ba46
15692: Introduce background jobs (#16927)
* Introduce reusable BackgroundJob framework

A new abstract class can be used to implement job function classes. It
handles the necessary logic for starting and stopping jobs, including
exception handling and rescheduling of recurring jobs.

This commit also includes the migration of data source jobs to the new
framework.

* Restore using import_string for jobs

Using the 'import_string()' utility from Django allows the job script
class to be simplified, as module imports no longer need to avoid loops.
This should make it easier to queue and maintain jobs.

* Use SyncDataSourceJob for management command

Instead of maintaining two separate job execution logics, the same job
is now used for both background and interactive execution.

* Implement BackgroundJob for running scripts

The independent implementations of interactive and background script
execution have been merged into a single BackgroundJob implementation.

* Fix documentation of model features

* Ensure consitent code style

* Introduce reusable ScheduledJob

A new abstract class can be used to implement job function classes that
specialize in scheduling. These use the same logic as regular
BackgroundJobs, but ensure that they are only scheduled once at any given
time.

* Introduce reusable SystemJob

A new abstract class can be used to implement job function classes that
specialize in system background tasks (e.g. synchronization or
housekeeping). In addition to the features of the BackgroundJob and
ScheduledJob classes, these implement additional logic to not need to be
bound to an existing NetBox object and to setup job schedules on plugin
load instead of an interactive request.

* Add documentation for jobs framework

* Revert "Use SyncDataSourceJob for management"

This partially reverts commit db591d4. The 'run_now' parameter of
'enqueue()' remains, as its being used by following commits.

* Merge enqueued status into JobStatusChoices

* Fix logger for ScriptJob

* Remove job name for scripts

Because scripts are already linked through the Job Instance field, the
name is displayed twice. Removing this reduces redundancy and opens up
the possibility of simplifying the BackgroundJob framework in future
commits.

* Merge ScheduledJob into BackgroundJob

Instead of using separate classes, the logic of ScheduledJob is now
merged into the generic BackgroundJob class. This allows reusing the
same logic, but dynamically deciding whether to enqueue the same job
once or multiple times.

* Add name attribute for BackgroundJob

Instead of defining individual names on enqueue, BackgroundJob classes
can now set a job name in their meta class. This is equivalent to other
Django classes and NetBox scripts.

* Drop enqueue_sync_job() method from DataSource

* Import ScriptJob directly

* Relax requirement for Jobs to reference a specific object

* Rename 'run_now' arg on Job.enqueue() to 'immediate'

* Fix queue lookup in Job enqueue

* Collapse SystemJob into BackgroundJob

* Remove legacy JobResultStatusChoices

ChoiceSet was moved to core in 40572b5.

* Use queue 'low' for system jobs by default

System jobs usually perform low-priority background tasks and therefore
can use a different queue than 'default', which is used for regular jobs
related to specific objects.

* Add test cases for BackgroundJob handling

* Fix enqueue interval jobs

As the job's name is set by enqueue(), it must not be passed in handle()
to avoid duplicate kwargs with the same name.

* Honor schedule_at for job's enqueue_once

Not only can a job's interval change, but so can the time at which it is
scheduled to run. If a specific scheduled time is set, it will also be
checked against the current job schedule. If there are any changes, the
job is rescheduled with the new time.

* Switch BackgroundJob to regular methods

Instead of using a class method for run(), a regular method is used for
this purpose. This gives the possibility to add more convenience methods
in the future, e.g. for interacting with the job object or for logging,
as implemented for scripts.

* Fix background tasks documentation

* Test enqueue in combination with enqueue_once

* Rename background jobs to tasks (to differentiate from RQ)

* Touch up docs

* Revert "Use queue 'low' for system jobs by default"

This reverts commit b17b2050df.

* Remove system background job

This commit reverts commits 4880d81 and 0b15ecf. Using the database
'connection_created' signal for job registration feels a little wrong at
this point, as it would trigger registration very often. However, the
background job framework is prepared for this use case and can be used
by plugins once the auto-registration of jobs is solved.

* Fix runscript management command

Defining names for background jobs was disabled with fb75389. The
preceeding changes in 257976d did forget the management command.

* Use regular imports for ScriptJob

* Rename BackgroundJob to JobRunner

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-30 13:31:21 -04:00
Arthur Hanson
0a1ce79154
16992 remove TODO for NetBox 4.1 (#16993)
* 16992 remove TODO for NetBox 4.1

* 16992 fix custom validator

* Remove obsolete LegacyScriptRedirectView

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-26 09:46:16 -04:00
Jeremy Stretch
44a9350986
Closes #16886: Dynamic event types (#16938)
* Initial work on #16886

* Restore GraphQL filter

* Remove namespace

* Add Event documentation

* Use MultipleChoiceField for event_types

* Fix event_types field class on EventRuleImportForm

* Fix tests

* Simplify event queue handling logic

* Misc cleanup
2024-07-22 08:12:04 -04:00
Jeremy Stretch
b0e7294bc1
Closes #15621: User notifications (#16800)
* Initial work on #15621

* Signal receiver should ignore models which don't support notifications

* Flesh out NotificationGroup functionality

* Add NotificationGroup filters for users & groups

* Separate read & dimiss actions

* Enable one-click dismissals from notifications list

* Include total notification count in dropdown

* Drop 'kind' field from Notification model

* Register event types in the registry; add colors & icons

* Enable event rules to target notification groups

* Define dynamic choices for Notification.event_name

* Move event registration to core

* Add more job events

* Misc cleanup

* Misc cleanup

* Correct absolute URLs for notifications & subscriptions

* Optimize subscriber notifications

* Use core event types when queuing events

* Standardize queued event attribute to event_type; change content_type to object_type

* Rename Notification.event_name to event_type

* Restore NotificationGroupBulkEditView

* Add API tests

* Add view & filterset tests

* Add model documentation

* Fix tests

* Update notification bell when notifications have been cleared

* Ensure subscribe button appears only on relevant models

* Notifications/subscriptions cannot be ordered by object

* Misc cleanup

* Add event icon & type to notifications table

* Adjust icon sizing

* Mute color of read notifications

* Misc cleanup
2024-07-15 14:24:11 -04:00
Arthur Hanson
5ac5135dbc
8984 Allow script log to be filtered (#16446)
* 8984 filter by script log level

* 8984 filter log list

* 8984 add dropdown

* 8984 add dropdown

* 8984 fix button color

* Update netbox/extras/views.py

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* 8984 review changes

* 8984 review changes

* 8984 review changes

* Clean up log threshold selector

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-07-01 16:04:29 -04:00
Jeremy Stretch
c22463f4aa
Closes #16580: Remove AUTH_EXEMPT_PATHS (#16662)
* Closes #16580: Remove AUTH_EXEMPT_PATHS

* Misc cleanup
2024-06-26 12:05:38 -04:00
Jeremy Stretch
08ac5cd52c Merge branch 'develop' into feature 2024-06-24 15:40:43 -04:00
Arthur Hanson
85fd232614
16149 add (optional) obj hyperlink to script list table (#16271)
* 16149 add (optional) obj hyperlink to script list table

* 16149 add (optional) obj hyperlink to script list table

* 16149 review feedback

* 16149 review changes
2024-06-21 10:04:52 -04:00
Jeremy Stretch
853d990c03
Closes #16388: Move change logging resources from extras to core (#16545)
* Initial work on #16388

* Misc cleanup
2024-06-17 08:03:06 -04:00
Jeremy Stretch
a094719d23 Closes #16290: Capture entire object in changelog data 2024-05-29 09:34:22 -04:00
Arthur Hanson
58da5c1252
15353 add better script error message (#15441)
* 15353 add better script error message

* Simplify _get_script_class() & add docstring

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-05-17 14:54:30 -04:00
Jeremy Stretch
312291b010 Merge branch 'develop' into feature 2024-05-01 16:09:14 -04:00
Jeremy Stretch
a2efec09be Fixes #15891: Ensure deterministic ordering for scripts & reports 2024-05-01 10:46:25 -04:00
Julio Oliveira at Encora
79b9dc2013
Feature #15428 - Show all devices with configuration template attached (#15822)
* Added devices instances column for config templates.

* Added devices instances column for config templates.

* Add counts for VMs, roles, and platforms

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-04-29 14:15:44 -04:00
Jeremy Stretch
744be59a4d
Closes #14736: Enable HTMX navigation globally (#15158)
* Enable HTMX boosting

* Refactor HTMX properties for tables

* Fix dashboard object list widget

* Disable scrolling to page content

* Fix initialization of TomSelect dropdowns after HTMX loading

* Replace formaction properties with hx-post

* Fix quick search field on object list view

* Reinitialize copy-to-clipboard buttons upon HTMX load

* Disable scrolling effect for intra-page navigation

* Introduce user preference for toggling HTMX navigation

* Enable HTMX navigation only when selected by user

* Pass htmx_navigation context

* Fix display of confirmation form when deleting an object

* Disable HTMX boosting for rack elevation SVG downloads

* Fix dyanmic form rendering

* Introduce htmx_boost template tag; enable HTMX for user menu

* Use out-of-band sap to update footer stamp

* Fix display of toasts after form submission

* Fix user preference selection

* Misc cleanup

* Rename render_partial() to htmx_partial()

* Add docstring to htmx_boost template tag

* Disable HTMX for user preferences form to force a full page refresh on changes
2024-03-28 11:51:38 -04:00
Jeremy Stretch
ae8df77cc8 Move count_related() & dict_to_filter_params() to utilities.query 2024-03-22 08:59:52 -04:00
Jeremy Stretch
a49eb80f9e Move dict_to_querydict() and normalize_querydict() to utilities.querydict 2024-03-22 08:59:52 -04:00
Jeremy Stretch
81ca455fef Move array_to_range(), array_to_string(), deepmerge(), drange(), flatten_dict(), and shallow_compare_dict() to utilities.data 2024-03-22 08:59:52 -04:00
Jeremy Stretch
ef774319f4 Move NetBoxFakeRequest and copy_safe_request() from utilities.utils to utilities.request 2024-03-22 08:59:52 -04:00
Jeremy Stretch
3547ea376c Move utilities.utils.get_viewname() to utilities.views 2024-03-22 08:59:52 -04:00
Jeremy Stretch
8f03a19b5f Introduce ObjectAttribute for displaying read-only instance attributes on forms 2024-03-19 13:34:13 -04:00
Arthur Hanson
663bd32464
10587 script pagination (#15343)
* 10587 temp commit

* 10587 temp commit

* 10587 fix migrations

* 10587 pagination

* 10587 pagination

* 10587 pagination

* 10587 review changes
2024-03-07 11:41:34 -05:00
Jeremy Stretch
0e89f46601 #15277: Clean up references to object types in templates 2024-03-04 11:49:39 -05:00
Jeremy Stretch
aeeec284a5 Rename CustomField.content_types to object_types & use ObjectType proxy 2024-03-04 08:33:44 -05:00
Arthur Hanson
ca2ee436a0
Closes #14438: Database representation of scripts
- Introduces the Script model to represent individual Python classes within a ScriptModule file
- Automatically migrates jobs & event rules

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-02-23 08:27:37 -05:00