Example #1
0
    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
Example #2
0
    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
Example #3
0
    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
Example #4
0
File: zapis.py Project: Adman/votr
    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
Example #5
0
    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
Example #6
0
    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)
Example #7
0
    def _open_register_osob(self):
        url = '/ais/servlets/WebUIServlet?fajr=A&appClassName=ais.gui.lz.LZ014App&kodAplikacie=LZ014&uiLang=SK'
        app, ops = Application.open(self.context, url)
        assert_ops(ops, 'openMainDialog', 'openDialog')

        app.open_main_dialog(*ops[0].args)
        app.open_dialog(*ops[1].args)

        return app
Example #8
0
File: osoby.py Project: Adman/votr
    def _open_register_osob(self):
        url = '/ais/servlets/WebUIServlet?fajr=A&appClassName=ais.gui.lz.LZ014App&kodAplikacie=LZ014&uiLang=SK'
        app, ops = Application.open(self.context, url)
        assert_ops(ops, 'openMainDialog', 'openDialog')

        app.open_main_dialog(*ops[0].args)
        app.open_dialog(*ops[1].args)

        return app
Example #9
0
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
Example #10
0
File: osoby.py Project: Adman/votr
    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)
Example #11
0
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
Example #12
0
    def _select_ciselnik(self, app, text, select_button, compare_column):
        # Ciselnik typu SSSC001
        if text is not None:
            old_ignored_messages = app.ignored_messages
            app.ignored_messages = [
                m for m in app.ignored_messages
                if m != 'Podmienkam nevyhovuje žiadny záznam.'
            ]
            try:
                with app.collect_operations() as ops:
                    app.d.components[select_button].click()
            finally:
                app.ignored_messages = old_ignored_messages

            if ops:
                if len(ops) == 1 and ops[0].method == 'messageBox' and ops[
                        0].args[0] == 'Podmienkam nevyhovuje žiadny záznam.':
                    return False

                assert_ops(ops, 'openDialog')

                if ops[0].args[0]['code'] != 'SSSC001':
                    raise AISBehaviorError(
                        "AIS opened an unexpected dialog: {}".format(ops))

                app.awaited_open_dialog(ops)
                try:
                    index = find_row_insensitive(app.d.table.all_rows(),
                                                 **{compare_column: text})
                except KeyError:
                    with app.collect_operations() as ops:
                        app.d.closeButton.click()

                    app.awaited_close_dialog(ops)

                    return False
                else:
                    app.d.table.select(index)

                    with app.collect_operations() as ops:
                        app.d.enterButton.click()

                    app.awaited_close_dialog(ops)

        return True
Example #13
0
    def get_informacny_list(self, kod_predmetu, akademicky_rok):
        app = self._open_register_predmetov()

        stredisko, _, zvysok = decode_key(kod_predmetu)[0].partition('/')
        skratka = zvysok.rpartition('/')[0]

        # Napiseme stredisko a skratku predmetu.
        self.__query_dialog(app,
                            akademicky_rok,
                            stredisko=stredisko,
                            skratka_predmetu=skratka)

        # 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 ops2:
            app.abort_box(*ops[1].args)

        # Vratime zakodove PDF.
        url = app.awaited_shell_exec(ops2)
        return base64.b64encode(url.content).decode()
Example #14
0
    def delete_zapisny_list(self, zapisny_list_key):
        '''Deletes enrollment list.

        Args:
            zapisny_list_key: enrollment list identifier
        '''
        app = self._open_administracia_studia()

        # Vyberieme zapisny list.
        self.__vyber_zapisny_list(app, zapisny_list_key)

        # Klikneme na tlacidlo zrusenia zapisneho listu.
        with app.collect_operations() as ops:
            app.d.odobratZapisnyListButton.click()

        # Vyskoci confirm box, ci naozaj chceme odstranit zapisny list. Stlacime "Ano".
        assert_ops(ops, 'confirmBox')
        with app.collect_operations() as ops:
            app.confirm_box(2)
Example #15
0
    def _select_ciselnik(self, app, text, select_button, compare_column):
        # Ciselnik typu SSSC001
        if text is not None:
            old_ignored_messages = app.ignored_messages
            app.ignored_messages = []
            try:
                with app.collect_operations() as ops:
                    app.d.components[select_button].click()
            finally:
                app.ignored_messages = old_ignored_messages

            if ops:
                if (
                    len(ops) == 1
                    and ops[0].method == "messageBox"
                    and ops[0].args[0] == "Podmienkam nevyhovuje žiadny záznam."
                ):
                    return False

                assert_ops(ops, "openDialog")

                if ops[0].args[2] != "SSSC001":
                    raise AISBehaviorError("AIS opened an unexpected dialog: {}".format(ops))

                app.awaited_open_dialog(ops)
                try:
                    index = find_row_insensitive(app.d.table.all_rows(), **{compare_column: text})
                except KeyError:
                    with app.collect_operations() as ops:
                        app.d.closeButton.click()

                    app.awaited_close_dialog(ops)

                    return False
                else:
                    app.d.table.select(index)

                    with app.collect_operations() as ops:
                        app.d.enterButton.click()

                    app.awaited_close_dialog(ops)

        return True
Example #16
0
    def delete_zapisny_list(self, zapisny_list_key):
        '''Deletes enrollment list.

        Args:
            zapisny_list_key: enrollment list identifier
        '''
        app = self._open_administracia_studia()

        # Vyberieme zapisny list.
        self.__vyber_zapisny_list(app, zapisny_list_key)

        # Klikneme na tlacidlo zrusenia zapisneho listu.
        with app.collect_operations() as ops:
            app.d.odobratZapisnyListButton.click()

        # Vyskoci confirm box, ci naozaj chceme odstranit zapisny list. Stlacime "Ano".
        assert_ops(ops, 'confirmBox')
        with app.collect_operations() as ops:
            app.confirm_box(2)
Example #17
0
    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)
Example #18
0
    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