diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 2ad7ae1c8b..ed4823c35c 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -101,6 +101,7 @@ INSTALLED_APPS = [ 'django_cleanup', # Automatically delete orphaned MEDIA files 'qr_code', # Generate QR codes 'mptt', # Modified Preorder Tree Traversal + 'pagedown.apps.PagedownConfig' # Markdown forms ] LOGGING = { diff --git a/InvenTree/part/admin.py b/InvenTree/part/admin.py index fcef36a772..060723f3d8 100644 --- a/InvenTree/part/admin.py +++ b/InvenTree/part/admin.py @@ -8,6 +8,8 @@ from import_export.resources import ModelResource from import_export.fields import Field import import_export.widgets as widgets +from .forms import PartAdminForm + from .models import PartCategory, Part from .models import PartAttachment, PartStar from .models import BomItem @@ -70,6 +72,9 @@ class PartResource(ModelResource): class PartAdmin(ImportExportModelAdmin): + form = PartAdminForm + #fields = "__all__" + resource_class = PartResource list_display = ('full_name', 'description', 'total_stock', 'category') diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 339c8519fc..5b4cb509fa 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -11,6 +11,8 @@ from mptt.fields import TreeNodeChoiceField from django import forms from django.utils.translation import ugettext as _ +from pagedown.widgets import AdminPagedownWidget + from .models import Part, PartCategory, PartAttachment from .models import BomItem from .models import PartParameterTemplate, PartParameter @@ -18,6 +20,20 @@ from .models import PartParameterTemplate, PartParameter from common.models import Currency +class PartAdminForm(forms.ModelForm): + """ Override default form behaviour for the Part admin interface. + + - Present the 'notes' field as a Markdown-editor + + """ + + notes = forms.CharField(widget=AdminPagedownWidget()) + + class Meta: + model = Part + fields = "__all__" + + class PartImageForm(HelperForm): """ Form for uploading a Part image """ diff --git a/requirements.txt b/requirements.txt index 4770a2e557..20d4923a73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ django-cors-headers==3.2.0 # CORS headers extension for DRF django_filter==2.2.0 # Extended filtering options django-mptt==0.10.0 # Modified Preorder Tree Traversal django-dbbackup==3.2.0 # Database backup / restore functionality +django-pagedown==2.0.3 # Markdown form fields coreapi==2.3.0 # API documentation pygments==2.2.0 # Syntax highlighting tablib==0.13.0 # Import / export data files