added display of sub-storage when expanding sub-storages in stock view
This commit is contained in:
@@ -83,20 +83,24 @@ class Storage(models.Model):
|
||||
# caching variable for subtrees
|
||||
storage_list = None
|
||||
|
||||
def get_path_components(self):
|
||||
def get_path_components(self, top_level=None):
|
||||
chain = []
|
||||
iterator = self
|
||||
chain.append(self)
|
||||
while iterator.parent_storage is not None:
|
||||
|
||||
if top_level and iterator.parent_storage == top_level:
|
||||
break
|
||||
|
||||
chain.append(iterator.parent_storage)
|
||||
iterator = iterator.parent_storage
|
||||
|
||||
return chain
|
||||
|
||||
def get_full_path(self):
|
||||
def get_full_path(self, top_level=None):
|
||||
output = ''
|
||||
|
||||
chain = self.get_path_components()
|
||||
chain = self.get_path_components(top_level)
|
||||
|
||||
for i in range(len(chain) - 1, -1, -1):
|
||||
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)}'
|
Reference in New Issue
Block a user