Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions netbox/extras/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from netbox.forms import NetBoxModelForm
from tenancy.models import Tenant, TenantGroup
from users.models import Group, User
from utilities.forms import add_blank_choice, get_field_value
from utilities.forms import get_field_value
from utilities.forms.fields import (
CommentField, ContentTypeChoiceField, ContentTypeMultipleChoiceField, DynamicModelChoiceField,
DynamicModelMultipleChoiceField, JSONField, SlugField,
Expand Down Expand Up @@ -687,8 +687,7 @@ class Meta:
class JournalEntryForm(NetBoxModelForm):
kind = forms.ChoiceField(
label=_('Kind'),
choices=add_blank_choice(JournalEntryKindChoices),
required=False
choices=JournalEntryKindChoices
)
comments = CommentField()

Expand Down
25 changes: 25 additions & 0 deletions netbox/extras/migrations/0123_journalentry_kind_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import migrations

from extras.choices import JournalEntryKindChoices


def set_kind_default(apps, schema_editor):
"""
Set kind to "info" on any entries with no kind assigned.
"""
JournalEntry = apps.get_model('extras', 'JournalEntry')
JournalEntry.objects.filter(kind='').update(kind=JournalEntryKindChoices.KIND_INFO)


class Migration(migrations.Migration):

dependencies = [
('extras', '0122_charfield_null_choices'),
]

operations = [
migrations.RunPython(
code=set_kind_default,
reverse_code=migrations.RunPython.noop
),
]