added display of sub-storage when expanding sub-storages in stock view
This commit is contained in:
parent
871086c7b7
commit
6dc8f3bfef
@ -83,20 +83,24 @@ class Storage(models.Model):
|
|||||||
# caching variable for subtrees
|
# caching variable for subtrees
|
||||||
storage_list = None
|
storage_list = None
|
||||||
|
|
||||||
def get_path_components(self):
|
def get_path_components(self, top_level=None):
|
||||||
chain = []
|
chain = []
|
||||||
iterator = self
|
iterator = self
|
||||||
chain.append(self)
|
chain.append(self)
|
||||||
while iterator.parent_storage is not None:
|
while iterator.parent_storage is not None:
|
||||||
|
|
||||||
|
if top_level and iterator.parent_storage == top_level:
|
||||||
|
break
|
||||||
|
|
||||||
chain.append(iterator.parent_storage)
|
chain.append(iterator.parent_storage)
|
||||||
iterator = iterator.parent_storage
|
iterator = iterator.parent_storage
|
||||||
|
|
||||||
return chain
|
return chain
|
||||||
|
|
||||||
def get_full_path(self):
|
def get_full_path(self, top_level=None):
|
||||||
output = ''
|
output = ''
|
||||||
|
|
||||||
chain = self.get_path_components()
|
chain = self.get_path_components(top_level)
|
||||||
|
|
||||||
for i in range(len(chain) - 1, -1, -1):
|
for i in range(len(chain) - 1, -1, -1):
|
||||||
output = output + '/' + chain[i].name
|
output = output + '/' + chain[i].name
|
||||||
|
0
shimatta_kenkyusho/parts/templatetags/__init__.py
Normal file
0
shimatta_kenkyusho/parts/templatetags/__init__.py
Normal file
9
shimatta_kenkyusho/parts/templatetags/storage_tags.py
Normal file
9
shimatta_kenkyusho/parts/templatetags/storage_tags.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import datetime
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="get_relative_storage_path")
|
||||||
|
def get_relative_storage_path(storage, top_level):
|
||||||
|
return f'.{storage.get_full_path(top_level)}'
|
@ -2,6 +2,7 @@
|
|||||||
{% load qr_code %}
|
{% load qr_code %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
|
{% load storage_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -97,6 +98,9 @@
|
|||||||
{% if stock.component.manufacturer %}
|
{% if stock.component.manufacturer %}
|
||||||
Manufacturer: {{stock.component.manufacturer}}
|
Manufacturer: {{stock.component.manufacturer}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if stock.storage != storage %}
|
||||||
|
<span class="text-secondary"><br>{{ stock.storage|get_relative_storage_path:storage }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if stock.lot %}
|
{% if stock.lot %}
|
||||||
<span class="text-secondary"><br>Lot: {{stock.lot}}</span>
|
<span class="text-secondary"><br>Lot: {{stock.lot}}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user