Oppdaterte placement-funksjonene for å utheve en kategori dersom to argumenter blir gitt (hylle og kategori).
This commit is contained in:
parent
232d53380a
commit
8b425a26ef
|
@ -1,6 +1,6 @@
|
||||||
from web.library.models import Placement
|
from web.library.models import Placement
|
||||||
|
|
||||||
def print_shelf(shelf, title=None):
|
def print_shelf(shelf, category=None, title=None):
|
||||||
# Discover the dimensions of the shelves
|
# Discover the dimensions of the shelves
|
||||||
cols = len(shelf)
|
cols = len(shelf)
|
||||||
rows, cell_height, cell_width = 0,0,0
|
rows, cell_height, cell_width = 0,0,0
|
||||||
|
@ -37,6 +37,9 @@ def print_shelf(shelf, title=None):
|
||||||
|
|
||||||
except:
|
except:
|
||||||
content = ""
|
content = ""
|
||||||
|
|
||||||
|
if category and content.upper() == category.upper():
|
||||||
|
content = "\x1B[31;1m" + content.upper() + "\x1B[0m"
|
||||||
|
|
||||||
spacing = " "*(cell_width-len(content))
|
spacing = " "*(cell_width-len(content))
|
||||||
output.append( format_cell %(content, spacing) )
|
output.append( format_cell %(content, spacing) )
|
||||||
|
@ -55,9 +58,9 @@ def print_all_shelves():
|
||||||
print_shelf(Placement.shelf_as_list(shelfname), title=shelfname)
|
print_shelf(Placement.shelf_as_list(shelfname), title=shelfname)
|
||||||
|
|
||||||
|
|
||||||
def print_shelf_cmd(shelfname):
|
def print_shelf_cmd(shelfname, category):
|
||||||
if shelfname:
|
if shelfname:
|
||||||
print_shelf(Placement.shelf_as_list(shelfname), title=shelfname)
|
print_shelf(Placement.shelf_as_list(shelfname), category=category, title=shelfname)
|
||||||
else:
|
else:
|
||||||
print_all_shelves()
|
print_all_shelves()
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ commands = { 'show':
|
||||||
'options': [],
|
'options': [],
|
||||||
'fun': edit_book_or_person },
|
'fun': edit_book_or_person },
|
||||||
'map':
|
'map':
|
||||||
{ 'args': [('shelfname', (0,1))],
|
{ 'args': [('shelfname', (0,1)), ('category', (0,1))],
|
||||||
'options': [],
|
'options': [],
|
||||||
'fun': placement.print_shelf_cmd }
|
'fun': placement.print_shelf_cmd }
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue