diff --git a/shimatta_kenkyusho/parts/migrations/0009_auto_20220101_1306.py b/shimatta_kenkyusho/parts/migrations/0009_auto_20220101_1306.py new file mode 100644 index 0000000..7bab409 --- /dev/null +++ b/shimatta_kenkyusho/parts/migrations/0009_auto_20220101_1306.py @@ -0,0 +1,49 @@ +# Generated by Django 3.2.5 on 2022-01-01 13:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('parts', '0008_auto_20220101_1250'), + ] + + operations = [ + migrations.AlterField( + model_name='component', + name='datasheet_link', + field=models.CharField(blank=True, default='', max_length=300), + preserve_default=False, + ), + migrations.AlterField( + model_name='component', + name='description', + field=models.TextField(blank=True, default=''), + preserve_default=False, + ), + migrations.AlterField( + model_name='componentparameter', + name='text_value', + field=models.TextField(blank=True, default=''), + preserve_default=False, + ), + migrations.AlterField( + model_name='distributor', + name='component_link_pattern', + field=models.CharField(blank=True, default='', max_length=255), + preserve_default=False, + ), + migrations.AlterField( + model_name='distributor', + name='website', + field=models.CharField(blank=True, default='', max_length=200), + preserve_default=False, + ), + migrations.AlterField( + model_name='manufacturer', + name='website', + field=models.CharField(blank=True, default='', max_length=200), + preserve_default=False, + ), + ] diff --git a/shimatta_kenkyusho/parts/models.py b/shimatta_kenkyusho/parts/models.py index 2195da3..62704f0 100644 --- a/shimatta_kenkyusho/parts/models.py +++ b/shimatta_kenkyusho/parts/models.py @@ -116,9 +116,9 @@ class Distributor(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) name = models.CharField(max_length=100, unique=True) - website = models.CharField(max_length=200, null=True, blank=True) + website = models.CharField(max_length=200, null=False, blank=True) image = models.ImageField(upload_to=RandomFileName.RandomFileName('distributor-logos'), null=True, blank=True) - component_link_pattern = models.CharField(max_length=255, blank=True, null=True) + component_link_pattern = models.CharField(max_length=255, blank=True, null=False) def __str__(self): return self.name @@ -144,7 +144,7 @@ class Manufacturer(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) name = models.CharField(max_length=100, unique=True) - website = models.CharField(max_length=200, null=True, blank=True) + website = models.CharField(max_length=200, null=False, blank=True) image = models.ImageField(upload_to=RandomFileName.RandomFileName('manufacturer-images'), blank=True, null=True) def __str__(self): @@ -161,8 +161,8 @@ class Component(models.Model): manufacturer = models.ForeignKey(Manufacturer, on_delete=models.PROTECT, blank=True, null=True) component_type = models.ForeignKey(ComponentType, on_delete=models.SET_NULL, blank=True, null=True) pref_distri = models.ForeignKey(Distributor, on_delete=models.PROTECT, blank=True, null=True) - description = models.TextField(null=True, blank=True) - datasheet_link = models.CharField(max_length=300, null=True, blank=True) + description = models.TextField(null=False, blank=True) + datasheet_link = models.CharField(max_length=300, null=False, blank=True) package = models.ForeignKey(Package, on_delete=models.PROTECT, blank=True, null=True) image = models.ImageField(upload_to=RandomFileName.RandomFileName('component-images'), blank=True, null=True) @@ -208,7 +208,7 @@ class ComponentParameter(models.Model): component = models.ForeignKey(Component, on_delete=models.CASCADE) # A target component is required! parameter_type = models.ForeignKey(ComponentParameterType, on_delete=models.CASCADE) value = models.FloatField(default=0) - text_value = models.TextField(null=True, blank=True) + text_value = models.TextField(null=False, blank=True) def __str__(self): if self.parameter_type.parameter_type == 'F': diff --git a/shimatta_kenkyusho/templates/widgets/autocomplete-foreign-key.html b/shimatta_kenkyusho/templates/widgets/autocomplete-foreign-key.html index 7898fa0..ec1a0cf 100644 --- a/shimatta_kenkyusho/templates/widgets/autocomplete-foreign-key.html +++ b/shimatta_kenkyusho/templates/widgets/autocomplete-foreign-key.html @@ -2,7 +2,7 @@ -
+
{% if custom.current_instance %} {% if custom.image_field_name %}
@@ -15,13 +15,18 @@
{% endif %} {% endif %} -
+
{% if custom.current_instance %} - {{custom.current_instance}} + {{custom.current_instance}} {% else %} None selected {% endif %}
+ {% if custom.current_instance %} +
+ +
+ {% endif %}
- +
\ No newline at end of file