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
|
||||
.Python
|
||||
env/
|
||||
inventree-env/
|
||||
./build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
|
@ -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):
|
||||
|
@ -120,7 +120,7 @@ class EditPartForm(HelperForm):
|
||||
'keywords',
|
||||
'variant_of',
|
||||
'is_template',
|
||||
'URL',
|
||||
'link',
|
||||
'default_location',
|
||||
'default_supplier',
|
||||
'units',
|
||||
|
@ -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.
|
||||
"""
|
||||
|
||||
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):
|
||||
|
||||
|
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)
|
||||
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,
|
||||
|
@ -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
|
||||
|
@ -60,11 +60,11 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if part.URL %}
|
||||
{% if part.link %}
|
||||
<tr>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td><b>{% trans "Link" %}</b></td>
|
||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
||||
<td><b>{% trans "External Link" %}</b></td>
|
||||
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if part.default_location %}
|
||||
|
@ -72,14 +72,16 @@
|
||||
<table class='table table-condensed'>
|
||||
{% if part.IPN %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "IPN" %}</td>
|
||||
<td>{{ part.IPN }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if part.URL %}
|
||||
{% if part.link %}
|
||||
<tr>
|
||||
<td>{% trans "URL" %}</td>
|
||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
|
@ -1388,8 +1388,6 @@ class BomExport(AjaxView):
|
||||
url += '?file_format=' + fmt
|
||||
url += '&cascade=' + str(cascade)
|
||||
|
||||
print("URL:", url)
|
||||
|
||||
data = {
|
||||
'form_valid': part is not None,
|
||||
'url': url,
|
||||
|
Loading…
Reference in New Issue
Block a user