mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-30 12:26:25 -06:00
Fix E501 errors
This commit is contained in:
parent
7edd1a58c8
commit
e5001aac95
@ -35,7 +35,10 @@ class ChoiceFieldFix(OpenApiSerializerFieldExtension):
|
|||||||
|
|
||||||
elif direction == "response":
|
elif direction == "response":
|
||||||
value = build_cf
|
value = build_cf
|
||||||
label = {**build_basic_type(OpenApiTypes.STR), "enum": list(OrderedDict.fromkeys(self.target.choices.values()))}
|
label = {
|
||||||
|
**build_basic_type(OpenApiTypes.STR),
|
||||||
|
"enum": list(OrderedDict.fromkeys(self.target.choices.values()))
|
||||||
|
}
|
||||||
|
|
||||||
return build_object_type(
|
return build_object_type(
|
||||||
properties={
|
properties={
|
||||||
|
@ -22,7 +22,7 @@ class JobSerializer(BaseModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Job
|
model = Job
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display_url', 'display', 'object_type', 'object_id', 'name', 'status', 'created', 'scheduled', 'interval',
|
'id', 'url', 'display_url', 'display', 'object_type', 'object_id', 'name', 'status', 'created', 'scheduled',
|
||||||
'started', 'completed', 'user', 'data', 'error', 'job_id',
|
'interval', 'started', 'completed', 'user', 'data', 'error', 'job_id',
|
||||||
]
|
]
|
||||||
brief_fields = ('url', 'created', 'completed', 'user', 'status')
|
brief_fields = ('url', 'created', 'completed', 'user', 'status')
|
||||||
|
@ -93,9 +93,14 @@ class ManagedFile(SyncedDataMixin, models.Model):
|
|||||||
self.file_path = os.path.basename(self.data_path)
|
self.file_path = os.path.basename(self.data_path)
|
||||||
|
|
||||||
# Ensure that the file root and path make a unique pair
|
# Ensure that the file root and path make a unique pair
|
||||||
if self._meta.model.objects.filter(file_root=self.file_root, file_path=self.file_path).exclude(pk=self.pk).exists():
|
if self._meta.model.objects.filter(
|
||||||
|
file_root=self.file_root, file_path=self.file_path
|
||||||
|
).exclude(pk=self.pk).exists():
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
f"A {self._meta.verbose_name.lower()} with this file path already exists ({self.file_root}/{self.file_path}).")
|
_("A {model} with this file path already exists ({path}).").format(
|
||||||
|
model=self._meta.verbose_name.lower(),
|
||||||
|
path=f"{self.file_root}/{self.file_path}"
|
||||||
|
))
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
# Delete file from disk
|
# Delete file from disk
|
||||||
|
@ -203,7 +203,17 @@ class Job(models.Model):
|
|||||||
job_end.send(self)
|
job_end.send(self)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def enqueue(cls, func, instance=None, name='', user=None, schedule_at=None, interval=None, immediate=False, **kwargs):
|
def enqueue(
|
||||||
|
cls,
|
||||||
|
func,
|
||||||
|
instance=None,
|
||||||
|
name='',
|
||||||
|
user=None,
|
||||||
|
schedule_at=None,
|
||||||
|
interval=None,
|
||||||
|
immediate=False,
|
||||||
|
**kwargs
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Create a Job instance and enqueue a job using the given callable
|
Create a Job instance and enqueue a job using the given callable
|
||||||
|
|
||||||
|
@ -20,11 +20,27 @@ urlpatterns = (
|
|||||||
|
|
||||||
# Background Tasks
|
# Background Tasks
|
||||||
path('background-queues/', views.BackgroundQueueListView.as_view(), name='background_queue_list'),
|
path('background-queues/', views.BackgroundQueueListView.as_view(), name='background_queue_list'),
|
||||||
path('background-queues/<int:queue_index>/<str:status>/', views.BackgroundTaskListView.as_view(), name='background_task_list'),
|
path(
|
||||||
|
'background-queues/<int:queue_index>/<str:status>/',
|
||||||
|
views.BackgroundTaskListView.as_view(),
|
||||||
|
name='background_task_list'
|
||||||
|
),
|
||||||
path('background-tasks/<str:job_id>/', views.BackgroundTaskView.as_view(), name='background_task'),
|
path('background-tasks/<str:job_id>/', views.BackgroundTaskView.as_view(), name='background_task'),
|
||||||
path('background-tasks/<str:job_id>/delete/', views.BackgroundTaskDeleteView.as_view(), name='background_task_delete'),
|
path(
|
||||||
path('background-tasks/<str:job_id>/requeue/', views.BackgroundTaskRequeueView.as_view(), name='background_task_requeue'),
|
'background-tasks/<str:job_id>/delete/',
|
||||||
path('background-tasks/<str:job_id>/enqueue/', views.BackgroundTaskEnqueueView.as_view(), name='background_task_enqueue'),
|
views.BackgroundTaskDeleteView.as_view(),
|
||||||
|
name='background_task_delete'
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
'background-tasks/<str:job_id>/requeue/',
|
||||||
|
views.BackgroundTaskRequeueView.as_view(),
|
||||||
|
name='background_task_requeue'
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
'background-tasks/<str:job_id>/enqueue/',
|
||||||
|
views.BackgroundTaskEnqueueView.as_view(),
|
||||||
|
name='background_task_enqueue'
|
||||||
|
),
|
||||||
path('background-tasks/<str:job_id>/stop/', views.BackgroundTaskStopView.as_view(), name='background_task_stop'),
|
path('background-tasks/<str:job_id>/stop/', views.BackgroundTaskStopView.as_view(), name='background_task_stop'),
|
||||||
path('background-workers/<int:queue_index>/', views.WorkerListView.as_view(), name='worker_list'),
|
path('background-workers/<int:queue_index>/', views.WorkerListView.as_view(), name='worker_list'),
|
||||||
path('background-workers/<str:key>/', views.WorkerView.as_view(), name='worker'),
|
path('background-workers/<str:key>/', views.WorkerView.as_view(), name='worker'),
|
||||||
|
Loading…
Reference in New Issue
Block a user