[boobcoming] search by ticket status
This commit is contained in:
parent
9b901bed1f
commit
1142868dd7
1 changed files with 26 additions and 19 deletions
|
|
@ -24,7 +24,7 @@ from datetime import time, datetime
|
||||||
from weboob.tools.date import parse_date
|
from weboob.tools.date import parse_date
|
||||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||||
from weboob.capabilities.base import empty
|
from weboob.capabilities.base import empty
|
||||||
from weboob.capabilities.calendar import CapCalendarEvent, Query, CATEGORIES, BaseCalendarEvent
|
from weboob.capabilities.calendar import CapCalendarEvent, Query, CATEGORIES, BaseCalendarEvent, TICKET
|
||||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -188,6 +188,29 @@ class Boobcoming(ReplApplication):
|
||||||
return super(Boobcoming, self).comp_object(obj1, obj2)
|
return super(Boobcoming, self).comp_object(obj1, obj2)
|
||||||
|
|
||||||
|
|
||||||
|
def select_values(self, values_from, values_to, query_str):
|
||||||
|
r = 'notempty'
|
||||||
|
while r != '':
|
||||||
|
for value in values_from.values:
|
||||||
|
print(' %s%2d)%s [%s] %s' % (self.BOLD,
|
||||||
|
values_from.index[value] + 1,
|
||||||
|
self.NC,
|
||||||
|
'x' if value in values_to else ' ',
|
||||||
|
value))
|
||||||
|
r = self.ask(query_str, regexp='(\d+|)', default='')
|
||||||
|
|
||||||
|
if not r.isdigit():
|
||||||
|
continue
|
||||||
|
r = int(r)
|
||||||
|
if r <= 0 or r > len(values_from.values):
|
||||||
|
continue
|
||||||
|
value = values_from.values[r - 1]
|
||||||
|
if value in values_to:
|
||||||
|
values_to.remove(value)
|
||||||
|
else:
|
||||||
|
values_to.append(value)
|
||||||
|
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
def do_search(self, line):
|
def do_search(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -196,26 +219,10 @@ class Boobcoming(ReplApplication):
|
||||||
search for an event. Parameters interactively asked
|
search for an event. Parameters interactively asked
|
||||||
"""
|
"""
|
||||||
query = Query()
|
query = Query()
|
||||||
r = 'notempty'
|
self.select_values(CATEGORIES, query.categories, ' Select categorie (or empty to stop)')
|
||||||
while r != '':
|
self.select_values(TICKET, query.ticket, ' Select tickets status (or empty to stop)')
|
||||||
for category in CATEGORIES.values:
|
|
||||||
print(' %s%2d)%s [%s] %s' % (self.BOLD,
|
|
||||||
CATEGORIES.index[category] + 1,
|
|
||||||
self.NC,
|
|
||||||
'x' if category in query.categories else ' ', category))
|
|
||||||
r = self.ask(' Select category (or empty to stop)', regexp='(\d+|)', default='')
|
|
||||||
if not r.isdigit():
|
|
||||||
continue
|
|
||||||
r = int(r)
|
|
||||||
if r <= 0 or r > len(CATEGORIES.values):
|
|
||||||
continue
|
|
||||||
value = CATEGORIES.values[r - 1]
|
|
||||||
if value in query.categories:
|
|
||||||
query.categories.remove(value)
|
|
||||||
else:
|
|
||||||
query.categories.append(value)
|
|
||||||
|
|
||||||
if query.categories and len(query.categories) > 0:
|
if query.categories and len(query.categories) > 0 and query.ticket and len(query.ticket) > 0:
|
||||||
query.city = self.ask('Enter a city', default='')
|
query.city = self.ask('Enter a city', default='')
|
||||||
query.summary = self.ask('Enter a title', default='')
|
query.summary = self.ask('Enter a title', default='')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue