Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

Oppdaterte placement-funksjonene for å utheve en kategori dersom to argumenter blir gitt (hylle og kategori).

This commit is contained in:
Jabir Ali Ouassou 2011-03-05 22:57:27 +00:00
parent 232d53380a
commit 8b425a26ef
2 changed files with 7 additions and 4 deletions

View File

@ -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
@ -37,6 +37,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()

View File

@ -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 }
}