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
|
||||
|
||||
def print_shelf(shelf, title=None):
|
||||
def print_shelf(shelf, category=None, title=None):
|
||||
# Discover the dimensions of the shelves
|
||||
cols = len(shelf)
|
||||
rows, cell_height, cell_width = 0,0,0
|
||||
|
@ -38,6 +38,9 @@ def print_shelf(shelf, title=None):
|
|||
except:
|
||||
content = ""
|
||||
|
||||
if category and content.upper() == category.upper():
|
||||
content = "\x1B[31;1m" + content.upper() + "\x1B[0m"
|
||||
|
||||
spacing = " "*(cell_width-len(content))
|
||||
output.append( format_cell %(content, spacing) )
|
||||
|
||||
|
@ -55,9 +58,9 @@ def print_all_shelves():
|
|||
print_shelf(Placement.shelf_as_list(shelfname), title=shelfname)
|
||||
|
||||
|
||||
def print_shelf_cmd(shelfname):
|
||||
def print_shelf_cmd(shelfname, category):
|
||||
if shelfname:
|
||||
print_shelf(Placement.shelf_as_list(shelfname), title=shelfname)
|
||||
print_shelf(Placement.shelf_as_list(shelfname), category=category, title=shelfname)
|
||||
else:
|
||||
print_all_shelves()
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ commands = { 'show':
|
|||
'options': [],
|
||||
'fun': edit_book_or_person },
|
||||
'map':
|
||||
{ 'args': [('shelfname', (0,1))],
|
||||
{ 'args': [('shelfname', (0,1)), ('category', (0,1))],
|
||||
'options': [],
|
||||
'fun': placement.print_shelf_cmd }
|
||||
}
|
||||
|
|
Reference in New Issue