diff --git a/.gitignore b/.gitignore index bb31aa7d3f..25c1195923 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ # Distribution / packaging .Python env/ +inventree-env/ ./build/ develop-eggs/ dist/ diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 9b73f68973..7bb31af14d 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -200,7 +200,7 @@ class PartList(generics.ListCreateAPIView): 'description', 'keywords', 'is_template', - 'URL', + 'link', 'units', 'minimum_stock', 'trackable', @@ -249,12 +249,6 @@ class PartList(generics.ListCreateAPIView): else: item['category__name'] = None - # Rename "URL" to "link" to distinguish from lower-case "url", - # which is the web address of the item itself - if 'URL' in item.keys(): - item['link'] = item['URL'] - del item['URL'] - return Response(data) def get_queryset(self): diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 5adf1e08dd..332e9b6611 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -120,7 +120,7 @@ class EditPartForm(HelperForm): 'keywords', 'variant_of', 'is_template', - 'URL', + 'link', 'default_location', 'default_supplier', 'units', diff --git a/InvenTree/part/migrations/0034_auto_20200404_1238.py b/InvenTree/part/migrations/0034_auto_20200404_1238.py index 95b3cd2b96..e292202b68 100644 --- a/InvenTree/part/migrations/0034_auto_20200404_1238.py +++ b/InvenTree/part/migrations/0034_auto_20200404_1238.py @@ -1,6 +1,7 @@ # Generated by Django 2.2.10 on 2020-04-04 12:38 from django.db import migrations +from django.db.utils import OperationalError from part.models import Part from stdimage.utils import render_variations @@ -11,11 +12,13 @@ def create_thumbnails(apps, schema_editor): Create thumbnails for all existing Part images. """ - for part in Part.objects.all(): - # Render thumbnail for each existing Part - if part.image: - part.image.render_variations() - + try: + for part in Part.objects.all(): + # Render thumbnail for each existing Part + if part.image: + part.image.render_variations() + except OperationalError: + print("Error - could not generate Part thumbnails") class Migration(migrations.Migration): diff --git a/InvenTree/part/migrations/0035_auto_20200406_0045.py b/InvenTree/part/migrations/0035_auto_20200406_0045.py new file mode 100644 index 0000000000..92f0472880 --- /dev/null +++ b/InvenTree/part/migrations/0035_auto_20200406_0045.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-04-06 00:45 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0034_auto_20200404_1238'), + ] + + operations = [ + migrations.RenameField( + model_name='part', + old_name='URL', + new_name='link', + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 92dd8a0d68..da0bff16b8 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -214,7 +214,7 @@ class Part(models.Model): IPN: Internal part number (optional) revision: Part revision is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem - URL: Link to an external page with more information about this part (e.g. internal Wiki) + link: Link to an external page with more information about this part (e.g. internal Wiki) image: Image of this part default_location: Where the item is normally stored (may be null) default_supplier: The default SupplierPart which should be used to procure and stock this part @@ -383,7 +383,7 @@ class Part(models.Model): revision = models.CharField(max_length=100, blank=True, help_text=_('Part revision or version number')) - URL = InvenTreeURLField(blank=True, help_text=_('Link to extenal URL')) + link = InvenTreeURLField(blank=True, help_text=_('Link to extenal URL')) image = StdImageField( upload_to=rename_part_image, diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 9e97cad84f..18d8fbd8c8 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -86,7 +86,6 @@ class PartSerializer(InvenTreeModelSerializer): on_order = serializers.FloatField(read_only=True) thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True) url = serializers.CharField(source='get_absolute_url', read_only=True) - link = serializers.CharField(source='URL') used_in = serializers.IntegerField(source='used_in_count', read_only=True) @staticmethod diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index b41e470bd2..64e0bed5bc 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -60,11 +60,11 @@ {% endif %} - {% if part.URL %} + {% if part.link %}
{% trans "IPN" %} | {{ part.IPN }} | |||
{% trans "URL" %} | -{{ part.URL }} | ++ | {% trans "External Link" %} | +{{ part.link }} |