mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 13:58:47 +00:00
* adds new field 'parameter type' to PartParameterTemplate model * Move part parameter settings onto their own page * Add "choices" and "regex" template types * Adds validation for PartParameter based on template type * javascript cleanup * Fix for serializers.py * Add unit testing for parameter validation * Add filters * Rename "type" field to "param_type" - Should have seen that one coming * Coerce 'boolean' value to True/False * table update * js linting * Add requirement for "pint" package * Add validator for physical unit types - Revert a previous migration which adds "parameter type" and "validator" fields - These will get implemented later, too much scope creep for this PR - Add unit test for validation of "units" field * Update PartParameter model - Add data_numeric field (will be used later) - Add MinLengthValidator to data field * Run validation for part parameter data - Ensure it can be converted to internal units * Update admin interface to display partparameter values inline for a part * Adds validation of part parameter data value - Also converts to base units, and stores as "numeric" value - Display "numeric" value in tables - Create new file conversion.py for data conversion * Update unit tests and fix some bugs * Update docstring * Add units to parameter columns in parameteric part table * Allow part list to be ordered by a particular parameter value - Annotate queryset with new "order_by_parameter" method - Skeleton method for future work * Bump API version * Adds unit testing for sorting parts by parameter value * Update historical data migrations - Turns out RunPython.noop is a thing? * Cache the unit registry - Creating the unit registry takes a significant amount of time - Construct when first called, and then cache for subsequent hits - Massive improvement in performance * Throw error on empty values when converting between units * Data migration for converting existing part parameter values * Handle more error cases * Show parameteric table on top-level part page too * Unit test for data migration * Update credits in docs * Improved error checking * WIP docs updates * Fix parameteric table filtering * remove zoom property * Fix for import path * Update parameter docs * Run background task to rebuild parameters when template changes * Make "data_numeric" field nullable - Defaulting to zero is not appropriate, as the actual value may be zero - Sorting still seems to work just fine * Fixes for unit test * More unit test fixes * Further fixes for unit tests --------- Co-authored-by: Matthias Mair <code@mjmair.com>
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
# Generated by Django 3.0.7 on 2020-10-19 11:25
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
def add_default_reference(apps, schema_editor):
|
|
"""
|
|
Add a "default" build-order reference for any existing build orders.
|
|
Best we can do is use the PK of the build order itself.
|
|
"""
|
|
|
|
Build = apps.get_model('build', 'build')
|
|
|
|
count = 0
|
|
|
|
for build in Build.objects.all():
|
|
|
|
build.reference = str(build.pk)
|
|
build.save()
|
|
count += 1
|
|
|
|
if count > 0:
|
|
print(f"\nUpdated build reference for {count} existing BuildOrder objects")
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
atomic = False
|
|
|
|
dependencies = [
|
|
('build', '0017_auto_20200426_0612'),
|
|
]
|
|
|
|
operations = [
|
|
# Initial operation - create a 'reference' field for the Build object:
|
|
migrations.AddField(
|
|
model_name='build',
|
|
name='reference',
|
|
field=models.CharField(help_text='Build Order Reference', blank=True, max_length=64, unique=False, verbose_name='Reference'),
|
|
),
|
|
|
|
# Auto-populate the new reference field for any existing build order objects
|
|
migrations.RunPython(
|
|
add_default_reference,
|
|
reverse_code=migrations.RunPython.noop
|
|
),
|
|
|
|
# Now that each build has a non-empty, unique reference, update the field requirements!
|
|
migrations.AlterField(
|
|
model_name='build',
|
|
name='reference',
|
|
field=models.CharField(
|
|
help_text='Build Order Reference',
|
|
max_length=64,
|
|
blank=False,
|
|
unique=True,
|
|
verbose_name='Reference'
|
|
)
|
|
)
|
|
]
|