mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Remove reliance on django-markdownx (#3231)
* Remove reliance on django-markdownx - We are now rendering notes on the client side using easymde - No longer any need to utilize the markdownx integration - Adds character limit for notes fields` * Adjust legacy migrations - remove references to markdownx * Fix bug for company notes field
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
# Generated by Django 2.2.9 on 2020-01-31 10:22
|
||||
|
||||
from django.db import migrations
|
||||
import markdownx.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -14,6 +13,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='notes',
|
||||
field=markdownx.models.MarkdownxField(help_text='Part notes - supports Markdown formatting'),
|
||||
field=models.TextField(help_text='Part notes - supports Markdown formatting'),
|
||||
),
|
||||
]
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Generated by Django 2.2.9 on 2020-02-23 09:01
|
||||
|
||||
from django.db import migrations
|
||||
import markdownx.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -14,6 +13,6 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='notes',
|
||||
field=markdownx.models.MarkdownxField(blank=True, help_text='Part notes - supports Markdown formatting'),
|
||||
field=models.TextField(blank=True, help_text='Part notes - supports Markdown formatting'),
|
||||
),
|
||||
]
|
||||
|
@ -3,8 +3,6 @@
|
||||
import InvenTree.fields
|
||||
import InvenTree.validators
|
||||
|
||||
import markdownx
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
@ -38,7 +36,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='notes',
|
||||
field=markdownx.models.MarkdownxField(blank=True, help_text='Part notes - supports Markdown formatting', null=True),
|
||||
field=models.TextField(blank=True, help_text='Part notes - supports Markdown formatting', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
|
@ -4,7 +4,6 @@ import InvenTree.fields
|
||||
import InvenTree.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import markdownx.models
|
||||
import mptt.fields
|
||||
import part.settings
|
||||
|
||||
@ -65,7 +64,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='notes',
|
||||
field=markdownx.models.MarkdownxField(blank=True, help_text='Part notes - supports Markdown formatting', null=True, verbose_name='Notes'),
|
||||
field=models.TextField(blank=True, help_text='Part notes - supports Markdown formatting', null=True, verbose_name='Notes'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
|
19
InvenTree/part/migrations/0079_alter_part_notes.py
Normal file
19
InvenTree/part/migrations/0079_alter_part_notes.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.13 on 2022-06-20 07:28
|
||||
|
||||
import InvenTree.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('part', '0078_auto_20220606_0024'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='part',
|
||||
name='notes',
|
||||
field=InvenTree.fields.InvenTreeNotesField(blank=True, help_text='Part notes', max_length=50000, null=True, verbose_name='Notes'),
|
||||
),
|
||||
]
|
@ -25,7 +25,6 @@ from django_cleanup import cleanup
|
||||
from djmoney.contrib.exchange.exceptions import MissingRate
|
||||
from djmoney.contrib.exchange.models import convert_money
|
||||
from jinja2 import Template
|
||||
from markdownx.models import MarkdownxField
|
||||
from mptt.exceptions import InvalidMove
|
||||
from mptt.managers import TreeManager
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
@ -41,7 +40,7 @@ from common.models import InvenTreeSetting
|
||||
from common.settings import currency_code_default
|
||||
from company.models import SupplierPart
|
||||
from InvenTree import helpers, validators
|
||||
from InvenTree.fields import InvenTreeURLField
|
||||
from InvenTree.fields import InvenTreeNotesField, InvenTreeURLField
|
||||
from InvenTree.helpers import decimal2money, decimal2string, normalize
|
||||
from InvenTree.models import (DataImportMixin, InvenTreeAttachment,
|
||||
InvenTreeTree)
|
||||
@ -920,11 +919,7 @@ class Part(MetadataMixin, MPTTModel):
|
||||
verbose_name=_('Virtual'),
|
||||
help_text=_('Is this a virtual part, such as a software product or license?'))
|
||||
|
||||
notes = MarkdownxField(
|
||||
blank=True, null=True,
|
||||
verbose_name=_('Notes'),
|
||||
help_text=_('Part notes - supports Markdown formatting')
|
||||
)
|
||||
notes = InvenTreeNotesField(help_text=_('Part notes'))
|
||||
|
||||
bom_checksum = models.CharField(max_length=128, blank=True, verbose_name=_('BOM checksum'), help_text=_('Stored BOM checksum'))
|
||||
|
||||
|
@ -1305,6 +1305,22 @@ class PartDetailTests(InvenTreeAPITestCase):
|
||||
self.assertFalse('hello' in part.metadata)
|
||||
self.assertEqual(part.metadata['x'], 'y')
|
||||
|
||||
def test_part_notes(self):
|
||||
"""Unit tests for the part 'notes' field"""
|
||||
|
||||
# Ensure that we cannot upload a very long piece of text
|
||||
url = reverse('api-part-detail', kwargs={'pk': 1})
|
||||
|
||||
response = self.patch(
|
||||
url,
|
||||
{
|
||||
'notes': 'abcde' * 10001
|
||||
},
|
||||
expected_code=400
|
||||
)
|
||||
|
||||
self.assertIn('Ensure this field has no more than 50000 characters', str(response.data['notes']))
|
||||
|
||||
|
||||
class PartAPIAggregationTest(InvenTreeAPITestCase):
|
||||
"""Tests to ensure that the various aggregation annotations are working correctly..."""
|
||||
|
Reference in New Issue
Block a user