Add 'keywords' field to Part

- Shows up in search results
This commit is contained in:
Oliver Walters 2019-05-14 17:23:20 +10:00
parent 7447561f77
commit 02033c2157
6 changed files with 43 additions and 13 deletions

View File

@ -157,6 +157,7 @@ class PartList(generics.ListCreateAPIView):
'$name',
'description',
'$IPN',
'keywords',
]

View File

@ -92,9 +92,10 @@ class EditPartForm(HelperForm):
'confirm_creation',
'category',
'name',
'IPN',
'variant',
'description',
'IPN',
'keywords',
'URL',
'default_location',
'default_supplier',

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-05-14 07:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0022_auto_20190512_1246'),
]
operations = [
migrations.AddField(
model_name='part',
name='keywords',
field=models.CharField(blank=True, help_text='Part keywords to improve visibility in search results', max_length=250),
),
]

View File

@ -179,8 +179,9 @@ class Part(models.Model):
Attributes:
name: Brief name for this part
variant: Optional variant number for this part - Must be unique for the part name
description: Longer form description of the part
category: The PartCategory to which this part belongs
description: Longer form description of the part
keywords: Optional keywords for improving part search results
IPN: Internal part number (optional)
URL: Link to an external page with more information about this part (e.g. internal Wiki)
image: Image of this part
@ -250,6 +251,8 @@ class Part(models.Model):
description = models.CharField(max_length=250, blank=False, help_text='Part description')
keywords = models.CharField(max_length=250, blank=True, help_text='Part keywords to improve visibility in search results')
category = models.ForeignKey(PartCategory, related_name='parts',
null=True, blank=True,
on_delete=models.DO_NOTHING,

View File

@ -62,15 +62,16 @@ class PartSerializer(serializers.ModelSerializer):
fields = [
'pk',
'url', # Link to the part detail page
'full_name',
'name',
'variant',
'image_url',
'IPN',
'URL', # Link to an external URL (optional)
'description',
'category',
'category_name',
'image_url',
'full_name',
'name',
'IPN',
'variant',
'description',
'keywords',
'URL',
'total_stock',
'available_stock',
'units',

View File

@ -35,16 +35,22 @@
<td>Part name</td>
<td>{{ part.full_name }}</td>
</tr>
<tr>
<td>Description</td>
<td>{{ part.description }}</td>
</tr>
{% if part.IPN %}
<tr>
<td>IPN</td>
<td>{{ part.IPN }}</td>
</tr>
{% endif %}
<tr>
<td>Description</td>
<td>{{ part.description }}</td>
</tr>
{% if part.keywords %}
<tr>
<td>Keywords</td>
<td>{{ part.keywords }}</td>
</tr>
{% endif %}
{% if part.URL %}
<tr>
<td>URL</td>