2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Custom URL validators for more fields

This commit is contained in:
Oliver Walters 2019-09-14 00:08:49 +10:00
parent 4ac8353099
commit 70e07470db
7 changed files with 80 additions and 7 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.5 on 2019-09-13 14:07
import InvenTree.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('build', '0005_auto_20190604_2217'),
]
operations = [
migrations.AlterField(
model_name='build',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL'),
),
]

View File

@ -17,6 +17,7 @@ from django.db.models import Sum
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
from InvenTree.status_codes import BuildStatus from InvenTree.status_codes import BuildStatus
from InvenTree.fields import InvenTreeURLField
from stock.models import StockItem from stock.models import StockItem
from part.models import Part, BomItem from part.models import Part, BomItem
@ -89,7 +90,7 @@ class Build(models.Model):
related_name='builds_completed' related_name='builds_completed'
) )
URL = models.URLField(blank=True, help_text='Link to external URL') URL = InvenTreeURLField(blank=True, help_text='Link to external URL')
notes = models.TextField(blank=True, help_text='Extra build notes') notes = models.TextField(blank=True, help_text='Extra build notes')
""" Notes attached to each build output """ """ Notes attached to each build output """

View File

@ -0,0 +1,24 @@
# Generated by Django 2.2.5 on 2019-09-13 14:07
import InvenTree.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('company', '0007_remove_supplierpart_lead_time'),
]
operations = [
migrations.AlterField(
model_name='company',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external company information'),
),
migrations.AlterField(
model_name='supplierpart',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='URL for external supplier part link'),
),
]

View File

@ -19,6 +19,7 @@ from django.urls import reverse
from django.conf import settings from django.conf import settings
from django.contrib.staticfiles.templatetags.staticfiles import static from django.contrib.staticfiles.templatetags.staticfiles import static
from InvenTree.fields import InvenTreeURLField
from InvenTree.status_codes import OrderStatus from InvenTree.status_codes import OrderStatus
from common.models import Currency from common.models import Currency
@ -85,7 +86,7 @@ class Company(models.Model):
contact = models.CharField(max_length=100, contact = models.CharField(max_length=100,
blank=True, help_text='Point of contact') blank=True, help_text='Point of contact')
URL = models.URLField(blank=True, help_text='Link to external company information') URL = InvenTreeURLField(blank=True, help_text='Link to external company information')
image = models.ImageField(upload_to=rename_company_image, max_length=255, null=True, blank=True) image = models.ImageField(upload_to=rename_company_image, max_length=255, null=True, blank=True)
@ -238,7 +239,7 @@ class SupplierPart(models.Model):
MPN = models.CharField(max_length=100, blank=True, help_text='Manufacturer part number') MPN = models.CharField(max_length=100, blank=True, help_text='Manufacturer part number')
URL = models.URLField(blank=True, help_text='URL for external supplier part link') URL = InvenTreeURLField(blank=True, help_text='URL for external supplier part link')
description = models.CharField(max_length=250, blank=True, help_text='Supplier part description') description = models.CharField(max_length=250, blank=True, help_text='Supplier part description')

View File

@ -0,0 +1,24 @@
# Generated by Django 2.2.5 on 2019-09-13 14:07
import InvenTree.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('stock', '0014_auto_20190908_0918'),
]
operations = [
migrations.AlterField(
model_name='stockitem',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, max_length=125),
),
migrations.AlterField(
model_name='stockitemtracking',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external page for further information'),
),
]

View File

@ -23,6 +23,7 @@ from InvenTree import helpers
from InvenTree.status_codes import StockStatus from InvenTree.status_codes import StockStatus
from InvenTree.models import InvenTreeTree from InvenTree.models import InvenTreeTree
from InvenTree.fields import InvenTreeURLField
from part.models import Part from part.models import Part
@ -308,7 +309,7 @@ class StockItem(models.Model):
serial = models.PositiveIntegerField(blank=True, null=True, serial = models.PositiveIntegerField(blank=True, null=True,
help_text='Serial number for this item') help_text='Serial number for this item')
URL = models.URLField(max_length=125, blank=True) URL = InvenTreeURLField(max_length=125, blank=True)
batch = models.CharField(max_length=100, blank=True, null=True, batch = models.CharField(max_length=100, blank=True, null=True,
help_text='Batch code for this stock item') help_text='Batch code for this stock item')
@ -715,7 +716,7 @@ class StockItemTracking(models.Model):
notes = models.CharField(blank=True, max_length=512, help_text='Entry notes') notes = models.CharField(blank=True, max_length=512, help_text='Entry notes')
URL = models.URLField(blank=True, help_text='Link to external page for further information') URL = InvenTreeURLField(blank=True, help_text='Link to external page for further information')
user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True) user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)

View File

@ -7,7 +7,7 @@ clean:
rm -rf .tox rm -rf .tox
rm -f .coverage rm -f .coverage
update: backup install migrate update: backup install migrate static
# Perform database migrations (after schema changes are made) # Perform database migrations (after schema changes are made)
migrate: migrate:
@ -15,6 +15,9 @@ migrate:
cd InvenTree && python3 manage.py migrate cd InvenTree && python3 manage.py migrate
cd InvenTree && python3 manage.py migrate --run-syncdb cd InvenTree && python3 manage.py migrate --run-syncdb
cd InvenTree && python3 manage.py check cd InvenTree && python3 manage.py check
# Collect static files into the correct locations
static:
cd InvenTree && python3 manage.py collectstatic cd InvenTree && python3 manage.py collectstatic
# Install all required packages # Install all required packages
@ -64,4 +67,4 @@ backup:
cd InvenTree && python3 manage.py dbbackup cd InvenTree && python3 manage.py dbbackup
cd InvenTree && python3 manage.py mediabackup cd InvenTree && python3 manage.py mediabackup
.PHONY: clean migrate superuser install mysql postgresql style test coverage docreqs docs backup update .PHONY: clean migrate superuser install mysql postgresql static style test coverage docreqs docs backup update