detect no subscriptions

This commit is contained in:
rootzoll
2020-05-26 17:43:59 +02:00
parent f93659089e
commit fe39635fa5

View File

@@ -47,47 +47,45 @@ You have no active or inactive subscriptions at the moment.
''',title="Info") ''',title="Info")
return return
while True: # load subscriptions and make dialog choices out of it
choices = []
lookup = {}
lookupIndex=0
subs = toml.load(SUBSCRIPTIONS_FILE)
# load subscriptions and make dialog choices out of it # list ip2tor subscriptions
choices = [] for sub in subs['subscriptions_ip2tor']:
lookup = {} # remember subscription under lookupindex
lookupIndex=0 lookupIndex += 1
subs = toml.load(SUBSCRIPTIONS_FILE) lookup[str(lookupIndex)]=sub
# add to dialog choices
if sub['active']:
activeState="on"
else:
activeState="off"
name="IP2TOR brigde for {0}".format(sub['blitz_service'])
choices.append( ("{0}".format(lookupIndex), "{0} ({1})".format(name.ljust(20), activeState)) )
# list ip2tor subscriptions # show menu with options
for sub in subs['subscriptions_ip2tor']: d = Dialog(dialog="dialog",autowidgetsize=True)
# remember subscription under lookupindex d.set_background_title("RaspiBlitz Subscriptions")
lookupIndex += 1 code, tag = d.menu(
lookup[str(lookupIndex)]=sub "You have the following subscriptions (active & inactive). Select for details:",
# add to dialog choices choices=choices, title="My Subscriptions")
if sub['active']:
activeState="on"
else:
activeState="off"
name="IP2TOR brigde for {0}".format(sub['blitz_service'])
choices.append( ("{0}".format(lookupIndex), "{0} ({1})".format(name.ljust(20), activeState)) )
# show menu with options # if user chosses CANCEL
d = Dialog(dialog="dialog",autowidgetsize=True) if code != d.OK: return
d.set_background_title("RaspiBlitz Subscriptions")
code, tag = d.menu(
"You have the following subscriptions (active & inactive). Select for details:",
choices=choices, title="My Subscriptions")
# if user cancels # get data of selected subscrption
if code != d.OK: return selectedSub = lookup[str(tag)]
# get data of selected subscrption # show details of selected
selectedSub = lookup[str(tag)] d = Dialog(dialog="dialog",autowidgetsize=True)
d.set_background_title("My Subscriptions")
# show details of selected if selectedSub['type'] == "ip2tor-v1":
d = Dialog(dialog="dialog",autowidgetsize=True) if len(selectedSub['warning']) > 0:
d.set_background_title("My Subscriptions") selectedSub['warning'] = "\n{0}".formart(selectedSub['warning'])
if selectedSub['type'] == "ip2tor-v1": text='''
if len(selectedSub['warning']) > 0:
selectedSub['warning'] = "\n{0}".formart(selectedSub['warning'])
text='''
This is a IP2TOR subscription bought on {initdate} at This is a IP2TOR subscription bought on {initdate} at
{shop} {shop}
@@ -113,19 +111,22 @@ The following additional information is available:
warning=selectedSub['warning'], warning=selectedSub['warning'],
description=selectedSub['description'], description=selectedSub['description'],
service=selectedSub['blitz_service'] service=selectedSub['blitz_service']
) )
if selectedSub['active']: if selectedSub['active']:
extraLable = "CANCEL" extraLable = "CANCEL"
else: else:
extraLable = "DELETE" extraLable = "DELETE"
code = d.msgbox(text, title="Subscription Detail", ok_label="Back", extra_button=True, extra_label=extraLable ,width=70, height=30) code = d.msgbox(text, title="Subscription Detail", ok_label="Back", extra_button=True, extra_label=extraLable ,width=70, height=30)
# user wants to delete this subscription # user wants to delete this subscription
if code == "extra": if code == "extra":
if selectedSub['type'] == "ip2tor-v1": if selectedSub['type'] == "ip2tor-v1":
# TODO: make call to blitz.ip2tor to cancel/delete subscription # TODO: make call to blitz.ip2tor to cancel/delete subscription
pass pass
# loop until no more subscriptions or user chooses CANCEL on subscription list
mySubscriptions()
####### SSH MENU ######### ####### SSH MENU #########