def get_obdobie(self, datumova_akcia_id, akademicky_rok=None): '''Returns a time range defined by a given datumova_akcia_id. The academic year of such action can be changed with optional parameter akademicky_rok. Args: datumova_akcia_id: The ID of a time range. (Field 'D.a.') akademicky_rok: Academic year of the time range in the form of 'start/end'. E.g. '2013/2014'. (optional) Returns: A :class:`~Obdobie` object. ''' app = self._open_sprava_datumov() # shortname pre 'D.a.' je pochopitelne 'kod' index = find_row(app.d.akcieTable.all_rows(), kod=datumova_akcia_id) app.d.akcieTable.select(index) # ak je, selectneme aj akademicky rok if akademicky_rok is not None: detail_index = find_row(app.d.detailAkcieTable.all_rows(), ppopisAkademickyRok=akademicky_rok) else: detail_index = 0 row = app.d.detailAkcieTable.all_rows()[detail_index] return Obdobie(obdobie_od=row['odDatumu'], obdobie_do=row['doDatumu'], id_akcie=datumova_akcia_id)
def __get_prihlaseni_studenti_cez_vyber_terminu(self, app, datum, cas, miestnost, poznamka): self.__open_vyber_terminu_dialog(app) # Vyberieme spravny riadok. Ak v tabulke nie je, vypneme "Zobrazit len # aktualne terminy", stlacime nacitavaci button a skusime znovu. try: index = find_row( app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) except KeyError: index = None if index is None: app.d.aktualneTerminyCheckBox.set_to(False) app.d.zobrazitTerminyAction.execute() index = find_row( app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) app.d.zoznamTerminovTable.select(index) # Stlacime "Zobrazit zoznam prihlasenych". with app.collect_operations() as ops: app.d.zobrazitZoznamPrihlasenychAction.execute() result = self.__process_prihlaseni_studenti_list(app, ops) # Stlacime zatvaraci button na zozname terminov. with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) return result
def zapis_odstran_predmety(self, zapisny_list_key, cast, predmet_key_list): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE self.__zatvor_ponuku_predmetov(app) # Oznacime vrchol pre celu cast, aby sme videli vsetky predmety. app.d.castiZapisnehoListuTree.select('nR/' + cast) # Vyberieme v tabulke dane predmety. indexes = [] for predmet_key in predmet_key_list: (skratka_predmetu,) = decode_key(predmet_key) indexes.append(find_row( app.d.predmetyTable.all_rows(), skratka=skratka_predmetu)) app.d.predmetyTable.select(indexes) # Stlacime "Odobrat predmet". with app.collect_operations() as ops: app.d.odobratPredmetButton.click() # Mozno vyskoci confirm box. Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. Ak nie, sme hotovi. if ops: assert_ops(ops, 'messageBox') return ops[0].args[0] return None
def prihlas_na_termin(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) app = self._open_terminy_hodnotenia_app(zapisny_list_key) self.__select_predmet_row(app, predmet_key) self.__open_vyber_terminu_dialog(app) # Vyberieme spravny riadok. app.d.zoznamTerminovTable.select( find_row(app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka)) # Stlacime OK. with app.collect_operations() as ops: app.d.enterButton.click() message = None if ops and ops[0].method == 'messageBox': assert_ops(ops, 'messageBox') message = ops[0].args[0] with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) return message
def get_prihlaseni_studenti(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) app = self._open_terminy_hodnotenia_app(zapisny_list_key) self.__vyber_oba_semestre(app) self.__select_predmet_row(app, predmet_key) app.d.zobrazitTerminyAction.execute() try: index = find_row(app.d.terminyTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) except KeyError: index = None # Ak sa pozerame na stary zapisny list, vyber_terminov_dialog # bude disabled, preto termin musi byt v hlavnom dialogu. if index is not None: app.d.terminyTable.select(index) # Stlacime "Zobrazit zoznam prihlasenych". with app.collect_operations() as ops: app.d.zoznamPrihlasenychStudentovAction.execute() return self.__process_prihlaseni_studenti_list(app, ops) else: # zapisny_list_key a predmet_key uz sme selectli predtym. return self.__get_prihlaseni_studenti_cez_vyber_terminu( app, datum, cas, miestnost, poznamka)
def odhlas_z_terminu(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) (skratka_predmetu,) = decode_key(predmet_key) app = self._open_terminy_hodnotenia_app(zapisny_list_key) # V dolnom combo boxe dame "Zobrazit terminy: Vsetkych predmetov". app.d.zobrazitTerminyComboBox.select(0) # Stlacime button vedla combo boxu. app.d.zobrazitTerminyAction.execute() # Vyberieme spravny riadok. app.d.terminyTable.select(find_row( app.d.terminyTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka, predmetSkratka=skratka_predmetu)) # Stlacime "Odhlasit sa z terminu". with app.collect_operations() as ops: app.d.odstranitButton.click() # Vyskoci confirm box, ci sa naozaj chceme odhlasit. Stlacime "Ano". assert_ops(ops, 'confirmBox') with app.collect_operations() as ops: app.confirm_box(2) if ops: assert_ops(ops, 'messageBox') return ops[0].args[0] return None
def prihlas_na_termin(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) app = self._open_terminy_hodnotenia_app(zapisny_list_key) self.__select_predmet_row(app, predmet_key) self.__open_vyber_terminu_dialog(app) # Vyberieme spravny riadok. app.d.zoznamTerminovTable.select(find_row( app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka)) # Stlacime OK. with app.collect_operations() as ops: app.d.enterButton.click() message = None if ops and ops[0].method == 'messageBox': assert_ops(ops, 'messageBox') message = ops[0].args[0] with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) return message
def zapis_odstran_predmety(self, zapisny_list_key, cast, predmet_key_list): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE self.__zatvor_ponuku_predmetov(app) # Oznacime vrchol pre celu cast, aby sme videli vsetky predmety. app.d.castiZapisnehoListuTree.select('nR/' + cast) # Vyberieme v tabulke dane predmety. indexes = [] for predmet_key in predmet_key_list: (skratka_predmetu, ) = decode_key(predmet_key) indexes.append( find_row(app.d.predmetyTable.all_rows(), skratka=skratka_predmetu)) app.d.predmetyTable.select(indexes) # Stlacime "Odobrat predmet". with app.collect_operations() as ops: app.d.odobratPredmetButton.click() # Mozno vyskoci confirm box. Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. Ak nie, sme hotovi. if ops: assert_ops(ops, 'messageBox') return ops[0].args[0] return None
def get_prihlaseni_studenti(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) app = self._open_terminy_hodnotenia_app(zapisny_list_key) self.__vyber_oba_semestre(app) self.__select_predmet_row(app, predmet_key) app.d.zobrazitTerminyAction.execute() try: index = find_row( app.d.terminyTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) except KeyError: index = None # Ak sa pozerame na stary zapisny list, vyber_terminov_dialog # bude disabled, preto termin musi byt v hlavnom dialogu. if index is not None: app.d.terminyTable.select(index) # Stlacime "Zobrazit zoznam prihlasenych". with app.collect_operations() as ops: app.d.zoznamPrihlasenychStudentovAction.execute() return self.__process_prihlaseni_studenti_list(app, ops) else: # zapisny_list_key a predmet_key uz sme selectli predtym. return self.__get_prihlaseni_studenti_cez_vyber_terminu(app, datum, cas, miestnost, poznamka)
def __select_predmet_row(self, app, predmet_key): self.__vyber_oba_semestre(app) (skratka, ) = decode_key(predmet_key) index = find_row(app.d.predmetyTable.all_rows(), skratka=skratka) app.d.predmetyTable.select(index) return app.d.predmetyTable.all_rows()[index]
def __select_predmet_row(self, app, predmet_key): self.__vyber_oba_semestre(app) (skratka,) = decode_key(predmet_key) index = find_row(app.d.predmetyTable.all_rows(), skratka=skratka) app.d.predmetyTable.select(index) return app.d.predmetyTable.all_rows()[index]
def __vyber_zapisny_list(self, app, zapisny_list_key): studium_key, akademicky_rok = decode_key(zapisny_list_key) # Ak este nie je vybrate spravne studium, vyberieme ho. self.__vyber_studium(app, studium_key) # Vyberieme zapisny list. zapisny_list_index = find_row(app.d.zapisneListyTable.all_rows(), popisAkadRok=akademicky_rok) app.d.zapisneListyTable.select(zapisny_list_index)
def __vyber_zapisny_list(self, app, zapisny_list_key): studium_key, akademicky_rok = decode_key(zapisny_list_key) # Ak este nie je vybrate spravne studium, vyberieme ho. self.__vyber_studium(app, studium_key) # Vyberieme zapisny list. zapisny_list_index = find_row( app.d.zapisneListyTable.all_rows(), popisAkadRok=akademicky_rok) app.d.zapisneListyTable.select(zapisny_list_index)
def spusti_report(client, app, vrchol_stromu, kod_zostavy, parametre, vystupny_format): # selectnem vrchol v strome vlavo app.d.dzTree.select(vrchol_stromu) # v tabulke vyberiem riadok s danym kodom app.d.sysTable.select(find_row(app.d.sysTable.all_rows(), kod=kod_zostavy)) # v menu stlacim "Spustenie" with app.collect_operations() as ops: app.d.sysSpustenieAction.execute() if not parametre: app.awaited_open_dialog(ops) else: assert_ops(ops, 'openDialog', 'openDialog') app.open_dialog(*ops[0].args) app.open_dialog(*ops[1].args) # v dialogu nastavim parametre for index, (label, value) in enumerate(parametre): label_id = 'inputLabel' + str(index + 1) input_id = 'inputTextField' + str(index + 1) if app.d.components[label_id].text != label: raise AISBehaviorError('%s mal byt %r' % (label_id, label)) app.d.components[input_id].write(value) if 'inputLabel' + str(len(parametre) + 1) in app.d.components: raise AISBehaviorError('Zostava ma privela parametrov') # stlacim OK, dialog sa zavrie with app.collect_operations() as ops: app.d.enterButton.click() app.awaited_close_dialog(ops) # nastavim format vystupu app.d.vystupComboBox.select( find_option(app.d.vystupComboBox.options, title=vystupny_format)) # NESTLACAM OK, TYM SA DIALOG ZAVRIE # (for fun si najdi v mailinglistoch ako na to Vinko pravidelne kazdy rok nadava) # miesto toho v menu stlacim "Ulozit ako" with app.collect_operations() as ops: app.d.ulozitAkoAction.execute() response = app.awaited_shell_exec(ops) # nakoniec ten dialog mozem zavriet (a pouzijem X v rohu, ako kulturny clovek) with app.collect_operations() as ops: app.d.click_close_button() app.awaited_close_dialog(ops) return response
def get_ucitelia_predmetu(self, predmet_key, akademicky_rok, semester, fakulty): (skratka_predmetu, ) = decode_key(predmet_key) app = self._open_nastenka_predmetu() fakulta = fakulty.split(',')[0] fakulta_index = find_option(app.d.fakultaComboBox.options, id=fakulta) if app.d.fakultaComboBox.selected_index != fakulta_index: app.d.fakultaComboBox.select(fakulta_index) app.d.potvrditOrgJednotkuButton.click() # automaticky nacitavanie ucitelov do tabulky app.d.nacitavatAutomatickyCheckBox.set_to(True) akademicky_rok_index = find_option(app.d.rokComboBox.options, title=akademicky_rok) if app.d.rokComboBox.selected_index != akademicky_rok_index: app.d.rokComboBox.select(akademicky_rok_index) app.d.skratkaTextField.write(skratka_predmetu) # nastavime zobrazenie vsetkych predmetov, nie len tych co # mame zapisane. zobrazit_index = find_option(app.d.zobrazitComboBox.options, id="VSETKY") if app.d.zobrazitComboBox.selected_index != zobrazit_index: app.d.zobrazitComboBox.select(zobrazit_index) mozne_semestre = [semester] if semester else ["Z", "L"] for semester in mozne_semestre: semester_index = find_option(app.d.semesterComboBox.options, id=semester) if app.d.semesterComboBox.selected_index != semester_index: app.d.semesterComboBox.select(semester_index) app.d.nacitatPredmetyButton.click() if app.d.skupinaPredmetovTable.all_rows(): app.d.skupinaPredmetovTable.select( find_row(app.d.skupinaPredmetovTable.all_rows(), skratka=skratka_predmetu)) ucitelia = [ RegUcitelPredmetu(plne_meno=row['plneMeno'], typ=row['typVyucujuceho']) for row in app.d.vyucujuciTable.all_rows() ] return ucitelia return []
def __get_prihlaseni_studenti_cez_vyber_terminu(self, app, datum, cas, miestnost, poznamka): self.__open_vyber_terminu_dialog(app) # Vyberieme spravny riadok. Ak v tabulke nie je, vypneme "Zobrazit len # aktualne terminy", stlacime nacitavaci button a skusime znovu. try: index = find_row(app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) except KeyError: index = None if index is None: app.d.aktualneTerminyCheckBox.set_to(False) app.d.zobrazitTerminyAction.execute() index = find_row(app.d.zoznamTerminovTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka) app.d.zoznamTerminovTable.select(index) # Stlacime "Zobrazit zoznam prihlasenych". with app.collect_operations() as ops: app.d.zobrazitZoznamPrihlasenychAction.execute() result = self.__process_prihlaseni_studenti_list(app, ops) # Stlacime zatvaraci button na zozname terminov. with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) return result
def spusti_report(client, app, vrchol_stromu, kod_zostavy, parametre, vystupny_format): # selectnem vrchol v strome vlavo app.d.dzTree.select(vrchol_stromu) # v tabulke vyberiem riadok s danym kodom app.d.sysTable.select(find_row(app.d.sysTable.all_rows(), kod=kod_zostavy)) # v menu stlacim "Spustenie" with app.collect_operations() as ops: app.d.sysSpustenieAction.execute() if not parametre: app.awaited_open_dialog(ops) else: assert_ops(ops, 'openDialog', 'openDialog') app.open_dialog(*ops[0].args) app.open_dialog(*ops[1].args) # v dialogu nastavim parametre for index, (label, value) in enumerate(parametre): label_id = 'inputLabel' + str(index+1) input_id = 'inputTextField' + str(index+1) if app.d.components[label_id].text != label: raise AISBehaviorError('%s mal byt %r' % (label_id, label)) app.d.components[input_id].write(value) if 'inputLabel' + str(len(parametre)+1) in app.d.components: raise AISBehaviorError('Zostava ma privela parametrov') # stlacim OK, dialog sa zavrie with app.collect_operations() as ops: app.d.enterButton.click() app.awaited_close_dialog(ops) # nastavim format vystupu app.d.vystupComboBox.select(find_option(app.d.vystupComboBox.options, title=vystupny_format)) # NESTLACAM OK, TYM SA DIALOG ZAVRIE # (for fun si najdi v mailinglistoch ako na to Vinko pravidelne kazdy rok nadava) # miesto toho v menu stlacim "Ulozit ako" with app.collect_operations() as ops: app.d.ulozitAkoAction.execute() response = app.awaited_shell_exec(ops) # nakoniec ten dialog mozem zavriet (a pouzijem X v rohu, ako kulturny clovek) with app.collect_operations() as ops: app.d.click_close_button() app.awaited_close_dialog(ops) return response
def zapis_ponuka_pridaj_predmety(self, zapisny_list_key, fakulta, stredisko, filter_skratka, filter_nazov, zvolene_skratky): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE # Otvorime ponuku predmetov a vyhladame predmety. message = self.__query_ponuka_predmetov(app, fakulta, stredisko, filter_skratka, filter_nazov) if message: return message # Odznacime vsetky vyznacene predmety (nemalo by sa stat). for row in app.d.predmetyTable.loaded_rows: if row['p'] == True: app.d.predmetyTable.edit_cell('p', row.id, False) # Vyznacime predmety, co si chceme zapisat. for skratka in zvolene_skratky: index = find_row(app.d.predmetyTable.loaded_rows, skratkaPredmet=skratka) app.d.predmetyTable.edit_cell('p', index, True) # Stlacime "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Mozno vyskoci confirm box. (Napriklad nas upozornuje, ze niektore # predmety uz mame zapisane. O inych confirm boxoch nevieme, a # dufame, ze su neskodne.) Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. (Dialog zostane otvoreny.) if len(ops) == 1 and ops[0].method == 'messageBox': return ops[0].args[0] # Dialog sa zavrie. app.awaited_close_dialog(ops) return None
def zapis_ponuka_pridaj_predmety(self, zapisny_list_key, fakulta, stredisko, filter_skratka, filter_nazov, zvolene_skratky): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE # Otvorime ponuku predmetov a vyhladame predmety. message = self.__query_ponuka_predmetov( app, fakulta, stredisko, filter_skratka, filter_nazov) if message: return message # Odznacime vsetky vyznacene predmety (nemalo by sa stat). for row in app.d.predmetyTable.loaded_rows: if row['p'] == True: app.d.predmetyTable.edit_cell('p', row.id, False) # Vyznacime predmety, co si chceme zapisat. for skratka in zvolene_skratky: index = find_row( app.d.predmetyTable.loaded_rows, skratkaPredmet=skratka) app.d.predmetyTable.edit_cell('p', index, True) # Stlacime "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Mozno vyskoci confirm box. (Napriklad nas upozornuje, ze niektore # predmety uz mame zapisane. O inych confirm boxoch nevieme, a # dufame, ze su neskodne.) Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. (Dialog zostane otvoreny.) if len(ops) == 1 and ops[0].method == 'messageBox': return ops[0].args[0] # Dialog sa zavrie. app.awaited_close_dialog(ops) return None
def __vyber_studium(self, app, studium_key): sp_skratka, zaciatok = decode_key(studium_key) # Najdeme studium. studium_index = find_row( app.d.studiaTable.all_rows(), studijnyProgramSkratka=sp_skratka, zaciatokStudia=zaciatok) # Vyberieme studium a stlacime nacitavaci button (sipku dole). if app.d.studiaTable.selected_row_indexes != [studium_index] or len(app.d.zapisneListyTable.all_rows()) == 0: with app.collect_operations() as ops: app.d.studiaTable.select(studium_index) if ops: app.awaited_refresh_dialog(ops) with app.collect_operations() as ops: app.d.nacitatButton.click() if ops: app.awaited_refresh_dialog(ops)
def __vyber_studium(self, app, studium_key): sp_skratka, zaciatok = decode_key(studium_key) # Najdeme studium. studium_index = find_row(app.d.studiaTable.all_rows(), studijnyProgramSkratka=sp_skratka, zaciatokStudia=zaciatok) # Vyberieme studium a stlacime nacitavaci button (sipku dole). if app.d.studiaTable.selected_row_indexes != [studium_index] or len( app.d.zapisneListyTable.all_rows()) == 0: with app.collect_operations() as ops: app.d.studiaTable.select(studium_index) if ops: app.awaited_refresh_dialog(ops) with app.collect_operations() as ops: app.d.nacitatButton.click() if ops: app.awaited_refresh_dialog(ops)
def odhlas_z_terminu(self, termin_key): zapisny_list_key, predmet_key, datum, cas, miestnost, poznamka = ( decode_key(termin_key)) (skratka_predmetu, ) = decode_key(predmet_key) app = self._open_terminy_hodnotenia_app(zapisny_list_key) # V dolnom combo boxe dame "Zobrazit terminy: Vsetkych predmetov". app.d.zobrazitTerminyComboBox.select(0) # Stlacime button vedla combo boxu. app.d.zobrazitTerminyAction.execute() # Vyberieme spravny riadok. app.d.terminyTable.select( find_row(app.d.terminyTable.all_rows(), dat=datum, cas=cas, miestnosti=miestnost, poznamka=poznamka, predmetSkratka=skratka_predmetu)) # Stlacime "Odhlasit sa z terminu". with app.collect_operations() as ops: app.d.odstranitButton.click() # Vyskoci confirm box, ci sa naozaj chceme odhlasit. Stlacime "Ano". assert_ops(ops, 'confirmBox') with app.collect_operations() as ops: app.confirm_box(2) if ops: assert_ops(ops, 'messageBox') return ops[0].args[0] return None
def zapis_plan_pridaj_predmety(self, zapisny_list_key, cast, dvojice_typ_vyucby_skratka): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE self.__zatvor_ponuku_predmetov(app) # Zistime, ake vsetky typy vyucby chceme zapisat. typy_vyucby = sorted(set( typ_vyucby for typ_vyucby, skratka in dvojice_typ_vyucby_skratka)) for typ_vyucby in typy_vyucby: # Oznacime dany vrchol stromu. id = 'nR/' + cast + '/' + typ_vyucby app.d.castiZapisnehoListuTree.select(id) # Stlacime "Pridat predmet zo studijneho planu". with app.collect_operations() as ops: app.d.pridatPredmetAction.execute() # Mozno vyskoci chyba. if len(ops) == 1 and ops[0].method == 'messageBox': return ops[0].args[0] # Otvori sa novy dialog. app.awaited_open_dialog(ops) # Skusime, ci uz teraz vidime vsetky hladane predmety. found_all = True for typ_vyucby_predmetu, skratka in dvojice_typ_vyucby_skratka: if typ_vyucby != typ_vyucby_predmetu: continue try: find_row( app.d.predmetyTable.all_rows(), skratkaPredmet=skratka) except KeyError: found_all = False if not found_all: # Ak nevidime, zrusime filter podla odporucaneho rocniku. index = find_option(app.d.rocnikComboBox.options, title='') app.d.rocnikComboBox.select(index) # Nacitame vsetky predmety. app.d.zobrazitPredmetyButton.click() # Teraz uz by sme mali vidiet vsetky predmety, co chceme zapisat. # Postupne ich najdeme a zapneme checkboxy. for typ_vyucby_predmetu, skratka in dvojice_typ_vyucby_skratka: if typ_vyucby != typ_vyucby_predmetu: continue index = find_row( app.d.predmetyTable.all_rows(), skratkaPredmet=skratka) app.d.predmetyTable.edit_cell('p', index, True) # Stlacime "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Mozno vyskoci confirm box. (Napriklad nas upozornuje, ze niektore # predmety uz mame zapisane. O inych confirm boxoch nevieme, a # dufame, ze su neskodne.) Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. message = None if len(ops) == 1 and ops[0].method == 'messageBox': message = ops[0].args[0] with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) if message: return message return None
def zapis_plan_pridaj_predmety(self, zapisny_list_key, cast, dvojice_typ_vyucby_skratka): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return UNAVAILABLE self.__zatvor_ponuku_predmetov(app) # Zistime, ake vsetky typy vyucby chceme zapisat. typy_vyucby = sorted( set(typ_vyucby for typ_vyucby, skratka in dvojice_typ_vyucby_skratka)) for typ_vyucby in typy_vyucby: # Oznacime dany vrchol stromu. id = 'nR/' + cast + '/' + typ_vyucby app.d.castiZapisnehoListuTree.select(id) # Stlacime "Pridat predmet zo studijneho planu". with app.collect_operations() as ops: app.d.pridatPredmetAction.execute() # Mozno vyskoci chyba. if len(ops) == 1 and ops[0].method == 'messageBox': return ops[0].args[0] # Otvori sa novy dialog. app.awaited_open_dialog(ops) # Skusime, ci uz teraz vidime vsetky hladane predmety. found_all = True for typ_vyucby_predmetu, skratka in dvojice_typ_vyucby_skratka: if typ_vyucby != typ_vyucby_predmetu: continue try: find_row(app.d.predmetyTable.all_rows(), skratkaPredmet=skratka) except KeyError: found_all = False if not found_all: # Ak nevidime, zrusime filter podla odporucaneho rocniku. index = find_option(app.d.rocnikComboBox.options, title='') app.d.rocnikComboBox.select(index) # Nacitame vsetky predmety. app.d.zobrazitPredmetyButton.click() # Teraz uz by sme mali vidiet vsetky predmety, co chceme zapisat. # Postupne ich najdeme a zapneme checkboxy. for typ_vyucby_predmetu, skratka in dvojice_typ_vyucby_skratka: if typ_vyucby != typ_vyucby_predmetu: continue index = find_row(app.d.predmetyTable.all_rows(), skratkaPredmet=skratka) app.d.predmetyTable.edit_cell('p', index, True) # Stlacime "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Mozno vyskoci confirm box. (Napriklad nas upozornuje, ze niektore # predmety uz mame zapisane. O inych confirm boxoch nevieme, a # dufame, ze su neskodne.) Zvolime "Ano". if len(ops) == 1 and ops[0].method == 'confirmBox': with app.collect_operations() as ops: app.confirm_box(2) # Mozno vyskoci chyba. message = None if len(ops) == 1 and ops[0].method == 'messageBox': message = ops[0].args[0] with app.collect_operations() as ops: app.d.click_close_button() # Dialog sa zavrie. app.awaited_close_dialog(ops) if message: return message return None
def get_studenti_zapisani_na_predmet(self, predmet_key, akademicky_rok): (skratka_predmetu,) = decode_key(predmet_key) app = self._open_register_predmetov() self.__query_dialog(app, akademicky_rok, skratka_predmetu='/'.join(skratka_predmetu.split('/')[1:-1])) app.d.zobrazitPredmetyButton.click() if not app.d.zoznamPredmetovTable.all_rows(): # predmet nebol najdeny (napriklad uz je prilis stary ale napriek # tomu ho mam v mojom hodnoteni) return [[], None] predmet_index = find_row(app.d.zoznamPredmetovTable.all_rows(), skratka=skratka_predmetu) app.d.zoznamPredmetovTable.select(predmet_index) predmet_row = app.d.zoznamPredmetovTable.all_rows()[predmet_index] predmet = RegPredmet(skratka=predmet_row['skratka'], nazov=predmet_row['nazov'], semester=predmet_row['kodSemester'], stredisko=predmet_row['stredisko'], fakulta=predmet_row['FakUniv'], rozsah_vyucby=predmet_row['rozsah'], konanie=predmet_row['konanie'], cudzi_nazov=predmet_row['nazovJ'], kredit=predmet_row['kredit']) with app.collect_operations() as ops: app.d.poctyPrihlasenychStudentovAction.execute() app.awaited_open_dialog(ops) try: app.d.dataTable.select( find_row(app.d.dataTable.all_rows(), skratka=skratka_predmetu)) except KeyError: with app.collect_operations() as ops: app.d.closeButton.click() app.awaited_close_dialog(ops) return [[], predmet] with app.collect_operations() as ops: app.d.zoznamStudentovAction.execute() app.awaited_open_dialog(ops) studenti = [PrihlasenyStudent(sp_skratka=row['studProgSkratka'], datum_prihlasenia=row['datumZapisania'], plne_meno=row['plneMeno'], rocnik=row['rokRocnik'], email=row['email']) for row in app.d.zaradeniStudentiTable.all_rows()] # zatvarame dialog so zoznamom studentov with app.collect_operations() as ops: app.d.closeButton.click() app.awaited_close_dialog(ops) # zatvarame dialog pocty studentov with app.collect_operations() as ops: app.d.closeButton.click() app.awaited_close_dialog(ops) return [studenti, predmet]