mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add a markdown editor for the 'Notes" field of Part model
https://github.com/timmyomahony/django-pagedown
This commit is contained in:
parent
b5f8635794
commit
596d06cf1a
@ -101,6 +101,7 @@ INSTALLED_APPS = [
|
|||||||
'django_cleanup', # Automatically delete orphaned MEDIA files
|
'django_cleanup', # Automatically delete orphaned MEDIA files
|
||||||
'qr_code', # Generate QR codes
|
'qr_code', # Generate QR codes
|
||||||
'mptt', # Modified Preorder Tree Traversal
|
'mptt', # Modified Preorder Tree Traversal
|
||||||
|
'pagedown.apps.PagedownConfig' # Markdown forms
|
||||||
]
|
]
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
@ -8,6 +8,8 @@ from import_export.resources import ModelResource
|
|||||||
from import_export.fields import Field
|
from import_export.fields import Field
|
||||||
import import_export.widgets as widgets
|
import import_export.widgets as widgets
|
||||||
|
|
||||||
|
from .forms import PartAdminForm
|
||||||
|
|
||||||
from .models import PartCategory, Part
|
from .models import PartCategory, Part
|
||||||
from .models import PartAttachment, PartStar
|
from .models import PartAttachment, PartStar
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
@ -70,6 +72,9 @@ class PartResource(ModelResource):
|
|||||||
|
|
||||||
class PartAdmin(ImportExportModelAdmin):
|
class PartAdmin(ImportExportModelAdmin):
|
||||||
|
|
||||||
|
form = PartAdminForm
|
||||||
|
#fields = "__all__"
|
||||||
|
|
||||||
resource_class = PartResource
|
resource_class = PartResource
|
||||||
|
|
||||||
list_display = ('full_name', 'description', 'total_stock', 'category')
|
list_display = ('full_name', 'description', 'total_stock', 'category')
|
||||||
|
@ -11,6 +11,8 @@ from mptt.fields import TreeNodeChoiceField
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
from pagedown.widgets import AdminPagedownWidget
|
||||||
|
|
||||||
from .models import Part, PartCategory, PartAttachment
|
from .models import Part, PartCategory, PartAttachment
|
||||||
from .models import BomItem
|
from .models import BomItem
|
||||||
from .models import PartParameterTemplate, PartParameter
|
from .models import PartParameterTemplate, PartParameter
|
||||||
@ -18,6 +20,20 @@ from .models import PartParameterTemplate, PartParameter
|
|||||||
from common.models import Currency
|
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):
|
class PartImageForm(HelperForm):
|
||||||
""" Form for uploading a Part image """
|
""" Form for uploading a Part image """
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ django-cors-headers==3.2.0 # CORS headers extension for DRF
|
|||||||
django_filter==2.2.0 # Extended filtering options
|
django_filter==2.2.0 # Extended filtering options
|
||||||
django-mptt==0.10.0 # Modified Preorder Tree Traversal
|
django-mptt==0.10.0 # Modified Preorder Tree Traversal
|
||||||
django-dbbackup==3.2.0 # Database backup / restore functionality
|
django-dbbackup==3.2.0 # Database backup / restore functionality
|
||||||
|
django-pagedown==2.0.3 # Markdown form fields
|
||||||
coreapi==2.3.0 # API documentation
|
coreapi==2.3.0 # API documentation
|
||||||
pygments==2.2.0 # Syntax highlighting
|
pygments==2.2.0 # Syntax highlighting
|
||||||
tablib==0.13.0 # Import / export data files
|
tablib==0.13.0 # Import / export data files
|
||||||
|
Loading…
Reference in New Issue
Block a user