Skip to content

Commit a07a58f

Browse files
authored
Merge pull request #238 from fmfi-svt/mrshu/ais-birthplace-hotfix
hotfix: Birthplace in ASI2
2 parents 09ce1f1 + 91a1553 commit a07a58f

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

eprihlaska/ais_utils.py

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ def save_application_form(ctx,
192192
app.d.c31Button.click()
193193

194194
if session['country_of_birth'] == '703':
195-
app.d.sklonovanieNarTextField.write(session['place_of_birth'])
196-
197-
with app.collect_operations() as ops:
198-
app.d.vyberMiestoNarodeniabutton.click()
195+
place_of_birth_psc = lists['city_psc'][session['place_of_birth']]
196+
select_city_by_psc_ciselnik_code(app,
197+
place_of_birth_psc,
198+
session['place_of_birth'],
199+
app.d.sklonovanieNarTextField, app.d.vyberMiestoNarodeniabutton)
199200
else:
200201
app.d.statNarodeniaTextField.write(lists['country'][session['country_of_birth']]) # noqa
201202
with app.collect_operations() as ops:
@@ -496,36 +497,10 @@ def fill_in_address(field, app, session, lists):
496497
with app.collect_operations() as ops:
497498
fields['country_button'].click()
498499

499-
500-
# Write PSC instead of city name (TODO: hack to work with current AIS)
501-
fields['city'].write(city_psc)
502-
with app.collect_operations() as ops:
503-
fields['city_button'].click()
504-
505-
if len(ops) == 1 and ops[-1].method == 'openDialog':
506-
# Open selection dialogue
507-
select_dlg = app.awaited_open_dialog(ops)
508-
509-
rows = app.d.table.all_rows()
510-
511-
# Let's try to find the correct row by checking the PSC
512-
row_index = None
513-
for idx, row in enumerate(rows):
514-
print('city_psc: {}, row_value: {}'.format(city_psc, row.cells[2].value), file=sys.stderr)
515-
if row.cells[2].value == city_psc:
516-
row_index = idx
517-
518-
# If we did find a row, let's select it
519-
if row_index is not None:
520-
app.d.table.select(row_index)
521-
#else:
522-
# raise Exception('Could not find city_psc {}'.format(city_psc))
523-
524-
with app.collect_operations() as ops:
525-
app.d.enterButton.click()
526-
527-
# Close selection dialogue
528-
select_dlg = app.awaited_close_dialog(ops)
500+
select_city_by_psc_ciselnik_code(app,
501+
city_psc,
502+
session[field]['city'],
503+
fields['city'], fields['city_button'])
529504

530505
# TODO: hack to work with current AIS
531506
# Write the actual city to "Post office" field
@@ -762,3 +737,40 @@ def choose_study_programme(app, ops, study_programme):
762737
app.awaited_close_dialog(ops)
763738
else:
764739
raise Exception('Unexpected ops: {}'.format(ops))
740+
741+
742+
def select_city_by_psc_ciselnik_code(app, city_psc, ciselnik_code, city_field, city_button):
743+
# Write PSC instead of city name (TODO: hack to work with current AIS)
744+
city_field.write(city_psc)
745+
with app.collect_operations() as ops:
746+
city_button.click()
747+
748+
if len(ops) == 0:
749+
return
750+
751+
if len(ops) == 1 and ops[-1].method == 'openDialog':
752+
# Open selection dialogue
753+
select_dlg = app.awaited_open_dialog(ops)
754+
755+
rows = app.d.table.all_rows()
756+
757+
# Let's try to find the correct row by checking the ciselnik_code
758+
row_index = None
759+
for idx, row in enumerate(rows):
760+
print('ciselnik_code: {}, row_value: {}'.format(ciselnik_code, row.cells[0].value), file=sys.stderr)
761+
if row.cells[0].value == ciselnik_code:
762+
row_index = idx
763+
764+
# If we did find a row, let's select it
765+
if row_index is not None:
766+
app.d.table.select(row_index)
767+
else:
768+
raise Exception('Could not find ciselnik_code {}'.format(city_psc))
769+
770+
with app.collect_operations() as ops:
771+
app.d.enterButton.click()
772+
773+
# Close selection dialogue
774+
select_dlg = app.awaited_close_dialog(ops)
775+
else:
776+
raise Exception('Expected openDialog in select_city_by_psc_ciselnik_code')

0 commit comments

Comments
 (0)