mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Rename Part.URL -> part.link
- Previous migration needed some tweaking to get it to run... because.. why? - It seems to pass when running manage.py migrate but fails when running manage.py test - Stumped on this one
This commit is contained in:
parent
bd407cd226
commit
b28487760a
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ __pycache__/
|
|||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
env/
|
env/
|
||||||
|
inventree-env/
|
||||||
./build/
|
./build/
|
||||||
develop-eggs/
|
develop-eggs/
|
||||||
dist/
|
dist/
|
||||||
|
@ -200,7 +200,7 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
'description',
|
'description',
|
||||||
'keywords',
|
'keywords',
|
||||||
'is_template',
|
'is_template',
|
||||||
'URL',
|
'link',
|
||||||
'units',
|
'units',
|
||||||
'minimum_stock',
|
'minimum_stock',
|
||||||
'trackable',
|
'trackable',
|
||||||
@ -249,12 +249,6 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
else:
|
else:
|
||||||
item['category__name'] = None
|
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)
|
return Response(data)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
@ -120,7 +120,7 @@ class EditPartForm(HelperForm):
|
|||||||
'keywords',
|
'keywords',
|
||||||
'variant_of',
|
'variant_of',
|
||||||
'is_template',
|
'is_template',
|
||||||
'URL',
|
'link',
|
||||||
'default_location',
|
'default_location',
|
||||||
'default_supplier',
|
'default_supplier',
|
||||||
'units',
|
'units',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Generated by Django 2.2.10 on 2020-04-04 12:38
|
# Generated by Django 2.2.10 on 2020-04-04 12:38
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
from django.db.utils import OperationalError
|
||||||
|
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
from stdimage.utils import render_variations
|
from stdimage.utils import render_variations
|
||||||
@ -11,11 +12,13 @@ def create_thumbnails(apps, schema_editor):
|
|||||||
Create thumbnails for all existing Part images.
|
Create thumbnails for all existing Part images.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for part in Part.objects.all():
|
try:
|
||||||
# Render thumbnail for each existing Part
|
for part in Part.objects.all():
|
||||||
if part.image:
|
# Render thumbnail for each existing Part
|
||||||
part.image.render_variations()
|
if part.image:
|
||||||
|
part.image.render_variations()
|
||||||
|
except OperationalError:
|
||||||
|
print("Error - could not generate Part thumbnails")
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
18
InvenTree/part/migrations/0035_auto_20200406_0045.py
Normal file
18
InvenTree/part/migrations/0035_auto_20200406_0045.py
Normal file
@ -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',
|
||||||
|
),
|
||||||
|
]
|
@ -214,7 +214,7 @@ class Part(models.Model):
|
|||||||
IPN: Internal part number (optional)
|
IPN: Internal part number (optional)
|
||||||
revision: Part revision
|
revision: Part revision
|
||||||
is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem
|
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
|
image: Image of this part
|
||||||
default_location: Where the item is normally stored (may be null)
|
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
|
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'))
|
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(
|
image = StdImageField(
|
||||||
upload_to=rename_part_image,
|
upload_to=rename_part_image,
|
||||||
|
@ -86,7 +86,6 @@ class PartSerializer(InvenTreeModelSerializer):
|
|||||||
on_order = serializers.FloatField(read_only=True)
|
on_order = serializers.FloatField(read_only=True)
|
||||||
thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
|
thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
|
||||||
url = serializers.CharField(source='get_absolute_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)
|
used_in = serializers.IntegerField(source='used_in_count', read_only=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -60,11 +60,11 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if part.URL %}
|
{% if part.link %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><span class='fas fa-link'></span></td>
|
<td><span class='fas fa-link'></span></td>
|
||||||
<td><b>{% trans "Link" %}</b></td>
|
<td><b>{% trans "External Link" %}</b></td>
|
||||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.default_location %}
|
{% if part.default_location %}
|
||||||
|
@ -72,14 +72,16 @@
|
|||||||
<table class='table table-condensed'>
|
<table class='table table-condensed'>
|
||||||
{% if part.IPN %}
|
{% if part.IPN %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td></td>
|
||||||
<td>{% trans "IPN" %}</td>
|
<td>{% trans "IPN" %}</td>
|
||||||
<td>{{ part.IPN }}</td>
|
<td>{{ part.IPN }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.URL %}
|
{% if part.link %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% trans "URL" %}</td>
|
<td><span class='fas fa-link'></span></td>
|
||||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
<td>{% trans "External Link" %}</td>
|
||||||
|
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1388,8 +1388,6 @@ class BomExport(AjaxView):
|
|||||||
url += '?file_format=' + fmt
|
url += '?file_format=' + fmt
|
||||||
url += '&cascade=' + str(cascade)
|
url += '&cascade=' + str(cascade)
|
||||||
|
|
||||||
print("URL:", url)
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'form_valid': part is not None,
|
'form_valid': part is not None,
|
||||||
'url': url,
|
'url': url,
|
||||||
|
Loading…
Reference in New Issue
Block a user