Compare commits
1 Commits
develop
...
feature/21
Author | SHA1 | Date | |
---|---|---|---|
39e40d62f4 |
@ -31,6 +31,5 @@ setuptools==75.3.0
|
||||
sqlparse==0.4.1
|
||||
toml==0.10.2
|
||||
typing_extensions==4.12.2
|
||||
tzdata==2024.2
|
||||
urllib3==2.2.3
|
||||
wrapt==1.12.1
|
||||
|
@ -9,6 +9,7 @@ admin.site.register(parts_models.Manufacturer)
|
||||
admin.site.register(parts_models.Storage)
|
||||
admin.site.register(parts_models.Stock)
|
||||
admin.site.register(parts_models.ComponentParameter)
|
||||
admin.site.register(parts_models.PackageParameter)
|
||||
admin.site.register(parts_models.ComponentParameterType)
|
||||
admin.site.register(parts_models.ComponentType)
|
||||
admin.site.register(parts_models.Distributor)
|
||||
|
49
shimatta_kenkyusho/parts/migrations/0013_packageparameter.py
Normal file
49
shimatta_kenkyusho/parts/migrations/0013_packageparameter.py
Normal file
@ -0,0 +1,49 @@
|
||||
# Generated by Django 5.1.3 on 2024-11-19 20:26
|
||||
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("parts", "0012_storage_verbose_name"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="PackageParameter",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
("value", models.FloatField(default=0)),
|
||||
("text_value", models.TextField(blank=True)),
|
||||
(
|
||||
"package",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="parts.package"
|
||||
),
|
||||
),
|
||||
(
|
||||
"parameter_type",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="parts.componentparametertype",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["id"],
|
||||
"unique_together": {("package", "parameter_type")},
|
||||
},
|
||||
),
|
||||
]
|
@ -238,24 +238,25 @@ class Component(models.Model):
|
||||
sum = 0
|
||||
return sum
|
||||
|
||||
|
||||
class ComponentParameter(models.Model):
|
||||
class AbstractParameter(models.Model):
|
||||
class Meta:
|
||||
unique_together = ('component', 'parameter_type')
|
||||
ordering = ['id']
|
||||
abstract = True
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
|
||||
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=False, blank=True)
|
||||
|
||||
def _get_object_of_param(self):
|
||||
return None
|
||||
|
||||
def __str__(self):
|
||||
if self.parameter_type.parameter_type == 'F':
|
||||
value = self.text_value
|
||||
else:
|
||||
value = str(self.value)
|
||||
|
||||
return str(self.component)+ ': '+ str(self.parameter_type) + ': ' + value
|
||||
return str(self._get_object_of_param())+ ': '+ str(self.parameter_type) + ': ' + value
|
||||
|
||||
def resolved_value_as_string(self):
|
||||
my_type = self.parameter_type.parameter_type
|
||||
@ -270,6 +271,24 @@ class ComponentParameter(models.Model):
|
||||
elif my_type == 'F':
|
||||
return self.text_value
|
||||
|
||||
class ComponentParameter(AbstractParameter):
|
||||
class Meta:
|
||||
unique_together = ('component', 'parameter_type')
|
||||
ordering = ['id']
|
||||
component = models.ForeignKey(Component, on_delete=models.CASCADE) # A target component is required!
|
||||
|
||||
def _get_object_of_param(self):
|
||||
return self.component
|
||||
|
||||
class PackageParameter(AbstractParameter):
|
||||
class Meta:
|
||||
unique_together = ('package', 'parameter_type')
|
||||
ordering = ['id']
|
||||
package = models.ForeignKey(Package, on_delete=models.CASCADE)
|
||||
|
||||
def _get_object_of_param(self):
|
||||
return self.package
|
||||
|
||||
class Stock(models.Model):
|
||||
class Meta:
|
||||
unique_together = ('component', 'storage')
|
||||
|
@ -56,6 +56,7 @@ if get_env_value('DJANGO_FORCE_DEV_MODE', default=False) == 'True':
|
||||
|
||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', get_env_value('DJANGO_ALLOWED_HOST')]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
@ -238,7 +239,4 @@ CSRF_COOKIE_SECURE = True
|
||||
|
||||
SECURE_SSL_REDIRECT = False
|
||||
|
||||
# allow detection of https behind "old" nginx
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
|
||||
|
Loading…
Reference in New Issue
Block a user