diff --git a/shimatta_kenkyusho/api/serializers.py b/shimatta_kenkyusho/api/serializers.py index 7bf01a8..4c404cb 100644 --- a/shimatta_kenkyusho/api/serializers.py +++ b/shimatta_kenkyusho/api/serializers.py @@ -29,7 +29,7 @@ class StorageSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = parts_models.Storage - fields = ['url', 'id', 'name', 'parent_storage', 'responsible', 'full_path'] + fields = ['url', 'id', 'name', 'verbose_name', 'parent_storage', 'responsible', 'template', 'full_path'] class ComponentSerializer(serializers.HyperlinkedModelSerializer): package_data = PackageSerializerNoLink(source='package', read_only=True) diff --git a/shimatta_kenkyusho/parts/forms.py b/shimatta_kenkyusho/parts/forms.py index fbbf9fd..6d94b08 100644 --- a/shimatta_kenkyusho/parts/forms.py +++ b/shimatta_kenkyusho/parts/forms.py @@ -92,7 +92,8 @@ class MyTestForm(forms.Form): pass class ChangeStorageForm(forms.Form): - storage_name = forms.CharField(label="storage_name", initial='') + storage_name = forms.CharField(label="Name", initial='') + verbose_name = forms.CharField(label="Verbose Name", initial='') responsible = AutocompleteForeingKeyField(api_search_url='user-list', image_field_name=None, name_field_name='username', diff --git a/shimatta_kenkyusho/parts/migrations/0012_storage_verbose_name.py b/shimatta_kenkyusho/parts/migrations/0012_storage_verbose_name.py new file mode 100644 index 0000000..5ad2741 --- /dev/null +++ b/shimatta_kenkyusho/parts/migrations/0012_storage_verbose_name.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.5 on 2024-11-16 11:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('parts', '0011_auto_20241110_1242'), + ] + + operations = [ + migrations.AddField( + model_name='storage', + name='verbose_name', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/shimatta_kenkyusho/parts/models.py b/shimatta_kenkyusho/parts/models.py index f5c3de8..b78ebf8 100644 --- a/shimatta_kenkyusho/parts/models.py +++ b/shimatta_kenkyusho/parts/models.py @@ -62,6 +62,7 @@ class Storage(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) name = models.CharField(max_length=100, validators=[storage_name_validator]) + verbose_name = models.CharField(max_length=100, null=True, blank=True) parent_storage = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True) responsible = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, blank=True, null=True) diff --git a/shimatta_kenkyusho/parts/views.py b/shimatta_kenkyusho/parts/views.py index 585f19f..6de8672 100644 --- a/shimatta_kenkyusho/parts/views.py +++ b/shimatta_kenkyusho/parts/views.py @@ -484,6 +484,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView): context['add_storage_form'] = add_storage_form change_storage_form = ChangeStorageForm() change_storage_form.fields['storage_name'].initial = self.object.name + change_storage_form.fields['verbose_name'].initial = self.object.verbose_name change_storage_form.fields['responsible'].initial = self.object.responsible.id change_storage_form.fields['is_template'].initial = self.object.is_template context['change_storage_form'] = change_storage_form @@ -498,6 +499,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView): sub_name = f.cleaned_data['storage_name'] try: Storage.objects.create(name=sub_name, + verbose_name=f.cleaned_data.get('verbose_name'), parent_storage=self.object, responsible=f.cleaned_data['responsible'], is_template=f.cleaned_data['is_template'], @@ -514,6 +516,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView): sub_name = f.cleaned_data['storage_name'] try: self.object.name = f.cleaned_data['storage_name'] + self.object.verbose_name = f.cleaned_data.get('verbose_name') self.object.responsible = f.cleaned_data['responsible'] self.object.is_template = f.cleaned_data['is_template'] self.object.save() diff --git a/shimatta_kenkyusho/templates/parts/stocks-detail.html b/shimatta_kenkyusho/templates/parts/stocks-detail.html index 4276312..4d969f6 100644 --- a/shimatta_kenkyusho/templates/parts/stocks-detail.html +++ b/shimatta_kenkyusho/templates/parts/stocks-detail.html @@ -20,6 +20,9 @@