Update requirements

- Use markdownify for rendering
- Use markdownx for editing
This commit is contained in:
Oliver Walters 2020-01-31 21:42:30 +11:00
parent da01177d23
commit c546ed5dcd
9 changed files with 42 additions and 33 deletions

View File

@ -101,7 +101,8 @@ INSTALLED_APPS = [
'django_cleanup', # Automatically delete orphaned MEDIA files
'qr_code', # Generate QR codes
'mptt', # Modified Preorder Tree Traversal
'pagedown.apps.PagedownConfig' # Markdown forms
'markdownx', # Markdown editing
'markdownify', # Markdown template rendering
]
LOGGING = {

View File

@ -100,6 +100,8 @@ urlpatterns = [
url(r'^api/', include(apipatterns)),
url(r'^api-doc/', include_docs_urls(title='InvenTree API')),
url(r'^md/', include('markdownx.urls')),
]
# Static file access

View File

@ -8,8 +8,6 @@ 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
@ -71,9 +69,6 @@ class PartResource(ModelResource):
class PartAdmin(ImportExportModelAdmin):
form = PartAdminForm
#fields = "__all__"
resource_class = PartResource

View File

@ -11,8 +11,6 @@ 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
@ -20,20 +18,6 @@ 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 """
@ -120,7 +104,6 @@ class EditPartForm(HelperForm):
'default_supplier',
'units',
'minimum_stock',
'notes',
'active',
]

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.9 on 2020-01-31 10:22
from django.db import migrations
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('part', '0025_auto_20191118_2316'),
]
operations = [
migrations.AlterField(
model_name='part',
name='notes',
field=markdownx.models.MarkdownxField(help_text='Part notes - supports Markdown formatting'),
),
]

View File

@ -22,6 +22,8 @@ from django.contrib.auth.models import User
from django.db.models.signals import pre_delete
from django.dispatch import receiver
from markdownx.models import MarkdownxField
from mptt.models import TreeForeignKey
from datetime import datetime
@ -422,7 +424,7 @@ class Part(models.Model):
virtual = models.BooleanField(default=False, help_text=_('Is this a virtual part, such as a software product or license?'))
notes = models.TextField(blank=True)
notes = MarkdownxField(help_text=_('Part notes - supports Markdown formatting'))
bom_checksum = models.CharField(max_length=128, blank=True, help_text=_('Stored BOM checksum'))

View File

@ -147,13 +147,6 @@
</div>
</div>
{% if part.notes %}
<div class="panel panel-default">
<div class="panel-heading"><b>{% trans "Notes" %}</b></div>
<div class="panel-body">{{ part.notes }}</div>
</div>
{% endif %}
{% endblock %}
{% block js_load %}

View File

@ -1,6 +1,7 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% load markdownify %}
{% block details %}
@ -8,6 +9,18 @@
<h4>{% trans "Part Notes" %}</h4>
Notes field goes here
<div class='panel panel-default'>
<div class='panel-body'>
{{ part.notes | markdownify }}
</div>
</div>
<form method="post" action="">
{% csrf_token %}
{{ form }}
</form>
{{ form.media }}
{% endblock %}

View File

@ -5,7 +5,8 @@ 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
django-markdownx==3.0.1 # Markdown form fields
django-markdownify==0.8.0 # Markdown rendering
coreapi==2.3.0 # API documentation
pygments==2.2.0 # Syntax highlighting
tablib==0.13.0 # Import / export data files