Created
July 19, 2018 20:00
-
-
Save cruor99/459cb54862d57e7685daaefd33f5eaf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.screenmanager import Screen | |
from kivy.network.urlrequest import UrlRequest | |
from kivy.properties import ListProperty, StringProperty, ObjectProperty, BooleanProperty, DictProperty, NumericProperty | |
from kivy.lang import Builder | |
from kivy.clock import Clock, mainthread | |
from kivy.logger import Logger | |
from components.buttons import AvatarWidget, EventButton | |
from kivymd.icon_definitions import md_icons | |
from threading import Thread | |
Builder.load_file("kv/screens/event_screen.kv") | |
class EventScreen(Screen): | |
event_instance = ObjectProperty() | |
ticket_list = ListProperty([]) | |
ticket_matches = BooleanProperty(False) | |
list_ticket_list = ListProperty([]) | |
dict_ticket_list = DictProperty({}) | |
event_image = StringProperty("") | |
ticket_status = StringProperty("img/camera.png") | |
status_icon = StringProperty(md_icons["arrow-down-bold"]) | |
max_amount_icon = StringProperty(md_icons["ticket-account"]) | |
checked_in_tickets_icon = StringProperty(md_icons["ticket"]) | |
current_ticket = DictProperty({"buyer_first_name": "", | |
"buyer_last_name": "", | |
"row": "", | |
"buyer_phone": "", | |
"section_name": "", | |
"invoice_uuid": "", | |
"item_type_title": ""}) | |
name_icon = StringProperty(md_icons["account"]) | |
phone_icon = StringProperty(md_icons["cellphone-iphone"]) | |
location_icon = StringProperty(md_icons["map-marker"]) | |
pages_progress = NumericProperty(0) | |
def on_enter(self): | |
self.pages_progress = 0 | |
#Clock.schedule_interval(self.increase_progress, 1) | |
thr = Thread(target=self.grab_tickets) | |
thr.start() | |
self.event_image = self.event_instance.image | |
def on_ticket_list(self, object, value): | |
Logger.info("All tickets gathered!") | |
Logger.info("Amount of tickets: {}".format(len(self.ticket_list))) | |
#self.ids.ticket_status.text = "OK" | |
self.ids.ticket_amount.text = "Antall Billetter: {}".format(len(self.ticket_list)) | |
self.status_icon = md_icons["check-circle"] | |
self.pages_progress = 100 | |
for ticket in self.ticket_list: | |
self.list_ticket_list.append(ticket["uuid"]) | |
self.dict_ticket_list[ticket["uuid"]] = ticket | |
@mainthread | |
def increase_progress(self, *args): | |
self.pages_progress += 1 | |
def grab_tickets(self): | |
ticket_list = [] | |
i = 1 | |
while True: | |
self.increase_progress() | |
try: | |
items = App.get_running_app().root.ticketco_object.item_grosses(event_id=self.event_instance.event_id, page=i)[1]["item_grosses"] | |
Logger.debug("Ticket items: {}".format(len(items))) | |
ticket_list += items | |
i += 1 | |
print self.event_instance.event_id | |
if len(items) == 0: | |
Logger.info("Final ticket page: {}".format(i)) | |
self.ticket_list = ticket_list | |
break | |
else: | |
Logger.info("Ticket page: {}".format(i)) | |
except Exception as e: | |
Logger.exception(e) | |
Logger.info("Ran into an issue") | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment