def create_zapisny_list(self, studium_key, akademicky_rok, rok_studia): '''Creates enrollment list. Args: studium_key: studium identifier akademicky_rok: Academic year of the time range in the form of 'start/end'. E.g. '2013/2014'. (optional) rok_studia: year of the study ''' app = self._open_administracia_studia() self.__open_novy_zapisny_list_dialog(app, studium_key) # V combo boxe vyberieme rok studia. app.d.rocnikComboBox.select( find_option(app.d.rocnikComboBox.options, id=str(rok_studia))) # Ak je nastaveny akademicky rok, vyberieme ho v combo boxe. if akademicky_rok is not None: app.d.rokComboBox.select( find_option(app.d.rokComboBox.options, id=akademicky_rok)) # Stlacime tlacidlo "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Dialog sa zavrie. app.awaited_close_dialog(ops)
def create_zapisny_list(self, studium_key, akademicky_rok, rok_studia): '''Creates enrollment list. Args: studium_key: studium identifier akademicky_rok: Academic year of the time range in the form of 'start/end'. E.g. '2013/2014'. (optional) rok_studia: year of the study ''' app = self._open_administracia_studia() self.__open_novy_zapisny_list_dialog(app, studium_key) # V combo boxe vyberieme rok studia. app.d.rocnikComboBox.select(find_option(app.d.rocnikComboBox.options, id=str(rok_studia))) # Ak je nastaveny akademicky rok, vyberieme ho v combo boxe. if akademicky_rok is not None: app.d.rokComboBox.select(find_option(app.d.rokComboBox.options, id=akademicky_rok)) # Stlacime tlacidlo "OK". with app.collect_operations() as ops: app.d.enterButton.click() # Dialog sa zavrie. app.awaited_close_dialog(ops)
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 __query_ponuka_predmetov(self, app, fakulta, stredisko, filter_skratka, filter_nazov): message = self.__otvor_ponuku_predmetov(app) if message: return message if (app.d.fakultaComboBox.selected_option.id == (fakulta or '') and app.d.predmetSkratkaTextField.value == (filter_skratka or '') and app.d.predmetNazovTextField.value == (filter_nazov or '') and app.d.strediskoSkratkaTextField.value == (stredisko or '') and (not stredisko or not app.d.strediskoTextTextField.value)): return None app.d.fakultaComboBox.select(find_option(app.d.fakultaComboBox.options, id=(fakulta or ''))) app.d.predmetSkratkaTextField.write(filter_skratka or '') app.d.predmetNazovTextField.write(filter_nazov or '') if not self._select_text_ciselnik( app, stredisko, 'strediskoSkratkaTextField', app.d.zmazatStrediskoAction.component_ids[0], app.d.vybratStrediskoAction.component_ids[0], 'skratka'): return "Stredisko neexistuje." app.d.zobrazitPredmetyAction.execute() while not app.d.predmetyTable.is_end_of_data: app.d.predmetyTable.scroll_down(10) return None
def __query_ponuka_predmetov(self, app, fakulta, stredisko, filter_skratka, filter_nazov): message = self.__otvor_ponuku_predmetov(app) if message: return message if (app.d.fakultaComboBox.selected_option.id == (fakulta or '') and app.d.predmetSkratkaTextField.value == (filter_skratka or '') and app.d.predmetNazovTextField.value == (filter_nazov or '') and app.d.strediskoSkratkaTextField.value == (stredisko or '') and (not stredisko or not app.d.strediskoTextTextField.value)): return None app.d.fakultaComboBox.select( find_option(app.d.fakultaComboBox.options, id=(fakulta or ''))) app.d.predmetSkratkaTextField.write(filter_skratka or '') app.d.predmetNazovTextField.write(filter_nazov or '') if not self._select_text_ciselnik( app, stredisko, 'strediskoSkratkaTextField', app.d.zmazatStrediskoAction.component_ids[0], app.d.vybratStrediskoAction.component_ids[0], 'skratka'): return "Stredisko neexistuje." app.d.zobrazitPredmetyAction.execute() while not app.d.predmetyTable.is_end_of_data: app.d.predmetyTable.scroll_down(10) return None
def __query_dialog(self, app, meno, priezvisko, absolvent, student, zamestnanec, akademicky_rok, fakulta, studijny_program, uchadzaci, prvy_rocnik, druhy_rocnik, treti_rocnik, stvrty_rocnik, piaty_rocnik, siesty_rocnik, siedmy_rocnik, osmy_rocnik, absolventi): rocniky = [ uchadzaci, prvy_rocnik, druhy_rocnik, treti_rocnik, stvrty_rocnik, piaty_rocnik, siesty_rocnik, siedmy_rocnik, osmy_rocnik, absolventi ] if any(rocniky) and not (absolvent or student or zamestnanec): student = True if studijny_program and not (absolvent or student or zamestnanec): absolvent = True student = True if fakulta and not (absolvent or student or zamestnanec): absolvent = True student = True zamestnanec = True app.d.absolventCheckBox.set_to(absolvent) app.d.studentCheckBox.set_to(student) app.d.zamestnanecCheckBox.set_to(zamestnanec) app.d.menoTextField.write(meno or '') app.d.priezviskoTextField.write(priezvisko or '') if absolvent or student or zamestnanec: app.d.akademickyRokComboBox.select( find_option(app.d.akademickyRokComboBox.options, title=akademicky_rok)) with app.collect_operations() as ops: app.d.odstranitFakultuButton.click() if ops: assert_ops( ops, 'messageBox' ) # "Interna chyba: Nepodarilo sa osetrenie udalosti." if not self._select_ciselnik(app, fakulta or None, "VyberFakultaButton", "skratka"): return 'Fakulta nebola nájdená.' app.d.odstranitOdborButton.click() if not self._select_ciselnik(app, studijny_program or None, "VyberOdborButton", "skratka"): return 'Študijný program sa nenašiel, skontrolujte fakultu.' for index, item in enumerate(rocniky): if item != app.d.rocnikCheckList.items[index].checked: app.d.rocnikCheckList.toggle(index)
def export_predmet_katedra(args): akademicky_rok, fakulta, semester, output_filename = args client = prihlas_sa() app = client._open_register_predmetov() app.d.fakultaUniverzitaComboBox.select(find_option(app.d.fakultaUniverzitaComboBox.options, id=fakulta)) app.d.akRokComboBox.select(find_option(app.d.akRokComboBox.options, id=akademicky_rok)) app.d.semesterComboBox.select(find_option(app.d.semesterComboBox.options, id=semester)) app.d.zobrazitPredmetyButton.click() with app.collect_operations() as ops: app.d.printButton.click() with app.collect_operations() as ops2: app.awaited_abort_box(ops) with app.collect_operations() as ops3: app.awaited_abort_box(ops2) response = app.awaited_shell_exec(ops3) response.encoding = 'utf8' html_to_csv(client, response.text, output_filename)
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 __query_dialog(self, app, meno, priezvisko, absolvent, student, zamestnanec, akademicky_rok, fakulta, studijny_program, uchadzaci, prvy_rocnik, druhy_rocnik, treti_rocnik, stvrty_rocnik, piaty_rocnik, siesty_rocnik, siedmy_rocnik, osmy_rocnik, absolventi): rocniky = [uchadzaci, prvy_rocnik, druhy_rocnik, treti_rocnik, stvrty_rocnik, piaty_rocnik, siesty_rocnik, siedmy_rocnik, osmy_rocnik, absolventi] if any(rocniky) and not (absolvent or student or zamestnanec): student = True if studijny_program and not (absolvent or student or zamestnanec): absolvent = True student = True if fakulta and not (absolvent or student or zamestnanec): absolvent = True student = True zamestnanec = True app.d.absolventCheckBox.set_to(absolvent) app.d.studentCheckBox.set_to(student) app.d.zamestnanecCheckBox.set_to(zamestnanec) app.d.menoTextField.write(meno or '') app.d.priezviskoTextField.write(priezvisko or '') if absolvent or student or zamestnanec: app.d.akademickyRokComboBox.select(find_option( app.d.akademickyRokComboBox.options, title=akademicky_rok)) with app.collect_operations() as ops: app.d.odstranitFakultuButton.click() if ops: assert_ops(ops, 'messageBox') # "Interna chyba: Nepodarilo sa osetrenie udalosti." if not self._select_ciselnik(app, fakulta or None, "VyberFakultaButton", "skratka"): return 'Fakulta nebola nájdená.' app.d.odstranitOdborButton.click() if not self._select_ciselnik(app, studijny_program or None, "VyberOdborButton", "skratka"): return 'Študijný program sa nenašiel, skontrolujte fakultu.' for index, item in enumerate(rocniky): if item != app.d.rocnikCheckList.items[index].checked: app.d.rocnikCheckList.toggle(index)
def __query_dialog(self, app, akademicky_rok, fakulta=None, semester=None, stupen_predmetu=None, typ_predmetu=None, zobrazit_len=None, skratka_predmetu=None, nazov_predmetu=None, cislo_predmetu=None, stredisko=None, skratka_sp=None): message = [] app.d.fakultaUniverzitaComboBox.select( find_option(app.d.fakultaUniverzitaComboBox.options, id=(fakulta or ''))) app.d.semesterComboBox.select( find_option(app.d.semesterComboBox.options, id=(semester or ''))) app.d.stupenPredmetuComboBox.select( find_option(app.d.stupenPredmetuComboBox.options, id=(stupen_predmetu or ''))) app.d.typPredmetuComboBox.select( find_option(app.d.typPredmetuComboBox.options, id=(typ_predmetu or ''))) app.d.zobrazitLenComboBox.select( find_option(app.d.zobrazitLenComboBox.options, id=(zobrazit_len or ''))) app.d.skratkaPredmetuTextField.write(skratka_predmetu or '') app.d.nazovPredmetuTextField.write(nazov_predmetu or '') app.d.cisloPredmetuNumberControl.write(cislo_predmetu or '') if not self._select_text_ciselnik( app, stredisko, 'skratkaStrediskaTextField', 'zmazatStrediskoButton', 'vybratStrediskoButton', 'skratka'): message.append("Stredisko neexistuje.") if not self._select_text_ciselnik( app, skratka_sp, 'skratkaStudProgramuTextField', 'zmazatStudProgramButton', 'vybratStudProogramButton', 'skratka'): message.append("Študijný program neexistuje.") if app.d.vyucujuciTextField.value: app.d.odobratVyucujucehoButton.click() app.d.akRokComboBox.select( find_option(app.d.akRokComboBox.options, id=akademicky_rok)) return ' '.join(message) or None
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 export_predmet_katedra(args): akademicky_rok, fakulta, semester, output_filename = args client = prihlas_sa() app = client._open_register_predmetov() app.d.fakultaUniverzitaComboBox.select( find_option(app.d.fakultaUniverzitaComboBox.options, id=fakulta)) app.d.akRokComboBox.select( find_option(app.d.akRokComboBox.options, id=akademicky_rok)) app.d.semesterComboBox.select( find_option(app.d.semesterComboBox.options, id=semester)) app.d.zobrazitPredmetyButton.click() with app.collect_operations() as ops: app.d.printButton.click() with app.collect_operations() as ops2: app.awaited_abort_box(ops) with app.collect_operations() as ops3: app.awaited_abort_box(ops2) response = app.awaited_shell_exec(ops3) response.encoding = 'utf8' html_to_csv(client, response.text, output_filename)
def get_informacny_list(self, kod_predmetu, akademicky_rok): app = self._open_register_predmetov() index = find_option( app.d.akRokComboBox.options, title=akademicky_rok) app.d.akRokComboBox.select(index) # Napiseme kod predmetu. app.d.skratkaPredmetuTextField.write(kod_predmetu) # Stlacime nacitavaci button (sipku dole). app.d.zobrazitPredmetyButton.click() if not app.d.zoznamPredmetovTable.loaded_rows: return None # TODO: zdokumentovat, ze ak matchuju viacere informacne listy, je # undefined behavior ktory vratime. (asi vzdy ten prvy, ale kto vie ako # ich AIS zoradi.) # Stlacime v menu "Informacny list". with app.collect_operations() as ops: app.d.infListMenuItem.click() # Otvori sa dialog na vyber formatu. app.awaited_open_dialog(ops) # Vyberieme vrchny riadok. TODO: fakt chceme ten? app.d.sablonyTable.select(0) # Stlacime OK. with app.collect_operations() as ops: app.d.enterButton.click() # Dialog sa zavrie a otvori sa "prosim cakajte", tak cakame. assert_ops(ops, 'closeDialog', 'abortBox') app.close_dialog(*ops[0].args) with app.collect_operations() as ops: app.abort_box() # Otvori sa vysledne PDF. url = app.awaited_shell_exec(ops) return app.context.request_text(url)
def __vyber_oba_semestre(self, app): index = find_option(app.d.semesterComboBox.options, title='') if app.d.semesterComboBox.selected_index != index: app.d.semesterComboBox.select(index) app.d.filterAction.execute()
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_vyhladaj(self, zapisny_list_key, cast): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return [[], UNAVAILABLE] self.__zatvor_ponuku_predmetov(app) # AIS ponuka styri dialogy na pridavanie predmetov: # (1) "Pridat predmet zo studijneho planu" # (2) "Pridat predmet z ponuky predmetov" # (3) "Pridat neabsolvovany predmet" # (4) "Pridat odporucany predmet" # Zoznam ponukanych predmetov sa da zistit cez (1), (2) aj (4). (Pre # (2) mozme dat vyhladat vsetky predmety a zoradit ich podla bloku. Ale # to je dost pomale.) My pouzivame (1), lebo v tabulke su viacere dobre # stlpce, ako odporucany rocnik a "oficialne poradie" predmetov. Lenze # tieto stlpce su schovane, takze ich najprv musime zobrazit. # Optimalizacia pre SC (Studijna cast): Staci otvorit iba C (Vyberove # predmety), mozme vypnut filtrovanie podla typu vyucby a uvidime aj # A a B. Ale nesmieme ich tak zapisovat, lebo AIS ich zapise ako C, co # na studijnom nemaju radi. result = [] # Skusime kazdy vrchol stromu, co nas zaujima. for id, node in app.d.castiZapisnehoListuTree.nodes.items(): if not node.is_leaf: continue if '/' + cast + '/' not in id: continue if id in ('nR/SC/A', 'nR/SC/B'): continue # Oznacime dany vrchol stromu. 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) # Zapneme schovane stlpce. want = ['kodTypVyucby', 'popis', 'poradieB', 'poradieP', 'kodCastSP'] if any(col not in app.d.predmetyTable.column_map for col in want): self._show_all_columns(app, app.d.predmetyTable) # Zrusime filter podla odporucaneho rocniku. index = find_option(app.d.rocnikComboBox.options, title='') app.d.rocnikComboBox.select(index) # Ak sa da, zrusime filter podla typu vyucby. if app.d.typComboBox.is_really_enabled(): index = find_option(app.d.typComboBox.options, title='') app.d.typComboBox.select(index) # Nacitame vsetky predmety. app.d.zobrazitPredmetyButton.click() result.extend(ZapisPredmet(skratka=row['skratkaPredmet'], nazov=row['nazovPredmet'], typ_vyucby=row['kodTypVyucby'], semester=row['kodSemester'], kredit=row['kredit'], rozsah_vyucby=row['rozsah'], jazyk=row['jazyk'], datum_zapisu=None, aktualnost=row['kodAktualnost'], pocet_prihlasenych=row['pocetStudentov'], maximalne_prihlasenych=row['obmedzenie'], blok_skratka=row['skratkaBlok'], blok_nazov=row['popis'], blok_index=row['poradieB'], v_bloku_index=row['poradieP'], odporucany_rocnik=row['rocnik'], cast=row['kodCastSP']) for row in app.d.predmetyTable.all_rows()) # Ked sme hotovi, zavrieme dialog. with app.collect_operations() as ops: app.d.click_close_button() app.awaited_close_dialog(ops) return [result, None]
def zapis_plan_vyhladaj(self, zapisny_list_key, cast): try: app = self._open_zapis_predmetov_app(zapisny_list_key) except CantOpenApplication: return [[], UNAVAILABLE] self.__zatvor_ponuku_predmetov(app) # AIS ponuka styri dialogy na pridavanie predmetov: # (1) "Pridat predmet zo studijneho planu" # (2) "Pridat predmet z ponuky predmetov" # (3) "Pridat neabsolvovany predmet" # (4) "Pridat odporucany predmet" # Zoznam ponukanych predmetov sa da zistit cez (1), (2) aj (4). (Pre # (2) mozme dat vyhladat vsetky predmety a zoradit ich podla bloku. Ale # to je dost pomale.) My pouzivame (1), lebo v tabulke su viacere dobre # stlpce, ako odporucany rocnik a "oficialne poradie" predmetov. Lenze # tieto stlpce su schovane, takze ich najprv musime zobrazit. # Optimalizacia pre SC (Studijna cast): Staci otvorit iba C (Vyberove # predmety), mozme vypnut filtrovanie podla typu vyucby a uvidime aj # A a B. Ale nesmieme ich tak zapisovat, lebo AIS ich zapise ako C, co # na studijnom nemaju radi. result = [] # Skusime kazdy vrchol stromu, co nas zaujima. for id, node in app.d.castiZapisnehoListuTree.nodes.items(): if not node.is_leaf: continue if '/' + cast + '/' not in id: continue if id in ('nR/SC/A', 'nR/SC/B'): continue # Oznacime dany vrchol stromu. 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) # Zapneme schovane stlpce. want = [ 'kodTypVyucby', 'popis', 'poradieB', 'poradieP', 'kodCastSP' ] if any(col not in app.d.predmetyTable.column_map for col in want): self._show_all_columns(app, app.d.predmetyTable) # Zrusime filter podla odporucaneho rocniku. index = find_option(app.d.rocnikComboBox.options, title='') app.d.rocnikComboBox.select(index) # Ak sa da, zrusime filter podla typu vyucby. if app.d.typComboBox.is_really_enabled(): index = find_option(app.d.typComboBox.options, title='') app.d.typComboBox.select(index) # Nacitame vsetky predmety. app.d.zobrazitPredmetyButton.click() result.extend( ZapisPredmet(skratka=row['skratkaPredmet'], nazov=row['nazovPredmet'], typ_vyucby=row['kodTypVyucby'], semester=row['kodSemester'], kredit=row['kredit'], rozsah_vyucby=row['rozsah'], jazyk=row['jazyk'], datum_zapisu=None, aktualnost=row['kodAktualnost'], pocet_prihlasenych=row['pocetStudentov'], maximalne_prihlasenych=row['obmedzenie'], blok_skratka=row['skratkaBlok'], blok_nazov=row['popis'], blok_index=row['poradieB'], v_bloku_index=row['poradieP'], odporucany_rocnik=row['rocnik'], cast=row['kodCastSP']) for row in app.d.predmetyTable.all_rows()) # Ked sme hotovi, zavrieme dialog. with app.collect_operations() as ops: app.d.click_close_button() app.awaited_close_dialog(ops) return [result, 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