Compare commits
2 Commits
50ecaa2cc0
...
6e01b1939d
Author | SHA1 | Date | |
---|---|---|---|
6e01b1939d | |||
a77f46d697 |
@ -29,7 +29,7 @@ class StorageSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = parts_models.Storage
|
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):
|
class ComponentSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
package_data = PackageSerializerNoLink(source='package', read_only=True)
|
package_data = PackageSerializerNoLink(source='package', read_only=True)
|
||||||
|
@ -92,7 +92,8 @@ class MyTestForm(forms.Form):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class ChangeStorageForm(forms.Form):
|
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',
|
responsible = AutocompleteForeingKeyField(api_search_url='user-list',
|
||||||
image_field_name=None,
|
image_field_name=None,
|
||||||
name_field_name='username',
|
name_field_name='username',
|
||||||
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
@ -62,6 +62,7 @@ class Storage(models.Model):
|
|||||||
|
|
||||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
|
||||||
name = models.CharField(max_length=100, validators=[storage_name_validator])
|
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)
|
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)
|
responsible = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, blank=True, null=True)
|
||||||
|
|
||||||
|
@ -484,6 +484,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
|
|||||||
context['add_storage_form'] = add_storage_form
|
context['add_storage_form'] = add_storage_form
|
||||||
change_storage_form = ChangeStorageForm()
|
change_storage_form = ChangeStorageForm()
|
||||||
change_storage_form.fields['storage_name'].initial = self.object.name
|
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['responsible'].initial = self.object.responsible.id
|
||||||
change_storage_form.fields['is_template'].initial = self.object.is_template
|
change_storage_form.fields['is_template'].initial = self.object.is_template
|
||||||
context['change_storage_form'] = change_storage_form
|
context['change_storage_form'] = change_storage_form
|
||||||
@ -498,6 +499,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
|
|||||||
sub_name = f.cleaned_data['storage_name']
|
sub_name = f.cleaned_data['storage_name']
|
||||||
try:
|
try:
|
||||||
Storage.objects.create(name=sub_name,
|
Storage.objects.create(name=sub_name,
|
||||||
|
verbose_name=f.cleaned_data.get('verbose_name'),
|
||||||
parent_storage=self.object,
|
parent_storage=self.object,
|
||||||
responsible=f.cleaned_data['responsible'],
|
responsible=f.cleaned_data['responsible'],
|
||||||
is_template=f.cleaned_data['is_template'],
|
is_template=f.cleaned_data['is_template'],
|
||||||
@ -514,6 +516,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
|
|||||||
sub_name = f.cleaned_data['storage_name']
|
sub_name = f.cleaned_data['storage_name']
|
||||||
try:
|
try:
|
||||||
self.object.name = f.cleaned_data['storage_name']
|
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.responsible = f.cleaned_data['responsible']
|
||||||
self.object.is_template = f.cleaned_data['is_template']
|
self.object.is_template = f.cleaned_data['is_template']
|
||||||
self.object.save()
|
self.object.save()
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
{% qr_from_text object.get_qr_code size="m" image_format="svg" %}
|
{% qr_from_text object.get_qr_code size="m" image_format="svg" %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<h4>{{storage.name}}{% if storage.verbose_name %}<small> ({{storage.verbose_name}})</small>{% endif %}</h4>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if object.parent_storage %}
|
{% if object.parent_storage %}
|
||||||
<h1>Sub-Storages <a class="btn btn-secondary" href="{% url 'parts-stocks-detail' uuid=object.parent_storage.id %}">Parent Storage</a> {% else %}
|
<h1>Sub-Storages <a class="btn btn-secondary" href="{% url 'parts-stocks-detail' uuid=object.parent_storage.id %}">Parent Storage</a> {% else %}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<a href="{% url 'parts-stocks-detail' uuid=storage.id %}" class="text-decoration-none">
|
<a href="{% url 'parts-stocks-detail' uuid=storage.id %}" class="text-decoration-none">
|
||||||
<li class="list-group-item list-group-item-action justify-content-between align-items-center d-flex">
|
<li class="list-group-item list-group-item-action justify-content-between align-items-center d-flex">
|
||||||
<div>
|
<div>
|
||||||
<h5>{{storage.name}}</h5>
|
<h5>{{storage.name}}{% if storage.verbose_name %}<small> ({{storage.verbose_name}})</small>{% endif %}</h5>
|
||||||
Responsible: {{ storage.responsible }}
|
Responsible: {{ storage.responsible }}
|
||||||
</div>
|
</div>
|
||||||
<span class="badge bg-primary rounded-pill">{{storage.get_total_stock_amount}}</span>
|
<span class="badge bg-primary rounded-pill">{{storage.get_total_stock_amount}}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user