mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Adds bulk import for journal entry (#12485)
* adds bulk import for journal entry #12122 * lint fix * Add kind as CSVChoiceField on JournalEntryImportForm --------- Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
42346702a1
commit
ca0e7be637
@ -4,9 +4,10 @@ from django.contrib.postgres.forms import SimpleArrayField
|
|||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from extras.choices import CustomFieldVisibilityChoices, CustomFieldTypeChoices
|
from extras.choices import CustomFieldVisibilityChoices, CustomFieldTypeChoices, JournalEntryKindChoices
|
||||||
from extras.models import *
|
from extras.models import *
|
||||||
from extras.utils import FeatureQuery
|
from extras.utils import FeatureQuery
|
||||||
|
from netbox.forms import NetBoxModelImportForm
|
||||||
from utilities.forms import CSVModelForm
|
from utilities.forms import CSVModelForm
|
||||||
from utilities.forms.fields import CSVChoiceField, CSVContentTypeField, CSVMultipleContentTypeField, SlugField
|
from utilities.forms.fields import CSVChoiceField, CSVContentTypeField, CSVMultipleContentTypeField, SlugField
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ __all__ = (
|
|||||||
'CustomFieldImportForm',
|
'CustomFieldImportForm',
|
||||||
'CustomLinkImportForm',
|
'CustomLinkImportForm',
|
||||||
'ExportTemplateImportForm',
|
'ExportTemplateImportForm',
|
||||||
|
'JournalEntryImportForm',
|
||||||
'SavedFilterImportForm',
|
'SavedFilterImportForm',
|
||||||
'TagImportForm',
|
'TagImportForm',
|
||||||
'WebhookImportForm',
|
'WebhookImportForm',
|
||||||
@ -132,3 +134,20 @@ class TagImportForm(CSVModelForm):
|
|||||||
help_texts = {
|
help_texts = {
|
||||||
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')),
|
'color': mark_safe(_('RGB color in hexadecimal (e.g. <code>00ff00</code>)')),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class JournalEntryImportForm(NetBoxModelImportForm):
|
||||||
|
assigned_object_type = CSVContentTypeField(
|
||||||
|
queryset=ContentType.objects.all(),
|
||||||
|
label=_('Assigned object type'),
|
||||||
|
)
|
||||||
|
kind = CSVChoiceField(
|
||||||
|
choices=JournalEntryKindChoices,
|
||||||
|
help_text=_('The classification of entry')
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = JournalEntry
|
||||||
|
fields = (
|
||||||
|
'assigned_object_type', 'assigned_object_id', 'created_by', 'kind', 'comments', 'tags'
|
||||||
|
)
|
||||||
|
@ -82,6 +82,7 @@ urlpatterns = [
|
|||||||
path('journal-entries/add/', views.JournalEntryEditView.as_view(), name='journalentry_add'),
|
path('journal-entries/add/', views.JournalEntryEditView.as_view(), name='journalentry_add'),
|
||||||
path('journal-entries/edit/', views.JournalEntryBulkEditView.as_view(), name='journalentry_bulk_edit'),
|
path('journal-entries/edit/', views.JournalEntryBulkEditView.as_view(), name='journalentry_bulk_edit'),
|
||||||
path('journal-entries/delete/', views.JournalEntryBulkDeleteView.as_view(), name='journalentry_bulk_delete'),
|
path('journal-entries/delete/', views.JournalEntryBulkDeleteView.as_view(), name='journalentry_bulk_delete'),
|
||||||
|
path('journal-entries/import/', views.JournalEntryBulkImportView.as_view(), name='journalentry_import'),
|
||||||
path('journal-entries/<int:pk>/', include(get_model_urls('extras', 'journalentry'))),
|
path('journal-entries/<int:pk>/', include(get_model_urls('extras', 'journalentry'))),
|
||||||
|
|
||||||
# Change logging
|
# Change logging
|
||||||
|
@ -625,7 +625,7 @@ class JournalEntryListView(generic.ObjectListView):
|
|||||||
filterset = filtersets.JournalEntryFilterSet
|
filterset = filtersets.JournalEntryFilterSet
|
||||||
filterset_form = forms.JournalEntryFilterForm
|
filterset_form = forms.JournalEntryFilterForm
|
||||||
table = tables.JournalEntryTable
|
table = tables.JournalEntryTable
|
||||||
actions = ('export', 'bulk_edit', 'bulk_delete')
|
actions = ('import', 'export', 'bulk_edit', 'bulk_delete')
|
||||||
|
|
||||||
|
|
||||||
@register_model_view(JournalEntry)
|
@register_model_view(JournalEntry)
|
||||||
@ -674,6 +674,11 @@ class JournalEntryBulkDeleteView(generic.BulkDeleteView):
|
|||||||
table = tables.JournalEntryTable
|
table = tables.JournalEntryTable
|
||||||
|
|
||||||
|
|
||||||
|
class JournalEntryBulkImportView(generic.BulkImportView):
|
||||||
|
queryset = JournalEntry.objects.all()
|
||||||
|
model_form = forms.JournalEntryImportForm
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Dashboard & widgets
|
# Dashboard & widgets
|
||||||
#
|
#
|
||||||
|
@ -337,7 +337,7 @@ OPERATIONS_MENU = Menu(
|
|||||||
MenuGroup(
|
MenuGroup(
|
||||||
label=_('Logging'),
|
label=_('Logging'),
|
||||||
items=(
|
items=(
|
||||||
get_model_item('extras', 'journalentry', _('Journal Entries'), actions=[]),
|
get_model_item('extras', 'journalentry', _('Journal Entries'), actions=['import']),
|
||||||
get_model_item('extras', 'objectchange', _('Change Log'), actions=[]),
|
get_model_item('extras', 'objectchange', _('Change Log'), actions=[]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user